Ejemplo n.º 1
0
void CCTransitionRadialCCW::onEnter()
{
	CCTransitionScene::onEnter();
	// create a transparent color layer
	// in which we are going to add our rendertextures
	CCSize size = CCDirector::sharedDirector()->getWinSize();

	// create the second render texture for outScene
	m_OutRT = CCRenderTexture::renderTextureWithWidthAndHeight((int)size.width, (int)size.height);

	if (NULL == m_OutRT)
		return;
	
	m_OutRT->retain();

	m_OutRT->getSprite()->setAnchorPoint(ccp(0.5f,0.5f));
	m_OutRT->setPosition(ccp(size.width/2, size.height/2));
	m_OutRT->setAnchorPoint(ccp(0.5f,0.5f));

	//	We need the texture in RenderTexture.
	CCProgressTimer *outNode = CCProgressTimer::progressWithTexture(m_OutRT->getSprite()->getTexture());
	// but it's flipped upside down so we flip the sprite
	outNode->getSprite()->setFlipY(true);

	// fix content scale factor for radial texture
	CCRect rect = CCRectZero;
	rect.size = m_OutRT->getSprite()->getTexture()->getContentSize();
	outNode->getSprite()->setTextureRect(rect, false);
	float scale = 1.0f / CC_CONTENT_SCALE_FACTOR();
	rect.size.width *= scale;
	rect.size.height *= scale;
	outNode->setContentSize(rect.size);

	//	Return the radial type that we want to use
	outNode->setType(radialType());
	outNode->setPercentage(100.f);
	outNode->setPosition(ccp(size.width/2, size.height/2));
	outNode->setAnchorPoint(ccp(0.5f,0.5f));

	// create the blend action
	CCAction * layerAction = CCSequence::actions
	(
		CCProgressFromTo::actionWithDuration(m_fDuration, 100.0f, 0.0f),
		CCEventCall::actionWithTarget(NULL, createEventHandler(this, &CCTransitionScene::_finish)),
		NULL
	);
	// run the blend action
	outNode->runAction(layerAction);

	// add the layer (which contains our two rendertextures) to the scene
	this->addChild(outNode, 2, kSceneRadial);
}
Ejemplo n.º 2
0
void ASGame::changeHeart(int _shengming,int _source){
    
    shengming += _shengming;
    if (shengming<=0)
        shengming = 0;
    
    //1.血条
    CCProgressTimer* heartBar = (CCProgressTimer*)this->getChildByTag(1*10000000+2222);
    CCProgressFromTo* action = CCProgressFromTo::create(0.5, heartBar->getPercentage(), (float)shengming/(float)maxShengMing*100);
    heartBar->runAction(action);
    if ((float)shengming <= 0.4*(float)maxShengMing){
        heartBar->getSprite()->setColor(ccc3(237, 45, 37));
        
        if(!MainUser->muted){
            CocosDenshion::SimpleAudioEngine::sharedEngine()->stopEffect(heartSoundEffect);
            heartSoundEffect = CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("noHeart.wav", true);
        }
    }else{
        heartBar->getSprite()->setColor(ccc3(255, 255, 255));
        if(!MainUser->muted)
            CocosDenshion::SimpleAudioEngine::sharedEngine()->stopEffect(heartSoundEffect);
    }
    
    //2.生命数字
    string HeartStr = int2string(shengming)  + "/" + int2string(maxShengMing);
    CCLabelTTF* heartLabel = (CCLabelTTF*)this->getChildByTag(playerNumber*10000000+2223);
    heartLabel->setString(HeartStr.c_str());

    //3.判断胜利条件
    if (shengming == 0 && !((GameBaseClass*)getParent())->gameover){
        ((GameBaseClass*)getParent())->gameover = true;
        //1.禁用各种按钮
        CCMenu* skillMenu = (CCMenu*)this->getChildByTag(1*10000000+27);
        CCMenu* optionMenu = (CCMenu*)this->getChildByTag(1*10000000+12);
        CCMenu* itemMenu = (CCMenu*)this->getChildByTag(1*10000000+77776);
        skillMenu->setTouchEnabled(false);
        optionMenu->setTouchEnabled(false);
        itemMenu->setTouchEnabled(false);
        
        //2.停止所有监听
        unscheduleAllSelectors();
        bot2->unscheduleAllSelectors();
        
        //3.结束页面
        ((GameBaseClass*)getParent())->GameResult(1);
    }
}
Ejemplo n.º 3
0
void CCTransitionRadialCCW::onEnter()
{
	CCTransitionScene::onEnter();
	// create a transparent color layer
	// in which we are going to add our rendertextures
	CCSize size = CCDirector::sharedDirector()->getWinSize();

	// create the second render texture for outScene
	CCRenderTexture *outTexture = CCRenderTexture::renderTextureWithWidthAndHeight((int)size.width, (int)size.height);

	if (NULL == outTexture)
	{
		return;
	}
	
	outTexture->getSprite()->setAnchorPoint(ccp(0.5f,0.5f));
	outTexture->setPosition(ccp(size.width/2, size.height/2));
	outTexture->setAnchorPoint(ccp(0.5f,0.5f));

	// render outScene to its texturebuffer
	outTexture->clear(0,0,0,1);
	outTexture->begin();
	m_pOutScene->visit();
	outTexture->end();

	//	Since we've passed the outScene to the texture we don't need it.
	this->hideOutShowIn();

	//	We need the texture in RenderTexture.
	CCProgressTimer *outNode = CCProgressTimer::progressWithTexture(outTexture->getSprite()->getTexture());
	// but it's flipped upside down so we flip the sprite
	outNode->getSprite()->setFlipY(true);
	//	Return the radial type that we want to use
	outNode->setType(radialType());
	outNode->setPercentage(100.f);
	outNode->setPosition(ccp(size.width/2, size.height/2));
	outNode->setAnchorPoint(ccp(0.5f,0.5f));

	// create the blend action
	CCAction * layerAction = CCSequence::actions
	(
		CCProgressFromTo::actionWithDuration(m_fDuration, 100.0f, 0.0f),
		CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
		NULL
	);
	// run the blend action
	outNode->runAction(layerAction);

	// add the layer (which contains our two rendertextures) to the scene
	this->addChild(outNode, 2, kSceneRadial);
}
Ejemplo n.º 4
0
CCProgressTimer* CCTransitionProgressRadialCW::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( kCCProgressTimerTypeRadial );
    
    //    Return the radial type that we want to use
    pNode->setReverseDirection(true);
    pNode->setPercentage(100);
    pNode->setCenterOrigin(ccp(size.width/2, size.height/2));
    
    return pNode;
}
Ejemplo n.º 5
0
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;
}