CallFunc Action 允許你可以在一個action裡面調用一個方法。在序列action裡面的最後一個調用,會非常有用。
Example:
id actionTo = [MoveTo actionWithDuration: 2 position:ccp(s.width-40, s.height-40)];
id actionBy = [MoveBy actionWithDuration:2 position: ccp(80,80)];
id actionCallFunc = [CallFunc actionWithTarget:self selector:@selector(doATask)];
id actionSequence = [Sequence actions: actionTo, actionBy, actionCallFunc, nil];
-(void) doATask
{
//some code
}
CallFuncN and CallFuncND Actions
有兩種類型的CallFunc,分別是CallFuncN和CallFuncND
CallFuncN 把node當作參數。
CallFuncND 需要node和一個指向某個數據的指針。
Example:
id actionCallFuncN = [CallFuncN actionWithTarget:self selector:@selector(doATaskN:)];
// make sure you notice the trailing :
id actionCallFuncND = [CallFuncND actionWithTarget:self selector:@selector(doATaskN:data:)
data:pointerToSomeData];
- (void) doATaskN: (id)node
{
//some code
}
- (void) doATaskND: (id)node data:(void*)d
{
//some code
}
出處:http://alexliu.cnblogs.com/