I try to use a few functions in my GameLayer. First – from another class, second – from GameLayer class, but CCSequence run like CCSpawn, not sequence. Separately they both work perfect in GameLayer.
in GameLayer
[self runAction:[CCSequence actions:
[CCCallFuncN actionWithTarget:self.rolypoly selector:@selector(jumpToDeath:)],
[CCCallFuncND actionWithTarget:self selector:@selector(goToGameOverLayer:tagName:)data:(int)TagGameOverLose],
nil]];
in rolypoly class
-(void)jumpToDeath:(id)sender
{
[self.sprite stopAllActions];
id actionSpaw = [CCSpawn actions:
[CCMoveTo actionWithDuration:0.5f position:ccp(self.sprite.position.x, self.sprite.position.y+self.sprite.contentSize.height)],
[CCBlink actionWithDuration:1.0f blinks:4],
nil];
[self.sprite runAction:[CCSequence actions:
[CCCallFuncND actionWithTarget:self selector:@selector(setJumpingToDeath:withValue:)data:(void*)1],
actionSpaw,
[CCHide action],
[CCCallFunc actionWithTarget:self selector:@selector(moveSpriteDeath)],
nil]];
}
The problems is that the
runActionis not a blocking method. Meaning that when you use a function call action (likeCCCallFunc) the action after it in the sequence will be executed when the function call returns. In your casejumpToDeathruns actions but does not wait for them to be finished and when it returns the second action in your main sequence is executed (before the sequence insidejumpToDeathis finished)Try to rearrange your actions. If you need more help let me know.
EDIT : My suggestion :
As you can see I moved the last call function action to be the last in the
jumpToDeathmethod which insures it will be executed last after all other actions are done.I do not know what is the implementation of
moveSpriteDeathbut if it does not contain actions than it will be ok, otherwise show its implementation or try doing the same