当前位置: 首页>>代码示例>>C++>>正文


C++ CCProgressTimer::setBarChangeRate方法代码示例

本文整理汇总了C++中CCProgressTimer::setBarChangeRate方法的典型用法代码示例。如果您正苦于以下问题:C++ CCProgressTimer::setBarChangeRate方法的具体用法?C++ CCProgressTimer::setBarChangeRate怎么用?C++ CCProgressTimer::setBarChangeRate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCProgressTimer的用法示例。


在下文中一共展示了CCProgressTimer::setBarChangeRate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onEnter

//------------------------------------------------------------------
//
// SpriteProgressToVertical
//
//------------------------------------------------------------------
void SpriteProgressToVertical::onEnter()
{
    SpriteDemo::onEnter();
    
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    
    CCProgressTo *to1 = CCProgressTo::create(2, 100);
    CCProgressTo *to2 = CCProgressTo::create(2, 100);
    
    CCProgressTimer *left = CCProgressTimer::create(CCSprite::create(s_pPathSister1));
    left->setType(kCCProgressTimerTypeBar);

    //    Setup for a bar starting from the bottom since the midpoint is 0 for the y
    left->setMidpoint(ccp(0,0));
    //    Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
    left->setBarChangeRate(ccp(0, 1));
    addChild(left);
    left->setPosition(CCPointMake(100, s.height/2));
    left->runAction( CCRepeatForever::create(to1));
    
    CCProgressTimer *right = CCProgressTimer::create(CCSprite::create(s_pPathSister2));
    right->setType(kCCProgressTimerTypeBar);
    //    Setup for a bar starting from the bottom since the midpoint is 0 for the y
    right->setMidpoint(ccp(0, 1));
    //    Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
    right->setBarChangeRate(ccp(0, 1));
    addChild(right);
    right->setPosition(CCPointMake(s.width-100, s.height/2));
    right->runAction( CCRepeatForever::create(to2));
}
开发者ID:DangoXJ,项目名称:TuJinZhi,代码行数:35,代码来源:ActionsProgressTest.cpp

示例2: onEnter

void SpriteProgressToHorizontal::onEnter()
{
    SpriteDemo::onEnter();
    
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    
    CCProgressTo *to1 = CCProgressTo::create(2, 100);
    CCProgressTo *to2 = CCProgressTo::create(2, 100);
    
    CCProgressTimer *left = CCProgressTimer::progressWithFile(s_pPathSister1);
    left->setType(kCCProgressTimerTypeHorizontalBarLR);
    //    Setup for a bar starting from the left since the midpoint is 0 for the x
    left->setMidpoint(ccp(0,0));
    //    Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change
    left->setBarChangeRate(ccp(1, 0));
    addChild(left);
    left->setPosition(ccp(100, s.height/2));
    left->runAction( CCRepeatForever::create(to1));
    
    CCProgressTimer *right = CCProgressTimer::progressWithFile(s_pPathSister2);
    right->setType(kCCProgressTimerTypeHorizontalBarRL);
    //    Setup for a bar starting from the left since the midpoint is 1 for the x
    right->setMidpoint(ccp(1, 0));
    //    Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change
    right->setBarChangeRate(ccp(1, 0));
    addChild(right);
    right->setPosition(ccp(s.width-100, s.height/2));
    right->runAction( CCRepeatForever::create(to2));
}
开发者ID:qiuxu,项目名称:Cocos2dWindows,代码行数:29,代码来源:ActionsProgressTest.cpp

示例3: setUpdateView

