Ok, having success here - got the CallFuncN approach working. But there is a timing / sync issue.
Have a look at this code:
@implementation SpriteEaseSineInOut
-(void) onEnter
{
[super onEnter];
id move = [MoveBy actionWithDuration:0.5f position:ccp(0,200)];
//id move_back = [move reverse];
id move_ease = [EaseSineInOut actionWithAction:[[move copy] autorelease]];
id move_ease_back = [move_ease reverse];
//id move_title = [MoveBy actionWithDuration:1 position:ccp(0,-320)];
//id move_title_back = [move reverse];
//id move_title_ease_in = [EaseSineIn actionWithAction:[[move_title copy] autorelease]];
//id move_title_ease_in_back = [move_title_ease_in reverse];
//id seq0 = [Sequence actions:[DelayTime actionWithDuration:1.5f], move_title_ease_in, nil];
id seq1 = [Sequence actions: move_ease, move_ease_back, nil];
//id seq1 = [Sequence actions: [DelayTime actionWithDuration:2.0f], [CallFuncN actionWithTarget: self selector:@selector(hbarRepeat:)], nil];
id seq2 = [Sequence actions: [DelayTime actionWithDuration:0.05f], [CallFuncN actionWithTarget: self selector:@selector(hbarRepeat:)], nil];
id seq3 = [Sequence actions: [DelayTime actionWithDuration:0.10f], [CallFuncN actionWithTarget: self selector:@selector(hbarRepeat:)], nil];
id seq4 = [Sequence actions: [DelayTime actionWithDuration:0.15f], [CallFuncN actionWithTarget: self selector:@selector(hbarRepeat:)], nil];
id seq5 = [Sequence actions: [DelayTime actionWithDuration:0.20f], [CallFuncN actionWithTarget: self selector:@selector(hbarRepeat:)], nil];
id seq6 = [Sequence actions: [DelayTime actionWithDuration:0.25f], [CallFuncN actionWithTarget: self selector:@selector(hbarRepeat:)], nil];
id seq7 = [Sequence actions: [DelayTime actionWithDuration:0.30f], [CallFuncN actionWithTarget: self selector:@selector(hbarRepeat:)], nil];
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"Phenomena_Enigma.mp3"];
//[title runAction: seq0];
[hbar1 runAction: [RepeatForever actionWithAction:seq1]];
[hbar2 runAction: seq2];
[hbar3 runAction: seq3];
[hbar4 runAction: seq4];
[hbar5 runAction: seq5];
[hbar6 runAction: seq6];
[hbar7 runAction: seq7];
}
-(void)hbarRepeat:(id)sender
{
id move2 = [MoveBy actionWithDuration:0.5f position:ccp(0,200)];
//id move_back = [move reverse];
id move_ease2 = [EaseSineInOut actionWithAction:[[move2 copy] autorelease]];
id move_ease_back2 = [move_ease2 reverse];
RepeatForever *repeat = [RepeatForever actionWithAction:[Sequence actions: move_ease2, move_ease_back2, nil]];
[sender runAction:repeat];
}
That's my adaptation of the example method SpriteEaseSineInOut that has a number of horizontal bars (sprites loaded from images) moving up and down the screen on a sine path. Things start out pretty well and evenly spaced...
http://blakespot.com/images/bars_1.PNG
But after a few seconds, the spacing becomes quite uneven as the bars drift closer / farther apart during the overall animation...
http://blakespot.com/images/bars_2.PNG
Eventually, I end up with a few bars, with others hiding behind them, moving in sync with them.
Is there a better way to time this than with a delay? Could the calls made in the code take too long for the timing to work? That seems hard to believe. This happens both on the simulator and on my iPhone 3GS.
Thanks for any help.