1,英雄被砍的时候的掉血效果,这里提供一种思路,还有其他的感觉这个比较简单分享一下
CCSprite* l_banker = CCSprite::create("bankerbg.png");
l_banker->setPosition(ccp(600,500));
addChild(l_banker,10);
CCSprite* l_redbar = CCSprite::create("minusBlood2.png");
m_totalbanker_progressbar= CCProgressTimer::create(l_redbar);
m_totalbanker_progressbar->setMidpoint(CCPointMake(0,0.5));
m_totalbanker_progressbar->setType(kCCProgressTimerTypeBar);
m_totalbanker_progressbar->setBarChangeRate(CCPointMake(1,0));
m_totalbanker_progressbar->setPosition(ccp(l_banker->boundingBox().getMidX(),l_banker->boundingBox().getMaxY() -30));
addChild(m_totalbanker_progressbar,11);
m_totalbanker_progressbar->setPercentage(100);
CCSprite* l_greenbar = CCSprite::create("redbar.png");
m_totalcanbet_progressbar= CCProgressTimer::create(l_greenbar);
m_totalcanbet_progressbar->setMidpoint(CCPointMake(0,0.5));
m_totalcanbet_progressbar->setType(kCCProgressTimerTypeBar);
m_totalcanbet_progressbar->setBarChangeRate(CCPointMake(1,0));
m_totalcanbet_progressbar->setPosition(ccp(l_banker->boundingBox().getMidX(),l_banker->boundingBox().getMaxY() -30));
addChild(m_totalcanbet_progressbar,11);
m_totalcanbet_progressbar->setPercentage(100);
static int a =100; // _progressBar->progressTo(a); a+=30; if (a>100) { a=0; } m_nextper =a; int b = m_totalcanbet_progressbar->getPercentage(); CCProgressFromTo *to2 = CCProgressFromTo::create(0.1,b,a); m_totalcanbet_progressbar->runAction(to2); CCFadeOut*l_fadeout = CCFadeOut::create(0.5); CCCallFunc* l_call =CCCallFunc::create(this,callfunc_selector(HelloWorld::beAttactedFinished)); CCSequence* l_bankerbeattackseq = CCSequence::create(l_fadeout,l_call,NULL); m_totalbanker_progressbar->runAction(l_bankerbeattackseq);
原文链接:/cocos2dx/340944.html