cocos2d-x实现飞字效果
实现了三种飘字效果,可以在暴击时加一些特效和中文字“暴击”
//
// LQFlyNumber.h
//
#ifndef __LQFlyNumber_H__
#define __LQFlyNumber_H__
#include "cocos2d.h"
using namespace cocos2d;
//定义飘字类型
typedef enum{
klq_flaytype_normal=0, //正常
klq_flaytype_break =1, //暴击 放大字体,红色
klq_flaytype_resolve=2, //分解 缩小字体,黄色
klq_flaytype_other=3 //???
} LQFlyNumberTypeEnum;
/*
示例1:
LQFlyNumber* fly = LQFlyNumber::create("111");
fly->setPosition(ccpSize(this->getContentSize(),0.5));
addChild(fly);
fly->startAnimation();
示例2:
LQFlyNumber* fly = LQFlyNumber::create(value,true);
fly->setPosition(ccpSize(this->getContentSize(),0.5));
fly->setNumberType(klq_flaytype_break);
addChild(fly);
*/
class LQFlyNumber : public CCSprite
{
private:
const char* m_curValueStr; //当前串值
CCLabelBMFont *m_label;
public:
static LQFlyNumber* create(int num, bool isSign); //数字 带符号
static LQFlyNumber* create(const char* str);
LQFlyNumber();
~LQFlyNumber();
bool initWithString(const char* str);
void startAnimation();
void removeObject();
void setCurValueStr(const char* curValue);
void d