Roope's Cocos2d-x Learning Journey 002: A simple exercise

Source: Internet
Author: User
Tags addchild

I just don ' t want to regret it:
1.   where you want to go, how far you want to go--moveto and Moveby:            MoveTo (where do you want to go) its function is from one place to another, such as a (x1, y1), B (x2, y2 when we want to move the genie from a to point B, we can use MoveTo (a MoveTo B, that's how it's understood). Moveby (How far you want to go) its role is a movement B that's so far away. That is to arrive at C (x1 + x2, y1 + y2); (A add B, so understand ~) the specific implementation is as follows:           
Intercept screen size              visiblesize = director::getinstance ()->getvisiblesize ();               Define an elf                sprite* roope = sprite::create ("Sprite.png");                Roope->setposition (Point (VISIBLESIZE.HEIGHT/2));//Position Placement                this->addchild (roope);               Where do you want to go              //moveto* MoveTo = moveto::create (0.9f, point (.));              Roope->runaction (moveTo);            How far do you want to go               moveby* moveby = moveby::create (0.9f, point (+));               Roope->runaction (Moveby);

2 .   I want to lose weight--scaleto and Scaleby: first of all, the Scaleto,scaleto create has three parameters:
Float Duration: The duration of the action, in seconds.
The stretch value of float sx:x direction.
The stretch value of float sy:y direction.
Examples include:
        Size visiblesize = director::getinstance ()->getvisiblesize ();         sprite* Roope = sprite::create ("Sprite.png");         Roope->setposition (Point (VISIBLESIZE.WIDTH/2, VISIBLESIZE.HEIGHT/2));         AddChild (Roope);         scaleto* Scaleto = scaleto::create (5.5f, 0.4f, 1.0f);         Roope->runaction (Scaleto);



then the Scaleby,scaleby create parameter is the same as the Scaleto.
scaleby::create (2.8f, 0.4f, 1.0f );
here are the differences between Scaleto and Scaleby. The effect of Scaleto is that it scales the sprite to a specified number of multiples regardless of the current stretch multiplier of the sprite. The effect of Scaleby is to stretch again on the basis of the current multiplier of the sprite.
such as:        
Size visiblesize = director::getinstance ()->getvisiblesize ();        sprite* roope1 = sprite::create ("Sprite.png");        Roope1->setposition (Point (VISIBLESIZE.HEIGHT/2));        Roope1->setscale (2.0f);//Stretching elf        addChild (roope1);        sprite* roope2 = sprite::create ("Sprite.png");        Roope2->setposition (Point (VISIBLESIZE.HEIGHT/2));        Roope2->setscale (2.0f);//Stretching elf        addChild (roope2);        scaleto* Scaleto = scaleto::create (3.0f, 1.0f, 1.0f);        scaleby* Scaleby = scaleby::create (3.0f, 2.0f, 1.0f);        Roope1->runaction (Scaleto);        Roope2->runaction (Scaleby);

Here you can see the great difference between the two.
3 .   Flash debut--blink:          blink can be sprite flashing, and you can specify the number of flashes, using a class similar to MoveTo. Its create function has two parameters.           Float Duration: The duration of the action, in seconds.           float Ublink: number of flashes.                            examples include:    
Size visiblesize = director::getinstance ()->getvisiblesize ();    sprite* Roope = sprite::create ("Sprite.png");    Roope->setposition (Point (VISIBLESIZE.WIDTH/2, VISIBLESIZE.HEIGHT/2));    AddChild (Roope);    blink* Blink = Blink::create (5.0f, ten);    Roope->runaction (Blink);

Roope's Cocos2d-x Learning Journey 002: Simple exercise

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.