#include "Touch_and_Move.h"
Scene* TouchMove::createScene()
{
auto scene = Scene::create();
auto layer = TouchMove::create();
scene->addChild(layer);
return scene;
}
bool TouchMove::init()
{
if(!Layer::init())
{
return false;
}
this-> background = Sprite::create("BG-HD.png");
this-> background-> setPosition(TouchMove::screen().width/2, TouchMove::screen().height/2);
this-> addChild(background, -1);
this-> cloud = Sprite::create("Cloud-HD.png");
this-> cloud->setPosition(100, 600);
this-> addChild(cloud, 10);
//this->schedule(schedule_selector(TouchMove::update),.01);
this-> scheduleUpdate();
return true;
}
void TouchMove::update(float dt)
{
auto scroll = Point(-1,0);
CCLOG("%f", cloud-> getPositionX());
if (cloud-> getPositionX() < 0){
cloud-> setPositionX(TouchMove::screen().width);
}
cloud-> setPositionX(cloud-> getPositionX()+scroll.x);
}