现在我们运用我们已经学过的知识实现一个类来完成游戏中主角或者障碍物受到攻击时闪烁提示信息。
没有就新的东西,所以菜鸟们都可以看懂的,另外我还要特意强调一下,小的方面游戏需要创新,游戏开发中的效果需要创新,创新不是多么的难,运用简单的知识就能创新就像我们的这个类。
废话说多了,直接看代码吧:
class FlowWord : public CCNode {
public:
static FlowWord* create();
bool init();
public:
void showWord(const char* text, CCPoint pos);
private:
CCLabelTTF* m_textLab;
void flowEnd();
};
FlowWord* FlowWord::create() {
FlowWord* flowWord = new FlowWord();
if(flowWord && flowWord->init()) {
flowWord->autorelease();
}
else {
CC_SAFE_DELETE(flowWord);
}
return flowWord;
}
bool FlowWord::init() {
m_textLab = CCLabelTTF::create("", "Arial", 35);
m_textLab->setColor(ccc3(255, 0, 0));
m_textLab->setAnchorPoint(ccp(1, 0));
m_textLab->setVisible(false);
this->addChild(m_textLab);
return true;
}
void FlowWord::showWord( const char* text, CCPoint pos ) {
m_t