Custom Simplified Action with Cocos2D-iphone

How could you create a custom action in Cocos2D that could execute a “callback” over time, making each callback call longer than its last call (using something similar to the EaseExponentialOut action already provided with Cocos2D.

Something similar: (which does not work)

id sequence = [Sequence actions: [CallFunc actionWithTarget: self selector: @selector(spinTick)], [DelayTime actionWithDuration: 0.034f], nil];
id repeat = [Repeat actionWithAction: [sequence copy]  times: 18];
id ease = [EaseExponentialOut actionWithAction: [repeat copy]];
[ease setDuration:4];

id play = [CallFunc actionWithTarget:self selector:@selector(play)];
[self runAction: [Sequence actions: [ease copy], [play copy], nil]];

The above code executes the entire “sequence” 18 times, and then performs a “play” callback at the end of the last sequence.

However, the EaseExponentialOut has no effect on the created repeat action - I expected it to adjust the duration of the DelayTime action inside the sequence action, but that doesn't seem to do it.

I also tried to create my own custom action based on IntervalAction, but failed.

+5
source share
1 answer

Apparently the above code is functional, it's just my use of time in duration. Also, there was no need to use a “copy”, since actions can be used as is.

If I increased the time from 0.034 to something more along the lines of 0.25, the result was closer to what I was hoping to see. Now I just need to play with the values ​​for the duration in order to get the "right".

+2
source

All Articles