Cocos2d-x project 101 encounter: Add a sprite

Source: Internet
Author: User

  • Cocos2d-x 101 encounter/directory
    1. Installation and environment setup-xcode
    2 Scenes, Director, Layers, Sprites
    3. Create an image menu
    4. Create a new scenario on HelloWorld
    5. Add a sprite.
    5.1 scale down sprite and display it completely
    6 action, mobile sprite
    3.0 Click Event, CCTouchDelegate has been disabled
    8 use the touch event mobile genie

5. Add a sprite.

In the second scenario, the bool CMyFirstScene: init () function is added at the end.

 
  1. auto s =Sprite::create("19300001150142129966113771140.jpg");

  2. this->addChild(s,1);

  3. // do something

  4. returntrue;

19300001150142129966113771140. jpg

Is a rabbit image, you must add the file to the project. (Add files to "project" in xcode ")

What Is Genie? Is it dynamic, animal? Airplane? Device (gun, bullet )? Enemies: obstacles, walls, bricks ?, Mine ,? Traps.

5.1 scale down sprite and display it completely

 
  1. auto s =Sprite::create("19300001150142129966113771140.jpg");

  2. CCSize size=CCDirector::sharedDirector()->getWinSize();

  3.    s->setPosition(ccp(size.width/2,size.height/2));

  4.    s->setScale(0.3,0.3);

  5. this->addChild(s,1);

  6. // do something

  7. returntrue;

  8. }


Related Article

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.