在上面的例子中你提到過,有些方法要執行動畫完成時會執行三次。在循環後一次使用它。 'yourAnimationDuration'將是最長持續時間的動作時間,因爲所有其他動作必須在持續時間最長的動作之前結束。
'CCSequence'是一個不錯的選擇,但您只需要使用持續時間最長的操作而不是所有對象來執行CCSequence。
所以在第一種情況下
int yourAnimationDuration; //this needs to be set to duration of action with maximum time
for(int idx = 0; idx < 3; idx++) {
[[objArray objectAtIndex:idx] runAction:[actArray objectAtIndex:idx]];
}
[self performSelector:@selector(someMethodToBeExecutedWhenAnimationFinishes) withObject:nil afterDelay:yourAnimationDuration];
在第二個案例,如果您的第二個動作發生的最大時間 假設。
int actionNum = 2;
for(int idx = 0; idx < 3; idx++) {
if(idx == (actionNum-1))
{
[[objArray objectAtIndex:idx] runAction:[CCSequence actions:[actArray objectAtIndex:idx],[CCCallFuncN actionWithTarget:self selector:@selector(someMethodToBeExecutedWhenAnimationFinishes:)],nil];
}
else{
[[objArray objectAtIndex:idx] runAction:[actArray objectAtIndex:idx]];
}
}
希望有所幫助。我沒有運行這個代碼。因此,檢查是否有語法。 :)
是你想要在obj1上調用動作2的錯字嗎?那應該是行動1? – 2012-02-07 02:12:56
對不起,這是一個錯字。 – SpaceDog 2012-02-07 02:19:37