Background.h
#ifndef _BACKGROUND_H_
#define _BACKGROUND_H_
#include <iostream>
#include "cocos2d.h"
USING_NS_CC;
class Background : public Sprite
{
private:
Size visibleSize = Director::getInstance()->getVisibleSize();
enum Message { up = 1001, left, right, down, stay, sleep, over };
int _front;
public:
Background();
~Background();
virtual bool init();
virtual void update(float dt);
public:
//only front "up"or"down",then dealWithMoveCommand
void moveCommand(int front);
//is next of moveCommand
void dealWithMoveCommand();
static Background* create();
};
#endif
Background.cpp
#include "Background.h"
Background::Background()
{
}
Background::~Background()
{
this->unscheduleUpdate();//析构时停止该类的update更新。
}
bool Background::init()
{
Sprite::init();
//add updating background map
Size backSize &#