bool LoadingLayer::setUpdateView()
{
    bool isRet = false;
    do{
	CCSprite* loadingbackimg = CCSprite::create("gmbg/loadingbg.png");
	CC_BREAK_IF(!loadingbackimg);
	loadingbackimg->setPosition(ccp(getWinSize().width/2 + getWinOrigin().x, getWinSize().height/5 + getWinOrigin().y));
	this->addChild(loadingbackimg, 1);

	CCSprite* loadimg = CCSprite::create("gmbg/loading.png");
	CC_BREAK_IF(!loadimg);
	CCProgressTimer* pt = CCProgressTimer::create(loadimg);
	pt->setType(cocos2d::CCProgressTimerType(kCCProgressTimerTypeBar));
	pt->setMidpoint(ccp(0,0.5));
	pt->setBarChangeRate(ccp(1,0));
	float tex = getWinSize().width/2 + getWinOrigin().x;
	float tey = getWinSize().height/5 + getWinOrigin().y-5;
	pt->setPosition(ccp(tex, tey));
	pt->setPercentage(0);
	this->addChild(pt, 2, 1);
	CCProgressTo* to = CCProgressTo::create(5, 100);
	pt->runAction(CCRepeatForever::create(to));
	isRet = true;
	
    }while(0);
    return isRet;
}
开发者ID:hzfeibao,项目名称:Defender,代码行数:27,代码来源:LoadingLayer.cpp

示例4: setUpdateView

bool LoadingLayer::setUpdateView(){
	bool isRet=false;
	do 
	{
	// 设置进度条的背景图片 我们把他放到屏幕下方的1/5处	
    CCSprite* loadbackimg=CCSprite::create("gmbg/lodingbg.png");
	CC_BREAK_IF(!loadbackimg);	
	loadbackimg->setPosition(ccp(getWinSize().width/2+getWinOrigin().x,getWinSize().height/5+getWinOrigin().y));
	this->addChild(loadbackimg,1);
	
	// 添加进度条
	CCSprite* loadimg=CCSprite::create("gmbg/longding.png");
	CC_BREAK_IF(!loadimg);	
	CCProgressTimer* pt = CCProgressTimer::create(loadimg);
	pt->setType(kCCProgressTimerTypeBar);// 设置成横向的
	//可以看作是按矩形显示效果的进度条类型
	pt->setMidpoint(ccp(0,0)); 
	//  用来设定进度条横向前进的方向从左向右或是从右向左
	pt->setBarChangeRate(ccp(1,0));
	//重新设置锚点
	float tex=getWinSize().width/2+getWinOrigin().x;
	float tey=getWinSize().height/5+getWinOrigin().y-5;
	pt->setPosition(ccp(tex,tey));
	pt->setPercentage(0);
	this->addChild(pt,2,1);

	isRet=true;
	} while (0);
	return isRet;
}
开发者ID:joyfish,项目名称:cocos2d-1,代码行数:30,代码来源:LoadingLayer.cpp

示例5: init

bool HSShowEndurance::init()
{
    for (int i=0; i<HSShowEndurance::S_C_ENDURANCE_COUNT; ++i)
    {
        CCString* pPanel = CCString::createWithFormat("UI_Benfangxinxiban_Naili_%d",i);
        
        HSCCSprite* pSprite = HS_FIND_UI_PANEL_SPRITE(pPanel->getCString(),"Naili_1");
        pSprite->setVisible(false);
        
        CCProgressTimer* pProgress = CCProgressTimer::create(pSprite);
        pProgress->setType(kCCProgressTimerTypeBar);
        pProgress->setPosition(pSprite->getPosition());
        pProgress->setMidpoint(ccp(0.5,0));
        pProgress->setBarChangeRate(ccp(0,1));
        i < HSShowEndurance::S_CURRENT_ENDURANCE_COUNT  ? pProgress->setPercentage(100) : pProgress->setPercentage(0);
        pSprite->getParent()->addChild(pProgress,2000);
        m_enduranceMap.insert(pair<int, CCProgressTimer*>(i + 1,pProgress));
        
        CC_SAFE_RELEASE_NULL(pPanel);
    }
    
    HSCCSprite* pSprite = HS_FIND_UI_PANEL_SPRITE("UI_Benfangxinxiban_Nailijishiqi","Pipeinailidiban");
    
    m_pMaxLabel = CCLabelTTF::create("MAX", HS_FONT_HuaKang, 25, pSprite->getContentSize(), kCCTextAlignmentCenter,kCCVerticalTextAlignmentCenter);
    m_pMaxLabel->setAnchorPoint(HS_ANCHOR_CENTER);
    m_pMaxLabel->setPosition(pSprite->getAnchorPointInPoints());
    m_pMaxLabel->setVisible(false);
    pSprite->addChild(m_pMaxLabel);
    
    this->CreateTimeLabel();
    
    this->schedule(schedule_selector(HSShowEndurance::Updata));
    
	return true;
}
开发者ID:wanggan768q,项目名称:GameWork,代码行数:35,代码来源:HSShowEndurance.cpp

