COCOS2DX 3.x (move to modify sprite coordinates moveto and Moveby)

Source: Internet
Author: User
Tags addchild

1 //2 //MainScene.cpp3 //HelloWorld4 //5 //Created by Apple on 16/11/8.6 //7 //8 9#include"mainscene.hpp"TenScene *Mainscene::createscene () One { AAuto scene = Scene::create ();//Creating Layers -Mainscene *layer =mainscene::create (); -Scene->addChild (layer); the     returnscene; - } - BOOLMainscene::init () { -     if(!Layer::init ()) { +         return false; -     } +      A      at //MoveTo: Moving a Sprite to a certain location - //Moveby: Move a sprite a distance, it has a method reverse, it lets the object return by the original path -      -      -     /* - * @MoveTo, move to a point in      */ -Size size = Director::getinstance ()getwinsize (); toSprite *spritemoveto = Sprite::create ("Snow.png"); +Spritemoveto->setposition (VEC2 (Size.width/2.0f, Size.Height/2.0f)); -      This->addchild (Spritemoveto,1); the      *Actioninterval *forward = Moveto::create (4, VEC2 ( -, -)); $Spritemoveto->Runaction (forward);Panax Notoginseng      -      the     /* + *moveby, move some distance. A      */ theSprite *spritemoveby = Sprite::create ("Snow.png"); +Spritemoveby->setposition (VEC2 (Size.width/4.0f, Size.Height/4.0f)); -      This->addchild (Spritemoveby,1); $      $Actioninterval *forwardby = Moveby::create (2, VEC2 ( $, -)); -Actioninterval *backby = forwardby->reverse (); -Action *action = repeat::create (dynamic_cast<finitetimeaction *> (Sequence::create (Forwardby, BackBy, NULL)),4); theSpritemoveby->runaction (action); -     Wuyi      the      -     return true; Wu}

COCOS2DX 3.x (move to modify sprite coordinates moveto and Moveby)

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.