Cocos2d-x 3.1.1 Study notes [3]action Action

Source: Internet
Author: User


These animations appear to be very many, all created once.

The code is as follows:


/* Animation */Auto SP = sprite::create ("card_bg_big_26.jpg");    Size size = Director::getinstance ()->getwinsize ();    Sp->setscale (0.2);    Sp->setposition (VEC2 (SIZE.WIDTH/2 + SIZE.HEIGHT/2 + 200));    Sp->setanchorpoint (VEC2 (0.5, 0.5));        AddChild (SP);     /* * General functions will have Xxxto and Xxxby two methods. The by method generally works the same as the To method. Only by method can get the reverse action of this method.

E.g:moveby->reverse (); * Duration inside the animation is the time to run the animation * * */** * moveto::create (float duration, const COCOS2D::VEC2 &position); * Position: The location to move to */Auto A1 = Moveto::create (2, VEC2 (100, 100));//move to the specified coordinates within the stipulated time/** * jumpt O::create (float duration, const cocos2d::vec2 &position, float height, int jumps); * Position: To jump to the position * Height: the height of each jump * Jumps: The number of hops to jump */Auto a2= jumpto::create (3, Vec2 (0, 0), 30, 6);//Jump 6 After jumping to the specified coordinates/** * Two seconds to zoom in to 1 * scaleto::create (float duration, float s) * s: Multiples to zoom */Auto A3 = S Caleto::create (2, 1); /** * fade in. The change is the value of the Opacity property. 0 (Invisible)-100 (see ALL) * Fadein::create (float d) * d: Fade in time */auto a4 = fadein::create (2); /** * Fade out, change the value of opacity this property.

