2011-10-18 12 views

答えて

0

最後の2行には何が必要です。

CCMoveBy* move = [CCMoveBy actionWithDuration:3 position:ccp(75,0)]; 
CCCallFuncO* shot = [CCCallFuncO actionWithTarget:self selector:@selector(shoot:) object:enemy]; 
CCSequence* sequ = [CCSequence actions:move,shot,nil]; 
CCRepeatForever* repeat = [CCRepeatForever actionWithAction:sequ]; 
[sprite runAction:repeat]; //sprite here 
+0

これはうまくいきません。例を挙げてみましょう。アクションが2つしかないとします。 1.ディレイ・アクション(私が欲しいシーンのディレイを開始するため)2.ジャンプ・アクション(ディレイ・タイムが終わったら繰り返したい)。私があなたのアプローチで行くなら、遅れも繰り返されます。 :)私たちは別の解決策を考える必要があります。 –

+0

@Gabe無限ループでゲームがフリーズする – Lukman

+0

@paras mendiratta私のアドバイスは、アクションを使用しないで、ccTime関数内のx座標とy座標を更新するだけです。 – Gabe

1

メソッド内で繰り返すアクションを挿入します。次に、あなたのinitメソッド

[[CCScheduler sharedScheduler] scheduleSelector:@selector(myMethod) forTarget:self interval:10 paused:NO]; 

でこれを置くしかし、これは一度MyMethodは内部のあなたがそれのスケジュールを解除したいと思う、10秒後にmymethodを呼び出します。だから私の方法は、このようなものに見えるはずです。

- (void) myMethod 
{ 
    [[CCScheduler sharedScheduler] unscheduleSelector:@selector(myMethod) forTarget:self]; 
    CCMoveBy *move = [CCMoveBy actionWithDuration:3 position:ccp(75,0)]; 
    CCRepeatForever *repeat = [CCRepeatForever actionWithAction:move]; 
    [mySprite runAction:repeat]; 
} 
関連する問題