示例6: setUpdateView

bool wootestScene::setUpdateView()
{
	bool isRet=false;
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
	do
	{
        // 进度条背景
        CCSprite* loadbackimg=CCSprite::create("lodingbg.png");
        CC_BREAK_IF(!loadbackimg);
        loadbackimg->setPosition(ccp(visibleSize.width/2+origin.x,visibleSize.height/5+origin.y));
        this->addChild(loadbackimg,2);
        
        // 进度条
        CCSprite* loadimg=CCSprite::create("longding.png");
        CC_BREAK_IF(!loadimg);
        CCProgressTimer* pt = CCProgressTimer::create(loadimg);
        pt->setType(kCCProgressTimerTypeBar);// 设置成横向
        
        pt->setMidpoint(ccp(0,0));
        // 设置进度条从左到右
        pt->setBarChangeRate(ccp(1,0));
        
        //重新设置锚点
        float tex=visibleSize.width/2+origin.x;
        float tey=visibleSize.height/5+origin.y-5;
        pt->setPosition(ccp(tex,tey));
        pt->setPercentage(0);
        this->addChild(pt,2,1);
        
        isRet=true;
	} while (0);
	return isRet;
}
开发者ID:joyfish,项目名称:cocos2d-1,代码行数:34,代码来源:wootestScene.cpp

示例7: createProgressTimer

CCProgressTimer* createProgressTimer(CCSprite* sprite)
{
	CCProgressTimer *progress = CCProgressTimer::create(sprite);
	progress->setType( kCCProgressTimerTypeBar );
	progress->setMidpoint(ccp(0,0));
	progress->setBarChangeRate(ccp(1, 0));
	return progress;
}
开发者ID:SongCF,项目名称:game-LostStar,代码行数:8,代码来源:LFUtile.cpp

示例8: createRedStartToTableArrows

CCProgressTimer* SectionGuide::createRedStartToTableArrows()
{
    CCSprite* sprite = CCSprite::create(ResManager::getManager()->getSharedFilePath("arrows.png").c_str());
    CCProgressTimer *progress = CCProgressTimer::create(sprite);
    progress->setType( kCCProgressTimerTypeBar );
    progress->setVisible(false);
    progress->setMidpoint(ccp(0,1));
    progress->setBarChangeRate(ccp(0, 1));
    return progress;
}
开发者ID:SongCF,项目名称:game-LostStar,代码行数:10,代码来源:SectionGuide.cpp

示例9: energyBarAnimation

