2011-10-18 30 views

回答

0

最後兩行是你所需要的。

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

@加貝無限循環將凍結遊戲 – Lukman

+0

@paras mendiratta我的建議,不要使用行動只是更新ccTime函數內的x和y座標。 – Gabe

1

把你想要在一個方法中重複的動作。然後裏面myMethod的把這個在您的init方法

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

這將在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]; 
} 
相關問題