本文整理汇总了C++中CCProgressTimer::getContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCProgressTimer::getContentSize方法的具体用法?C++ CCProgressTimer::getContentSize怎么用?C++ CCProgressTimer::getContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCProgressTimer
的用法示例。
在下文中一共展示了CCProgressTimer::getContentSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}