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)