在开发游戏中,我们需要在需要在游戏中显示一个字体轮廓比较清晰的效果,我们就需要给字体的周围进行描边,让字体显示比较更加突出,我重写了cclabelttf类,使它具有描边的特效,和描边的大小以及颜色。。。
开发人员:Jason's.Alex QQ:531401335
csdn博客:http://blog.csdn.net/RuShrooM
@H_404_20@
[cpp]
view plain
copy
- #include"cocos2d.h"
- usingnamespacecocos2d;
- classStrokeLabelTTF:publiccocos2d::CCNode
- {
- public:
- StrokeLabelTTF();
- ~StrokeLabelTTF();
- public:
- staticStrokeLabelTTF*create(constchar*string,constchar*fontName,floatfontSize,floatstrokeSize,constcocos2d::ccColor3B&colStroke=cocos2d::ccc3(0,0),cocos2d::CCTextAlignmenthAlignment=cocos2d::kCCTextAlignmentCenter,cocos2d::CCVerticalTextAlignmentvAlignment=cocos2d::kCCVerticalTextAlignmentTop);
- boolinitWithString(constchar*label,floatfStrokeSize,constcocos2d::ccColor3B&colStroke,cocos2d::CCTextAlignmenthAlignment,cocos2d::CCVerticalTextAlignmentvAlignment);
- staticStrokeLabelTTF*create(constchar*string,floatfontSize);
- public:
- voidsetColor(constcocos2d::ccColor3B&color3);
- voidsetString(constchar*label);
- voidsetStrokeColor(cocos2d::ccColor3Bcol){m_colStroke=col;updateStroke();}
- voidsetStrokeSize(floatStrokeSize){m_fStrokeSize=StrokeSize;updateStroke();}
- voidsetAnchorPoint(constcocos2d::CCPoint&anchorPoint);
- protected:
- voidupdateStroke();
- private:
- floatm_fStrokeSize;
- cocos2d::ccColor3Bm_colStroke;
- cocos2d::CCSprite*m_sprite;
- cocos2d::CCLabelTTF*m_label;
- CCPointanchorPoint;
- };