void ASGame::energyBarAnimation(){
    
    //1.显示行动力的圆形底座
    CCSprite* energyBall = CCSprite::createWithSpriteFrameName("newEnergyContainer.png");
    energyBall->setPosition(ccp(size.width*17.38/80,size.height*77.85/90+winDif*2*alpha*alpha));
    addChild(energyBall,4);
    
    //2.行动力数量
    string perStr = int2string(moveCount);
    CCLabelTTF* per = CCLabelTTF::create(perStr.c_str(),"Arial Rounded MT bold",32);
    per->setPosition(ccp(size.width*17.38/80,size.height*77.85/90+winDif*2*alpha*alpha));
    addChild(per,5,1*10000000+26);
    
    //3.能量条
    CCSprite* energyBarSprite = CCSprite::createWithSpriteFrameName("newEnergyBar.png");
    CCProgressTimer* energyBar = CCProgressTimer::create(energyBarSprite);
    energyBar->setPosition(ccp(size.width*8.45/80,size.height*79.89/90+winDif*2*alpha*alpha));
    energyBar->setType(kCCProgressTimerTypeRadial);
    energyBar->setPercentage(moveCount*20);
    addChild(energyBar,4,1*10000000+20);
    
    //4.攻击按钮底座
    CCSprite* containerSprite = CCSprite::createWithSpriteFrameName("energyContainer.png");
    CCSprite* containerSprite_s = CCSprite::createWithSpriteFrameName("energyContainer.png");
    CCMenuItemSprite* energyContainer = CCMenuItemSprite::create(containerSprite,containerSprite_s,this,menu_selector(ASGame::enterFightLayer));
    energyContainer->setScale(1.05);
    energyContainer->setPosition(ccp(size.width*179.5/200,size.height*10.25/135));
    CCMenu* energyContainerMenu = CCMenu::create(energyContainer,NULL);
    energyContainerMenu->setPosition(CCPointZero);
    if (moveCount < moveToFight)
            energyContainerMenu->setTouchEnabled(false);
    addChild(energyContainerMenu,2,1*10000000+27);
    
    //5.攻击按钮充值槽
    CCSprite* barSprite = CCSprite::createWithSpriteFrameName("energyBar.png");
    CCProgressTimer* attackButton = CCProgressTimer::create(barSprite);
    attackButton->setScale(1.05);
    attackButton->setPosition(ccp(size.width*179.04/200,size.height*10/135));
    attackButton->setType(kCCProgressTimerTypeBar);
    attackButton->setMidpoint(ccp(0.5, 0));
    attackButton->setBarChangeRate(ccp(0, 1));
    attackButton->setPercentage(100*moveCount/moveToFight);
    addChild(attackButton,3,1*10000000+25);
    
    //4.能量的盖子
    CCSprite* energyBarCover = CCSprite::createWithSpriteFrameName("energyBarCover.png");
    energyBarCover->setPosition(ccp(size.width*179.5/200,size.height*10.25/135));
    energyBarCover->setOpacity(0);
    //addChild(energyBarCover,4,1*10000000+28);
}
开发者ID:nooboracle,项目名称:ForTest,代码行数:50,代码来源:ASEnergyBar.cpp

示例10: init

bool BattleLayer::init()
{
	if(!CCLayer::init())
		return false;
	
	m_label = CCLabelTTF::create("第1波", "", 40);
	m_label->setPosition(ccp(320,800));
	m_label->retain();
	addChild(m_label);
	
	m_effectLabel = CCLabelTTF::create("", "", 30);
	m_effectLabel->setPosition(ccp(320,750));
	m_effectLabel->setColor(ccc3(255,0,0));
	addChild(m_effectLabel);
	
	m_guardLabel = CCLabelTTF::create("", "", 30);
	m_guardLabel->setPosition(ccp(320,700));
	m_guardLabel->setColor(ccc3(255,255,0));
	addChild(m_guardLabel);
	
	m_enemySprite = CCSprite::create("icons/0020.png");
	m_enemySprite->retain();
	
	CCSprite* hpbg = CCSprite::create("hpbar_bg.png");
	CCProgressTimer* hpbar = CCProgressTimer::create(CCSprite::create("hpbar_fore.png"));
	hpbg->setPosition(ccp(50,100));
	hpbar->setPosition(ccp(50,100));
	hpbar->setType(kCCProgressTimerTypeBar);
	hpbar->setBarChangeRate(ccp(1,0));
	hpbar->setPercentage(100);
	hpbar->setMidpoint(CCPointZero);
	hpbar->setTag(0);
	m_enemySprite->addChild(hpbg);
	m_enemySprite->addChild(hpbar);
	
	
	addChild(m_enemySprite,SpritezOrder::Enemy);
	
	m_cardbattleLayer = CardBattleLayer::create();
	m_cardbattleLayer->retain();
	
	m_setTrapLayer = SetTrapLayer::create();
	addChild(m_setTrapLayer);
	
	m_pauseSprite = CCSprite::create("pause.png");
	m_pauseSprite->setPosition(ccp(590,910));
	addChild(m_pauseSprite);
	
	return true;
}
开发者ID:chhao,项目名称:CombatDemo,代码行数:50,代码来源:BattleLayer.cpp

示例11: progressTimerNodeWithRenderTexture

