Conclusion 4 of common cocos2d Actions and effects: Special Actions

Source: Internet
Author: User
Conclusion 4 of common cocos2d actions and effects: special actions The following text is reproduced from: http://hi.baidu.com/flwblog/blog/item/d57ca61cb77fdb9686d6b620.html, thanks to the original author.

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.