最近做项目使用到了抽奖功能,于是把抽奖模块独立出来了,以便重复利用,资源来自http://www.cnblogs.com/zisou/p/cocos2d-xZhuanpan.html。下面直接上代码:
#ifndef __Wheel__CWheelLayer__
#define __Wheel__CWheelLayer__
#include <stdio.h>
#include "cocos2d.h"
#include "../cocos2d/cocos/editor-support/cocostudio/CocoStudio.h"
#include "../cocos2d/cocos/ui/CocosGUI.h"
using namespace cocostudio;
using namespace ui;
USING_NS_CC;
class CWheelLayer:public Layer
{
public:
CWheelLayer();
~CWheelLayer();
bool init();
CREATE_FUNC(CWheelLayer);
static Scene* createScene();
void update(float dt);
private:
Sprite *_wheel;
//转盘状态0静止,1加速,2减速
int _state;
float _speed;
float _speedAcc;
//目标 设置index即为结果
int _index;
float _targetRo;
//控制音效
int _soundCount1;
int</