cocos2d cache / shows sprites with animation


i am spending a lot for my time for a simple things i think.I want to hide and show a sprite in scene.

 myS = [CCSprite spriteWithFile:@"Background_Pause_pad.png"];
    [myS setPosition:ccp(384,470)];
     myS.opacity = 0;
    [self addChild:myS z:1];

and when i need to appear it..

[myS runAction:[CCFadeIn actionWithDuration:1]];

and hide it

[myS runAction:[CCFadeOut actionWithDuration:1]];

but it does not work.....can anyone plz help??

  1. Why do you use a Sequence for one action ?
  2. You have to choose the animation you want !
  3. E.g : if you choose CCFadeIn
[mySprite runAction:[CCFadeIn actionWithDuration:0.5f]];