Special actions has three parts: function, lens tracking, and attribute control (this is my personal name ). I will add content slowly Based on my personal experience. If I have never used it, I will not write it first. Function section: Cccallfunc Cccalfunc is used to call methods in ccsequence. For example, if you need to call a method to implement a logic computing after a sprite has made some column animations, you need this stuff. The following is an example. id actionTo = [CCMoveTo actionWithDuration: 2 position: ccp(160, 240)];id actionCallFunc = [CCCallFunc actionWithTarget:self selector:@selector(doATask)]; id actionSequence = [CCSequence actions: actionTo, actionCallFunc, nil];[sprite runAtion:actionSequence]; -(void) doATask{ //some code} Sprite first moves to the coordinate (160,240) and then calls the doatask method.
Let's talk about the cccalfunc parameter. actionwithtarget specifies the object when you want to call the method. This parameter is not only self, but can be any object. When the parameter is self, it means to call the method of the current object.
Selector refers to the signature of the method (I will call it this way). The format is @ selector (method name). Here, doatask is the bottom part of the code. Ccactiontween If you need to change the attributes of a genie, but the current action class does not provide the corresponding functions, you can use this ccpropertyaction (the original ccpropertyaction) to pin it. The Code is as follows: id rot = [CCActionTween actionWithDuration:2 key:@"rotation" from:0 to:-270];[sprite runAction:rot]; I have never used this method for the moment, but it is relatively simple. Actionwithduration is the action time, and key is the name of the attribute to be changed. from and to specify the range of attribute value changes. |