Pop up the expression bubbles & amp; the conversion skill CD implementation of the imitation Warcraft, and the expression bubbles

Source: Internet
Author: User

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



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.