出处:Himi http://www.himigame.com 对于想学移动游戏开发的同仁强烈推荐!!!
虚拟摇杆类起名为:HRocker
下面是 HRocker.h 文件:
#include <iostream>
#include "cocos2d.h"
using namespace cocos2d;
//枚举型:用于标识摇杆与摇杆的背景
typedef enum{
tag_rocker,
tag_rockerBG,
}tagForHRocker;
class HRocker : public CCLayer
{
public:
//创建摇杆,摇杆图片,摇杆背景图片,起始坐标
static HRocker* createHRocker(const char* rockerImageName, const char* rockerBGImageName, CCPoint position);
//启动摇杆
void startRocker(bool _isStopOther);
//停止摇杆
void stopRocker();
private:
void rockerInit(const char* rockerImageName, const char* rockerBGImageNa