0

I am wondering if it is possible to run a fadeOut action half way through a moveTo action all on the same node. Here is my code:

id show = [CCShow action];
id move = [CCMoveTo actionWithDuration:2.5f position:ccp(70, 275)];
id seq = [CCSequence actions:show, move, nil];
id fade = [CCFadeOut actionWithDuration:2.5f];
id spawn = [CCSpawn actions:seq, fade, nil];
[extraTime runAction:spawn];

I need to be able to run the fade action half way through the move action if that is possible. Any help or suggestions would be appreciated.

Stephen
  • 499
  • 9
  • 28

1 Answers1

2

stall the fade like this

id delayFade = [CCDelayTime actionWithDuration:1.25];
id stallAndFade = [CCSequence actions:delayFade,fade,nil];

and modify your spawn to:

id spawn = [CCSpawn actions:seq,stallAndFade,nil];

ob cit. (not tested, from menory, cocos2d 2.0)

YvesLeBorg
  • 9,070
  • 8
  • 35
  • 48
  • dont remember , i think the syntax or class name of CCDelayTime is different under 1.1, but you should find the moral equivalent. – YvesLeBorg Sep 18 '13 at 15:57
  • Thanks. I had just one more question, is there a method for resetting a sprite/nodes position after a move action has been called or do I need to just create my own method and reset its values. Or would it be better for performance to destroy and recreate the sprite after these actions? – Stephen Sep 18 '13 at 16:01
  • i'd just add one more action at the end of seq, probably a CCCallFunc to invoke a class method to just reset the position for the sprite, its visibility, opacity and whatever else you may want to do. I tend to keep my sprites around whenever possible. – YvesLeBorg Sep 18 '13 at 16:10