0 (Invisible)-100 (see ALL) * Fadeout::create (float d) * d: Fade out time */auto A5 = fadeout::create (2);//2 seconds fade out /** * Cardinalsplineto is like running multiple moveto functions * cardinalsplineto::create (float duration, cocos2d::P ointarray *points, FL Oat tension) * points: Need to pass the point * tension: tension (tension will have a back force) */pointarray* arr = pointarray::create (20); Arr->addcontrolpoint (Vec2 (0, 0)); Arr->addcontrolpoint (VEC2 (600, 700)); Arr->addcontrolpoint (VEC2 (200,200)); Arr->addcontrolpoint (VEC2 (55, 55)); Auto A6 = cardinalsplineto::create (5, arr, 20);//equivalent to multiple moveto,20 is tension. If the tension is large, there will be back force. /** * Rotate an elf's angle * rotateto::create (float duration, float deltaangle) * Deltaangel: Clockwise angle required to rotate */Auto A 7 = Rotateto::create (2, 50); /** * Tilt an elf's * Skewto::create (float T, float sx, float sy); * Sx:x Axis Tilt angle * Sy:y axis tilt angle */Auto A8 = Skewto::create (3, 20, 1); /** * Bézier Curve Motion * bezierto::create (float t, const ccbezierConfig &c) * C: Bessel parameters */Ccbezierconfig Beziercon; beziercon.controlpoint_1 = VEC2 (100, 100); Beziercon.controlpoint_2 = VEC2 (200, 200); Beziercon.endposition = VEC2 (300, 600); Auto A9 = bezierto::create (5, Beziercon); /** * Color change action, color composition for (0-255), set (255,255. 255) for original painting * Tintby::create (float duration, glshort deltared, Glshort deltagreen, Glshort deltablue) * deltared: Red ingredient * Deltagreen: Green ingredient * Deltablue: Blue ingredient */Auto A10 = tintby::create (1, 155, 155, 155); /** * Let an elf blink several times within the specified time * blink::create (float duration, int blinks) * Blinks: Number of flashes */Auto A11 = Blink: : Create (1, 5); /** * Delayed for five seconds, generally used for animation continuous broadcast time, rest for five seconds. Plays the next animation. * Delaytime::create (float d) * d: Time required for delay */Auto A12 = Delaytime::create (5); /** * Create a spherical coordinate trajectory to rotate the action * orbitcamera::create (float t, float radius, float deltaradius, float anglez, float deltaa Nglez, float AngleX, float deltaanglex) * radius: Starting RADIUS * Deltaradius: Radius difference * Angelz: start z angle * Deltaanglez: rotation z Angle difference * AngleX: start x Angle * Deltaanglex: rotation x Angle Difference */Auto A13 = Orbitcamera::create (5, 10, 0, 45, 180, 90, 0); /** * Create a trailing action * follow::create (Cocos2d::node *followednode) * Followednode: Nodes that need to be tailed */auto A14 = Foll Ow::create (SP); /** * Allows the target action to give the bounce force, will rebound during the target action, the end point does not bounce. * Easebouncein::create (Cocos2d::actioninterval *action) * Action: Target action */Auto A15 = easebouncein::create (A1); /** * Allows the target action to give a rebound force. And start bouncing off the seat with the target action. (This effect is more like a bounce force than in) * Easebounceout::create (Cocos2d::actioninterval *action) * Action: Target action */auto A16 = Eas Ebounceout::create (A1); /** * Allows the target action to give a bounce, combined with Easebouncein and Easebounceout, both in the process and at the end of the rally. * Easebounceinout::create (Cocos2d::actioninterval *action) * Action: Target action */auto A17 = easebounceinout::create (A1); /** * Allows the target action to give back force (in the direction opposite to the direction of movement) (before the action starts) * Easebackin::create (cocos2d::actionInterval *action) * Action: Target action */Auto A18 = easebackin::create (A1); /** * Allows the target action to give back force (the direction is the same as the direction to move) (at the end of the action) * Easebackout::create (Cocos2d::actioninterval *action) * Action: Target action */Auto A19 = easebackout::create (A1); /** * Let the target action give back force combined with Easebackin and Easebackout * easebackinout::create (cocos2d::actioninterval *action) * Action: Target Action */Auto A20 = easebackinout::create (A1); /** * Give action elasticity (show during movement) * Easeelasticin::create (cocos2d::actioninterval *action, float period) * Action: Target action * Period: frequency. The frequency of the flex presentation. Period seconds to run the elastic effect */Auto A21 = easeelasticin::create (A1, 0); A21 = easeelasticin::create (A1);//can also not fill period function to create/** * give action elasticity (mobile end display) * Easeelasticout::create (cocos2d::a Ctioninterval *action, float period) * Action: Target action * period: Frequency, elastic display frequency, period second run elastic effect */auto A22 = Ease Elasticout::create (A1, 1); A22 = easeelasticout::create (A1);//can also be created without filling out the period function /** * gives motion flexibility in the process and ends when Easeelasticin + easeelasticout * easeelasticinout::create (Cocos2d::actioninterval *act ion, float period) * Action: Target action * period: Frequency, elastic display frequency, period second run elastic effect */auto A23 = Easeelasticinout::crea TE (A1, 1); A23 = easeelasticinout::create (A1);//can also create/** without filling out the period function * Let the target action slow start * Easeexponentialin::create (Cocos 2d::actioninterval *action) * Action: Target action */Auto A24 = easeexponentialin::create (A1); /** * Let target action slow end * Easeexponentialout::create (Cocos2d::actioninterval *action) * Action: Target action */Auto A2 5 = easeexponentialout::create (A1); /** * Let target action slow start and End * Easeexponentialinout::create (Cocos2d::actioninterval *action) * Action: Target action */AU To A26 = easeexponentialinout::create (A1); /** * Make the target action run twice faster * Speed::create (cocos2d::actioninterval *action, float) * Speed: Multiples */Auto A27 = Speed::create (A1, 20); /** * Let multiple animations run at the same time * spawn::create (cocos2d::finitetimeaction *action1, ..., NULL) * Action: Action */Auto A28 = S Pawn::create (A1, a2, NULL); /** * Let multiple animations run sequentially * sequence::create (cocos2d::finitetimeaction *action1, ..., NULL) * Action: Action/Auto A29 = Sequence::create (A1, a2, NULL); /** * Make an animation run multiple times * Repeat::create (cocos2d::finitetimeaction *action, unsigned int time) * Action: Action * Tim ES: Number of repeated actions */auto A30 = Repeat::create (A11, 2); /** * Permanent repetitive movement of the target action * repeatforever::create (Cocos2d::actioninterval *action) * Action: Action */Auto A31 = Repeatforever::create (A11); /* The following 0 1 2 3 in the macro definition of Cc_callback_ is the number of parameters that do not specify a callback function beforehand. For example, Cc_callback_ 1 says. The callback function does not specify a number of parameters in advance, and the parameters of the previously specified callback function can be arbitrarily multiple. */Sp->settag (5201314); Create a non-participating callback function Auto Callfunc = callfunc::create (Cc_callback_0 (Helloworld::noparam, this)); Create a callback function that has only one parameter.

(using the default callback function) Auto CALLFUNCN = Callfuncn::create (Cc_callback_1 (Helloworld::oneparam, this)); Create a callback function that has only one parameter. (Use your own definition) Auto Callfuncnself = Callfuncn::create (Cc_callback_0 (helloworld::oneparambyself, this,998)); Create a callback function with two parameters auto callfuncnd = Callfuncn::create (Cc_callback_1 (Helloworld::twoparam, this, 6)); Sp->runaction (CALLFUNCND);



The function used for the last callback above:

void Helloworld::noparam () {    log ("no param");} void helloworld::oneparambyself (int num) {    log ("One param one is%d", num);} void Helloworld::oneparam (node* node) {    //pass in the movement of the node    log ("One:%d", Node->gettag ());} void Helloworld::twoparam (node* node,int sec) {    log ("SEC:%d", (int) sec);}






Cocos2d-x 3.1.1 Study notes [3]action Action

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.