本文整理汇总了C++中CCProgressTimer::setOpacity方法的典型用法代码示例。如果您正苦于以下问题:C++ CCProgressTimer::setOpacity方法的具体用法?C++ CCProgressTimer::setOpacity怎么用?C++ CCProgressTimer::setOpacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCProgressTimer
的用法示例。
在下文中一共展示了CCProgressTimer::setOpacity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: skillCoolHandler
void OptionLayer::skillCoolHandler(CCObject* pSender)
{
OptionLayer *optionLayer = global->optionLayer;
UIImageView* skillView = (UIImageView*)pSender;
global->hero->setAllowMove(false);//动画执行期间角色不可移动
float SumCD = 10.0f;
//判断指向对象是否相等来初始化cd时间
if(optionLayer->getSkill_attack_1() == skillView){
SumCD = optionLayer->skill_SumCD_1;
global->hero->RunAttackAction_1(); //执行特殊攻击1动画
}else if(optionLayer->getSkill_attack_2() == skillView){
SumCD = optionLayer->skill_SumCD_2;
}else if(optionLayer->getSkill_attack_3() == skillView){
SumCD = optionLayer->skill_SumCD_3;
}else if(optionLayer->getSkill_attack() == skillView){
SumCD = optionLayer->skill_SumCD_0;
global->hero->RunAttackAction(); //执行普通攻击动画
}else if(optionLayer->getBlood_bottle() == skillView){
SumCD = optionLayer->blood_SumCD;
}else if(optionLayer->getMagic_bottle() == skillView){
SumCD = optionLayer->magic_SumCD;
}
skillView->setTouchEnabled(false); //CD开始,禁止本技能使用
//初始化 cd遮罩
CCTexture2D *spriteTx = CCTextureCache::sharedTextureCache()->addImage("Skill_UI/cooling_cover.png");
CCSprite * SkillCover = CCSprite::createWithTexture(spriteTx);
CCProgressTimer *skillTimer = CCProgressTimer::create(SkillCover);
skillTimer->setOpacity(125); //透明度
skillTimer->setPosition(skillView->getPosition());//将进度遮罩设置在技能图标位置上
optionLayer->getSkillUI()->addChild(skillTimer);
skillTimer->setType(kCCProgressTimerTypeRadial);//扇形
skillTimer->setPercentage(100);
skillTimer->setReverseProgress(true);
CCProgressTo* cdAction=CCProgressTo::create(SumCD, 100);
CCCallFuncND* func=CCCallFuncND::create(this, callfuncND_selector(OptionLayer::allowToClick),skillView);//附带skillView参数 方便cd结束后处理
CCFiniteTimeAction* seq=CCSequence::create(cdAction,func,NULL);
skillTimer->runAction(seq);
}
示例2: init
bool MonsterLayer::init() {
CCAssert(CCLayer::init(),"CCLayer init failed!");
int iPlayerCount = m_data->size();
this->setTouchEnabled(true);
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this,1,false);
float fScreenWidth = CCDirector::sharedDirector()->getVisibleSize().width;
float fScreenHeight = CCDirector::sharedDirector()->getVisibleSize().height;
for (int i = 0;i<iPlayerCount;++i) {
string name = m_data->at(i)->getName();
char pName[MAX_FILE_PATH_LENGTH];
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
GBKToUTF(name);
#endif
sprintf(pName,MONSTER_DIR_PATH,name.c_str());
CCSprite *pSprite = CCSprite::create(pName);
CCAssert(pSprite,"Get Monster sprite failed!");
float fPlayerWidth = pSprite->getContentSize().width;
float fPlayerHeight = pSprite->getContentSize().height;
float xpos = fScreenWidth*0.5+(i-iPlayerCount*0.5+0.5)*fPlayerWidth;
float ypos = fScreenHeight*0.6;
pSprite->setPosition(ccp(xpos,ypos));
pSprite->setOpacity(0);
addChild(pSprite,0,i);
m_monsters->addObject(pSprite);
m_originalPos.insert(make_pair(i,ccp(xpos,ypos)));
//HP Bar
CCProgressTimer *hpBarTimer = CCProgressTimer::create(CCSprite::create(MONSTER_HP_BAR_PATH));
hpBarTimer->setType(kCCProgressTimerTypeBar);
hpBarTimer->setMidpoint(ccp(0,0));
hpBarTimer->setPercentage(100);
hpBarTimer->setBarChangeRate(ccp(1,0));
hpBarTimer->setPosition(ccp(pSprite->getPositionX(),
pSprite->getPositionY() + fPlayerHeight*0.5 + hpBarTimer->getContentSize().height*0.5));
hpBarTimer->setOpacity(0);
addChild(hpBarTimer,1,iPlayerCount+i);
}
//Damage number
m_pFont = CCLabelBMFont::create("0",FONT_PATH);
m_pFont->setColor(ccYELLOW);
m_pFont->setOpacity(0);
addChild(m_pFont,4);
//Magic matrix tag
m_magicTag = CCSprite::create(MAGIC_BTN_PATH);
m_magicTag->setOpacity(0);
m_magicTag->setPosition(ccp(750,550));
addChild(m_magicTag);
m_magicPointer = CCSprite::create(MAGIC_UNAVA_PATH);
m_magicPointer->setOpacity(0);
m_magicPointer->setPosition(ccp(750,550));
addChild(m_magicPointer);
m_magicAva = CCTextureCache::sharedTextureCache()->addImage(MAGIC_AVA_PATH);
m_magicUnava = CCTextureCache::sharedTextureCache()->addImage(MAGIC_UNAVA_PATH);
m_longHPBar = CCProgressTimer::create(CCSprite::create(LONG_HP_BAR));
m_longHPBar->setType(kCCProgressTimerTypeBar);
m_longHPBar->setMidpoint(ccp(0,0));
m_longHPBar->setPercentage(100);
m_longHPBar->setBarChangeRate(ccp(1,0));
m_longHPBar->setOpacity(0);
m_longHPBar->setPosition(ccp(fScreenWidth*0.5,fScreenHeight*0.3));
addChild(m_longHPBar,2);
m_timeBarEmpty = CCSprite::create(TIME_BAR_EMPTY);
m_timeBarEmpty->setOpacity(0);
m_timeBarEmpty->setPosition(ccp(fScreenWidth*0.5,fScreenHeight*0.7));
addChild(m_timeBarEmpty,2);
m_timeBarFull = CCProgressTimer::create(CCSprite::create(TIME_BAR_FULL));
m_timeBarFull->setType(kCCProgressTimerTypeBar);
m_timeBarFull->setMidpoint(ccp(0,0));
m_timeBarFull->setPercentage(100);
m_timeBarFull->setBarChangeRate(ccp(1,0));
m_timeBarFull->setOpacity(0);
m_timeBarFull->setPosition(ccp(fScreenWidth*0.5,fScreenHeight*0.7));
addChild(m_timeBarFull,2);
CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
cache->addSpriteFramesWithFile(BUBBLE_PLIST_PATH,BUBBLE_TEXTURE_PATH);
return true;
}