Pop up the expression bubbles & the conversion skill CD implementation of the imitation Warcraft, and the expression bubbles
I suddenly found that I haven't updated it for a long time. It's a little laggy in winter ~~
In the future, we will summarize some interesting little special effects in the game.
The following code encapsulates the implementation of two special effects into the class. For more information, see.
1. the bubble expression is displayed when the red hair is flushed.
The key implementation is ScaleTo application.
void BubbleLayer::show(){ m_IsVisible = true; this->setScale(0); ScaleTo* scaleTo = ScaleTo::create(0.15, 1.25); ScaleTo* scaleTo2 = ScaleTo::create(0.1, 1); this->runAction(Sequence::createWithTwoActions(scaleTo,scaleTo2));}void BubbleLayer::hide(){ m_IsVisible = false; ScaleTo* scaleTo = ScaleTo::create(0.15, 1.25); ScaleTo* scaleTo2 = ScaleTo::create(0.1, 0); this->runAction(Sequence::createWithTwoActions(scaleTo,scaleTo2));}
The called interface is refresh.
m_bubble->refresh(buffStr); if(m_bubble->getIsVisible()) { m_bubble->setPosition(emotionPoint); }
2. Skill "to CD"
The key implementation is the application of ProgressTimer.
void SkillBtn::startCooldown(){ m_CurrentInterval = 0; schedule(schedule_selector(SkillBtn::cooldownUpdate)); _pProgressCD->setVisible(true); m_IsTouchable = false;}void SkillBtn::cooldownUpdate(float dt){ if(m_CurrentInterval <= m_CooldownTime) { m_CurrentInterval += dt; _pProgressCD->setPercentage( 100 * (m_CooldownTime - m_CurrentInterval) / m_CooldownTime); } else { unschedule(schedule_selector(SkillBtn::cooldownUpdate)); _pProgressCD->setVisible(false); m_IsTouchable = true; }}
Call Method
SkillBtn *btn = (SkillBtn *)getChildByTag(tag_skillbtn_1); btn->startCooldown();
Click blocking during cooldown
Code download
Http://write.blog.csdn.net/postedit/43585907