Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include "Touch_and_Move.h"
  2.  
  3. Scene* TouchMove::createScene()
  4. {
  5.     auto scene = Scene::create();
  6.     auto layer = TouchMove::create();
  7.     scene->addChild(layer);
  8.     return scene;
  9. }
  10.  
  11. bool TouchMove::init()
  12. {
  13.     if(!Layer::init())
  14.     {
  15.         return false;
  16.     }
  17.     this-> background = Sprite::create("BG-HD.png");
  18.     this-> background-> setPosition(TouchMove::screen().width/2, TouchMove::screen().height/2);
  19.     this-> addChild(background, -1);
  20.  
  21.     this-> cloud = Sprite::create("Cloud-HD.png");
  22.     this-> cloud->setPosition(100, 600);
  23.     this-> addChild(cloud, 10);
  24.  
  25.     //this->schedule(schedule_selector(TouchMove::update),.01);
  26.     this-> scheduleUpdate();
  27.     return true;
  28. }
  29.  
  30. void TouchMove::update(float dt)
  31. {
  32.     auto scroll = Point(-1,0);
  33.     CCLOG("%f", cloud-> getPositionX());
  34.     if (cloud-> getPositionX() < 0){
  35.         cloud-> setPositionX(TouchMove::screen().width);
  36.     }
  37.     cloud-> setPositionX(cloud-> getPositionX()+scroll.x);
  38. }