头文件:
#pragma once
#ifndef _ROLLER_LAYER_H_
#define _ROLLER_LAYER_H_
#include "cocos2d.h"
USING_NS_CC;
class RollerLayer :public Layer
{
public:
static const int VERTICAL = 1;
static const int HORIZONTAL = 2;
CREATE_FUNC(RollerLayer);
virtual bool init();
void update(float dt);
void setBackgrounds(Sprite *map1,Sprite*map2);
void setRollOrientaion(int orientation);
void setSpeed(int iSpeed);
private:
void rollHorizontal();
void rollVertical();
protected :
Sprite *mMap1;
Sprite *mMap2;
int mOrientation;
int mSpeed;
};
#endif
#include "RollerLayer.h"
bool RollerLayer::init() {
if (!Layer::init()) {
return false;
}
mOrientation = VERTICAL;
mMap1=mMap2 = NULL;
mSpeed = 10;
scheduleUpdate();
return true;
}
void RollerLayer::