Actions
重複動作
//讓一個節點無限旋轉的例子
CCRotateBy *rotateBy = [CCRotateBy actionwithDuration:2 angle:360];
CCRepeatForever *repeat = [CCRepeatForever actionWithAction:rotateBy];
[myNode runAction:repeat];
動作序列
CCSequece *sequece = [CCSequece actions:act1,act2,nil];
[myNode runAction:sequece];
即時動作 (Place/Hide/Show/Toggle)
動作序列中,動作完成之後發送通知
CCCallFunc *func = [CCCallFunc actionWithTarget:self selector:@selector
(onCallFunc)];
CCCallFunc *funcND = [CCCallFunc actionWithTarget:self selector:@selector
(onCallFuncND:data:)];
CCSequece *sequece = [CCSequece actions:act1,func,act2,funcND,nil];
舒緩動作
XxxxTo :運動到指定位置
XXXXBy:運動到按指定x,y增量的位置
//移動過程中減速
CCMoveTo *move = [CCMoveTo actionWithDuration:3 position:CGPointMake
(100,200)];
CCEaseInOut *ease = [CCEaseInOut actionWithAction:move rate:4];
[myNode runAction:ease];
Reverse反動作
id act2 = [act1 reverse];