Search code examples
objective-ccocos2d-iphonefadeccnode

FadeTo animation doesn't work. cocos2d


According to this code node must slowly appear, right? It doesn't work. What is wrong?

   CCNodeColor *_backNode = [CCNodeColor nodeWithColor:[CCColor colorWithRed:0 green:0 blue:0    alpha:1.0f]];
    _backNode.opacity=0;
    [self addChild:_backNode z:5];
  [_backNode runAction:[CCActionFadeTo actionWithDuration:2 opacity:0.9]];

Solution

  • Try it with alpha = 0 and not setting opacity:

    CCNodeColor *_backNode = [CCNodeColor nodeWithColor:[CCColor colorWithRed:0 
                                                                        green:0
                                                                         blue:0
                                                                        alpha:0.0f]];