2012-05-10 7 views
0

私は自分のGameLayerでいくつかの関数を使用しようとしています。まず、GameLayerクラスの別のクラスから2番目のクラスですが、CCSequenceはシーケンスではなくCCSpawnのように動作します。これとは別に、両方ともGameLayerで完璧に動作します。 GameLayerCCSpawnのようなCCSequenceは異なるクラスの関数を使用します

[self runAction:[CCSequence actions: 
        [CCCallFuncN actionWithTarget:self.rolypoly selector:@selector(jumpToDeath:)], 
        [CCCallFuncND actionWithTarget:self selector:@selector(goToGameOverLayer:tagName:)data:(int)TagGameOverLose],  
        nil]]; 
rolypolyクラス

-(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]]; 


} 

答えて

1

問題がrunActionブロッキング方法ではないということです。つまり、関数呼び出しアクション(CCCallFuncなど)を使用すると、シーケンス内のアクションは、関数呼び出しが戻るときに実行されます。あなたの場合、jumpToDeathはアクションを実行しますが、完了するのを待つことはなく、メインシーケンスの2番目のアクションが実行されます(jumpToDeathのシーケンスが完了する前)。

アクションを再配置してみてください。もっと助けが必要なら私に知らせてください。

EDIT:私の提案:あなたは、私は他のすべてのアクションが行われた後、それが最後に実行される保証jumpToDeath方法の最後であることを最後のコール機能のアクションを動かす見ることができるように

[self runAction:[CCSequence actions: 
        [CCCallFuncN actionWithTarget:self.rolypoly selector:@selector(jumpToDeath:)], nil]]; 

-(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)], 
           [CCCallFuncND actionWithTarget:self selector:@selector(goToGameOverLayer:tagName:)data:(int)TagGameOverLose], 
           nil]]; 
} 

それはそれは大丈夫だろうよりもアクションが含まれていない場合、私はそれ以外の場合は、その実装を表示したり、同じ

+0

をやってみてください、moveSpriteDeathの実装であるのか分からないが、あなたは、あなたがこの問題を解決するために私を得ることができますか? –

+0

私がこのケースでアドバイスできるのは、[CCDelayTime actionWithDuration:3]、アクションの間です –

+0

私の解決策を見てくださいあなたに役立つかどうかを確認してください – giorashc