views:

2582

answers:

1

How would one go about creating a custom action in Cocos2D that was able to perform a 'callback' over time, making each call to the callback progressively longer than the last call to it (using something similar to the EaseExponentialOut action already provided with Cocos2D.

Something similar to this: (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 executes the 'play' callback at the end of the last sequence.

However, the EaseExponentialOut does not appear to have any affect at all on the 'repeat' action that is created - I had expected it to adjust the duration of the 'DelayTime' action inside of the 'sequence' action, but it does not appear to do this.

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

+1  A: 

Apparently, the code above is functional, it was just my use of the timing in the durations. It was also not necessary to use 'copy', as the actions are usable as is.

If I increased my timing from 0.034 to something more along the lines of 0.25, then the result was closer to what I was hoping to see. Now I just have to play with the values for duration to get it 'just right'.

David Higgins
Hey I am trying to implement something like a bouncing ball. Will you please help me in implementing it like how to use the ease function for that particular thing.
rkb
I'd need more information than that, and you'd probably get a bit further if you posted the question to everyone.
David Higgins