CCProgressTimer* CCTransitionProgressOutIn::progressTimerNodeWithRenderTexture(CCRenderTexture* texture)
{    
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    
    CCProgressTimer* pNode = CCProgressTimer::create(texture->getSprite());
    
    // but it is flipped upside down so we flip the sprite
    pNode->getSprite()->setFlipY(true);
    pNode->setType( kCCProgressTimerTypeBar );
    
    pNode->setMidpoint(ccp(0.5f, 0.5f));
    pNode->setBarChangeRate(ccp(1, 1));
    
    pNode->setPercentage(100);
    pNode->setCenterOrigin(ccp(size.width/2, size.height/2));
    
    return pNode;
}
开发者ID:anarki1234,项目名称:9miao,代码行数:18,代码来源:CCTransitionProgress.cpp

示例12: HeartBar

void ASGame::HeartBar(){
    
    //1.血条
    CCSprite* heartBarSprite = CCSprite::createWithSpriteFrameName("newLifeBar.png");
    CCProgressTimer* heartBar = CCProgressTimer::create(heartBarSprite);
    heartBar->setPosition(ccp(size.width*23.08/80,size.height*85.23/90+winDif*2*alpha*alpha));
    heartBar->setType(kCCProgressTimerTypeBar);
    heartBar->setMidpoint(ccp(0,0.5));
    heartBar->setBarChangeRate(ccp(1, 0));
    heartBar->setPercentage(100);
    addChild(heartBar,4,1*10000000+2222);
    
    //2.生命数字
    string HeartStr = int2string(shengming)  + "/" + int2string(maxShengMing);
    CCLabelTTF* userHeartNumber= CCLabelTTF::create(HeartStr.c_str(), "Arial Rounded MT bold",25);
    userHeartNumber->setPosition(ccp(size.width*26/80,size.height*82/90+winDif*2*alpha*alpha));
    addChild(userHeartNumber,4,1*10000000+2223);
}
开发者ID:nooboracle,项目名称:ForTest,代码行数:18,代码来源:ASHeart.cpp

示例13: setAttribute

void CCProgressTimerCreator::setAttribute(CCNode* pNode, const char* strName, const char* strValue, bool bCache)
{
    if(bCache)
        mAttrMap[strName] = strValue;

    else
    {
        CCProgressTimer* pProgressTimer = (CCProgressTimer*)pNode;
        if(strcmp(strName, "file") == 0 || strcmp(strName, "plist") == 0 )
            return;

        if(strcmp(strName, "type") == 0)
            pProgressTimer->setType((CCProgressTimerType)ccXmlAttrParse::toInt(strValue));

        if(strcmp(strName, "percent") == 0)
            pProgressTimer->setPercentage(ccXmlAttrParse::toFloat(strValue));

        if(strcmp(strName, "midpos") == 0)
            pProgressTimer->setMidpoint(ccXmlAttrParse::toPoint(strValue));

        if(strcmp(strName, "rate") == 0)
            pProgressTimer->setBarChangeRate(ccXmlAttrParse::toPoint(strValue));

        if(strcmp(strName, "reverse") == 0)
            pProgressTimer->setReverseProgress(ccXmlAttrParse::toBool(strValue));

        if(strcmp(strName, "anchor") == 0)
            pProgressTimer->setAnchorPoint(ccXmlAttrParse::toPoint(strValue));

        if(strcmp(strName, "color") == 0)
            pProgressTimer->setColor(ccXmlAttrParse::toColor3B(strValue));

        else
            CCNodeRGBACreator::setAttribute(pNode, strName, strValue, bCache);
    }
}
开发者ID:zhaxun,项目名称:cocos2d,代码行数:36,代码来源:ccMiscNodeCreator.cpp

示例14: init

