Cocos2d-x Step by Step (3) Doub le kill simple little animations

Source: Internet
Author: User

In touch for more than two years, but achieved their own intentions and purposes.

Currently engaged in cocos2d changes and tuning migration work.

1 Simple one picture zoom in and zoom out

Auto Sprite = sprite::create ("langren1.png");

A sprite sprite is defined here, and the picture is random.

The scale function is scaled or enlarged in the cocos2d.

    ccactioninterval*  ACTIONTo = ccscaleto::create (20.2f);    Sprite->runaction (ACTIONTo);

We can define a ccactioninterval,2 second, change to 0.2.

Speaking of Ccactioninterval, this is a continuous animation, similar to the animation of WPF, which defines many animated lists, such as:

Ccmoveto: Move To, Ccmoveby: Press ... Move Ccjumpto: Jump To, Ccjumpby: Press ... Jump Ccbezierto: Bézier move To, Ccbezierby: Press ... Bézier move Ccrotateto: Rotate to, Ccrotateby: Press ... Rotate Ccscaleto: Zoom to, Ccscaleby: Press ... Zoom Ccskewto: Shear To, Ccskewby: Press ... Shear Cctintto: Color gradient to, Cctintby: Press ... Color gradient Ccfadein: From scratch, also called fade-in, ccfadeout: From there to nothing, also known as fade, Ccfadeto: Change the opacity to a value ccblink: Sparkle Ccdelaytime: Delay These are simple definitions, very easy 2 continuous changes, has been zooming in and out of the change cocos2d there's this thing in there.

Ccsequence

This is a queue,

Ccsequence.create (This is where ccactioninterval,ccactioninterval can pass in multiple,...., null) can pass in n ccactioninterval and then loop in the timeline to play

Of course, this is only executed once, if you want to do the loop, then it has a

Ccrepeatforever::create (ccsequence), the Ccsequence list as a parameter in the period, and then can continue to do the loop

Oh, and finally to say, Sprite object, after creation, you can do their own adjustment, initialization of the adjustment, such as Setscale setrotation adjust the zoom rotation, it has some of this parameter, it is quite convenient, and finally attached a simple code:

Auto Sprite = Sprite::create ("Langren1.png"); Sprite->setscale (0.5f,0.5f); Sprite->setrotation ( -); //position the sprite on the center of theSprite->setposition (VEC2 (Visiblesize/2) +origin); //Add the sprite as a child to this layer     This-AddChild (Sprite); //ccactioninterval* ACTIONTo = ccmoveto::create (2, CCP (0, 0));ccactioninterval* ACTIONTo = Ccscaleto::create (2,0.2f) ; Sprite-runaction (ACTIONTo); //ccactioninterval* scaleAction1 = ccscaleto::create (2, 0.2f, 0.2f); //ccactioninterval* scaleAction2 = ccscaleto::create (2, 0.5f, 0.5f); //ccactioninterval* seq = (ccactioninterval*) (Ccsequence::create (ScaleAction1, ScaleAction2, NULL)); //sprite->runaction (ccrepeatforever::create (seq)); //sprite->runaction (Ccrepeatforever::create (Ccsequence::create (Ccfadein::create (2), CCFadeOut::create (2), NULL ));

Lunch today, heard a bunch of wear suits, should be engaged in real estate, in the discussion Tfboy song, the first push youth practice manual.

Fine.

Cocos2d-x Step by Step (3) Doub le kill simple little animations

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.