views:

149

answers:

2

I have two logos, which I want to come in after each other.

I'd like to use CCFadeIn and CCFadeOut.

I have Logo1, and then I want it to CCFadeIn, then I want it to stay for 2 seconds, then make it fade out using CCFadeOut, and then make Logo2 CCFadeIn for 1 second, stay for 2 seconds and then go away during 1 second with CCFadeOut.

How I would make this I'm not completely sure. I can't seem to find a way to make a CCAction fire a method (let's say -finishedFadingInLogo1:), so I don't know how to do this.

Any ideas?

+2  A: 

...somewhere:...

[logo1 runAction:[CCSequence actions:[CCFadeIn actionWithDuration:SOMETIME], [CCDelayTime actionWithDuration:2], [CCFadeOut actionWithDuration:SOMEOTHERTIME], [CCCallFunc actionWithTarget:SOMETARGET selector:@selector(finishedFadingInLogo1)], nil]];

...

  • (void)finishedFadingInLogo1 { [logo2 runAction:blah, yada, nil]; }

make sense? There are other actions similar to CCCallFunc that take args and such...

Colin
Nice!! It works, thank you. :D
Johannes Jensen
Tip: better formatting would help to illustrate the point. Personally i also wouldn't stuff all the actions into the sequence line, instead create local variables that holds each action. Makes for much better readable (and maintainable) code.
GamingHorror
A: 

For better readability, Colin's answer reformatted:

id fadein = [CCFadeIn actionWithDuration:2];
id delay = [CCDelayTime actionWithDuration:2];
id fadeout = [CCFadeOut actionWithDuration:2];
id call = [CCCallFunc actionWithTarget:self selector:@selector(doneFading)];
CCSequence* sequence = [CCSequence actions:fadein, delay, fadeout, call, nil];
[aNode runAction:sequence];
GamingHorror