Create a wizard (basic summary) "7 Properties"

Source: Internet
Author: User

First, you need to learn to create sprites:

1 Auto mySprite = sprite::create ("mysprite.png"); 2 Auto mySprite = sprite::create ("mysprite.png", Rect (0,0, (a));

Then change their properties ( seven basic attributes ):

① Anchor Point (important)
1Mysprite->setanchorpoint (0.5,0.5);//All wizard default anchor points2Mysprite->setanchorpoint (0,0);//Lower left corner3Mysprite->setanchorpoint (0,1);//Upper left corner4Mysprite->setanchorpoint (1,0);//Lower right corner5Mysprite->setanchorpoint (1,1);//Upper Right Corner
② position (Position)
// let elf to coordinates (100,200)mysprite->setposition (Vec2);
③ Angle (Rotation)

Clockwise is +, counterclockwise is-

1 mysprite->setrotation (20.0f//  20 degrees clockwise 2 mysprite-> Setrotation (-20.0f); // rotate counterclockwise 20 degrees 3 mysprite->setrotation (60.0f//  60 degrees clockwise 4 mysprite-> Setrotation (-60.0f); // rotate counterclockwise 60 degrees
④ Scaling (Scale)
1 mysprite->setscale (2.0);  // twice times the percentage increase 2 Mysprite->setscalex (2.0); // X-axis increased by twice times 3 Mysprite->setscaley (2.0); // twice x increase in Y axis
⑤ Tilt (Skew)
1 // x-axis tilt 20 degrees 2 mysprite->setskewx (20.0f); 3 // Y-axis tilt 20  degrees 4 mysprite->setskewy (20.0f);
Sprite properties not affected by anchors: color, transparency ⑥ color
1 // set the color to go through the Color3b object 2 Mysprite->setcolor (color3b (255255255)); 3 // can also be set using the default color of the Color3b object 4 Mysprite->setcolor (color3b::white);
⑦ Transparency
// changes the sprite's transparency by a specific value. The value range is (2~255), the default value is 255 (opaque)mysprite->seropacity (();

Reference: http://cn.cocos2d-x.org/tutorial/show?id=1989

Create a wizard (basic summary) "7 Properties"

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.