【cocos2d-x 3.7 飞机大战】 决战南海I (九) 飘字特效

【cocos2d-x 3.7 飞机大战】 决战南海I (九) 飘字特效,第1张

概述        之前在一个闯关游戏中第一次接触飘字效果,因为那个游戏没有发教程,所以在这里介绍下飘字效果 class FlowWord :public Node{public: FlowWord(); ~FlowWord(); //创建和初始化 飘字 static FlowWord* create(); bool init(); //显示飘字 void showFlowWor

之前在一个闯关游戏中第一次接触飘字效果,因为那个游戏没有发教程,所以在这里介绍下飘字效果


class FlowWord :public Node{public:	FlowWord();	~FlowWord();	//创建和初始化 飘字	static FlowWord* create();	bool init();	//显示飘字	voID showFlowWord(const char* text,Point pos,ActionInterval* flowWord);	//显示飘字结束	voID showEnd();//	ActionInterval* beginFlowWord();//	ActionInterval* propFlowWord();	ActionInterval* otherFlowWord();protected:private:	Label* m_textLabel;};


在这个类中,内置了几种常见的飘字动作和一个飘字函数(需要传入 飘字内容、位置、动作)


其实现如下

bool FlowWord::init(){	m_textLabel = Label::createWithTTF("","Fonts/DFPShaoNvW5-GB.ttf",25);	m_textLabel->setcolor(ccc3(CCRANDOM_0_1() * 255,CCRANDOM_0_1() * 255,CCRANDOM_0_1() * 255));	m_textLabel->setAnchorPoint(ccp(1,0));	m_textLabel->setVisible(false);	this->addChild(m_textLabel);	return true;}//显示飘字voID FlowWord::showFlowWord(const char* text,ActionInterval* flowWord){	m_textLabel->setposition(pos);	m_textLabel->setString(text);	m_textLabel->setVisible(true);	m_textLabel->runAction(flowWord);}//显示飘字结束voID FlowWord::showEnd(){	cclOG("showWord End!");	m_textLabel->setVisible(false);	m_textLabel->removeFromParentAndCleanup(true);}#if 0//游戏开始飘字ActionInterval* FlowWord::beginFlowWord(){	//放大缩小	ActionInterval* m_scaleLarge = Scaleto::create(2.0f,2.5,2.5);	ActionInterval* m_scaleSmall = Scaleto::create(2.0f,0.5,0.5);	//倾斜	ActionInterval* m_skew = SkewTo::create(2.0f,180,0);	ActionInterval* m_skewBack = SkewTo::create(2.0f,0);	//组合动作	ActionInterval* m_action = Spawn::create(m_scaleLarge,m_skew,NulL);	ActionInterval* m_actionBack = Spawn::create(m_scaleSmall,m_skewBack,NulL);	CallFunc* callFunc = CallFunc::create(this,callfunc_selector(FlowWord::showEnd));	ActionInterval* flow = Sequence::create(m_action,m_actionBack,callFunc,NulL);	return flow;}//获得道具飘字ActionInterval* FlowWord::propFlowWord(){	//放大缩小	ActionInterval* m_scaleLarge = Scaleto::create(2.0f,0.5);	CallFunc* callFunc = CallFunc::create(this,callfunc_selector(FlowWord::showEnd));	ActionInterval* flow = Sequence::create(m_scaleLarge,m_scaleSmall,NulL);	return flow;}#endif//其它飘字ActionInterval* FlowWord::otherFlowWord(){	//移位	ActionInterval* m_move1 = MoveBy::create(2.0f,ccp(30,30));	ActionInterval* m_move2 = MoveBy::create(2.0f,ccp(-30,-30));	ActionInterval* m_move3 = MoveBy::create(2.0f,-30));	ActionInterval* m_move4 = MoveBy::create(2.0f,30));	//放大缩小	ActionInterval* m_scale1 = Scaleto::create(2.0f,CCRANDOM_0_1() * 4,CCRANDOM_0_1() * 4);	ActionInterval* m_scale2 = Scaleto::create(2.0f,CCRANDOM_0_1() * 4);	ActionInterval* m_scale3 = Scaleto::create(2.0f,CCRANDOM_0_1() * 4);	ActionInterval* m_scale4 = Scaleto::create(2.0f,CCRANDOM_0_1() * 4);	ActionInterval* m_action1 = Spawn::create(m_move1,m_scale1,NulL);	ActionInterval* m_action2 = Spawn::create(m_move2,m_scale2,NulL);	ActionInterval* m_action3 = Spawn::create(m_move3,m_scale3,NulL);	ActionInterval* m_action4 = Spawn::create(m_move4,m_scale4,NulL);	CallFunc* callFunc = CallFunc::create(this,callfunc_selector(FlowWord::showEnd));	ActionInterval* flow = Sequence::create(m_action1,m_action2,m_action3,m_action4,NulL);	return flow;}
总结

以上是内存溢出为你收集整理的【cocos2d-x 3.7 飞机大战】 决战南海I (九) 飘字特效全部内容,希望文章能够帮你解决【cocos2d-x 3.7 飞机大战】 决战南海I (九) 飘字特效所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1069138.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存