开发者

cocos2d hide/show sprites with animation

开发者 https://www.devze.com 2023-01-22 13:43 出处:网络
i am spending a lot for my time for a simple things i think.I want to hide and show a sprite in scene.

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 spriteWi开发者_运维技巧thFile:@"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]];


I think you can try the below stuff of the code. It would work for you

id action1 = [CCFadeIn actionWithDuration:1];
id action2 = [CCDelayTime actionWithDuration:1];
id action3 = [CCFadeOut actionWithDuration:1];

[myS runAction:[CCSequence actions:action1,action2,action3,nil]];

As you need the fadein fadeout action it would generate it and display the Same.

0

精彩评论

暂无评论...
验证码 换一张
取 消