bool FrontCoverLayer::init()
{	
	bool bRet = false;
	do {

		CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
		CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

		CCSprite* pSprite = CCSprite::create("frontCover.png");
		// position the sprite on the center of the screen
		float scaleX = visibleSize.width/pSprite->getTexture()->getPixelsWide();
		float scaleY = visibleSize.height/pSprite->getTexture()->getPixelsHigh();
		float scale = (scaleX > scaleY) ? scaleX : scaleY;
		pSprite->setScaleX(scale);
		pSprite->setScaleY(scale);
		pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
		this->addChild(pSprite, 0);

		//SkeletonAnimRcsManager::getInstance()->LoadOneRoleRcsOnly(201);
		SkeletonAnimRcsManager::getInstance()->LoadOneRoleRcsOnly(202);
		SkeletonAnimRcsManager::getInstance()->LoadOneRoleRcsOnly(203);

		EffectSprite* effect1 = ParticleManager::Get()->createEffectSprite(202,"");
		if(effect1)
		{
			effect1->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
			effect1->getRoot()->setScale(scale);
			this->addChild(effect1, 1);
			effect1->SetAnim(kType_Play,1,true);
		}
		
		//effect1 = ParticleManager::Get()->createEffectSprite(201,"");
		//if(effect1)
		//{
		//	effect1->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
		//	effect1->getRoot()->setScale(scale);
		//	this->addChild(effect1, 1);
		//	effect1->SetAnim(kType_Play,1,true);
		//}

		effect1 = ParticleManager::Get()->createEffectSprite(203,"");
		if(effect1)
		{
			effect1->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
			effect1->getRoot()->setScale(scale);
			this->addChild(effect1, 1);
			effect1->SetAnim(kType_Play,1,true);
		}

		CCSprite* spriteFrame = CCSprite::create("frontCoverFrame.png");	
		spriteFrame->setScaleX(scale);
		spriteFrame->setScaleY(scale);
		spriteFrame->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
		this->addChild(spriteFrame, 2);

		schedule(schedule_selector(FrontCoverLayer::update), 1);
        //ASprite *as = AspriteManager::getInstance()->getAsprite(KUI_BIN);
        //CCPoint pt;
        //CCSprite* bar = as->getSpriteFromFrame_Middle(map_ui_FRAME_EQUIPMENT_BAR_EXP, 0, pt);
        //CCSprite* barFrame = as->getSpriteFromFrame_Middle(map_ui_FRAME_EQUIPMENT_FRAME_EXP, 0, pt);
        
        CCSprite* barFrame = CCSprite::create("load0001.png");
        barFrame->setPosition(ccp(visibleSize.width/2, visibleSize.height/6));
        addChild(barFrame);
        
        CCSprite* sp = CCSprite::create("load0002.png");
        CCProgressTimer *progressBar = CCProgressTimer::create(sp);
        barFrame->addChild(progressBar,-1);
        progressBar->setPosition(ccp(6, barFrame->getContentSize().height/2-4));
        
        progressBar->setType(kCCProgressTimerTypeBar);
        progressBar->setAnchorPoint(ccp(0,0));
        progressBar->setMidpoint(ccp(0,0));
        progressBar->setBarChangeRate(ccp(1,0));
        progressBar->setPercentage(0.0f);

        _downloadTTF = CCLabelTTF::create("0%", KJLinXin, 15);
        _downloadTTF->setColor(ccORANGE);
        barFrame->addChild(_downloadTTF);
        _downloadTTF->setPosition(ccp(barFrame->getContentSize().width/2,barFrame->getContentSize().height/2));

        _downloadBar = progressBar;
        //_downloadBar->retain();
        
        _barFrame = barFrame;
        _barFrame->retain();
        
        
        GameResourceManager::sharedManager()->updateResource();
        
		GameAudioManager::sharedManager()->playLoadingBGM();
        
		const char* vision = LuaTinkerManager::Get()->callLuaFunc<char *>("Script/main.lua", "getVisionNum");
		m_visionLabel = CCLabelTTF::create(vision,KJLinXin,20);
		if(m_visionLabel)
		{
			float scale = UIManager::sharedManager()->getScaleFactor();
			m_visionLabel->setColor(ccWHITE);
			m_visionLabel->setScale(scale);
			addChild(m_visionLabel);
//.........这里部分代码省略.........
开发者ID:niuzb,项目名称:hellopetclient,代码行数:101,代码来源:FrontCoverLayer.cpp

示例15: 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;
}
开发者ID:mdifferent,项目名称:sanyu_rpg_cocos2dx,代码行数:83,代码来源:MonsterLayer.cpp


注:本文中的CCProgressTimer::setBarChangeRate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。