Ejemplo n.º 1
0
//------------------------------------------------------------------
//
// SpriteProgressToRadialMidpointChanged
//
//------------------------------------------------------------------
void SpriteProgressToRadialMidpointChanged::onEnter()
{
    SpriteDemo::onEnter();

    CCSize s = CCDirector::sharedDirector()->getWinSize();

    CCProgressTo *action = CCProgressTo::create(2, 100);

    /**
   *  Our image on the left should be a radial progress indicator, clockwise
   */

    CCProgressTimer *left = CCProgressTimer::progressWithFile(s_pPathBlock);
    left->setType(kCCProgressTimerTypeRadialCW);
    addChild(left);
    left->setAnchorPoint(ccp(0.25f, 0.75f));
    left->setPosition(ccp(100, s.height/2));
    left->runAction(CCRepeatForever::create((CCActionInterval *)action->copy()->autorelease()));

    /**
   *  Our image on the left should be a radial progress indicator, counter clockwise
   */
    CCProgressTimer *right = CCProgressTimer::progressWithFile(s_pPathBlock);
    right->setType(kCCProgressTimerTypeRadialCW);
    right->setAnchorPoint(ccp(0.75f, 0.25f));

    /**
   *  Note the reverse property (default=NO) is only added to the right image. That's how
   *  we get a counter clockwise progress.
   */
    addChild(right);
    right->setPosition(ccp(s.width-100, s.height/2));
    right->runAction(CCRepeatForever::create((CCActionInterval *)action->copy()->autorelease()));
}
Ejemplo n.º 2
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.º 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
void
MCSkillBarItem::intoColdTime()
{
    CCSprite *coldSprite = CCSprite::create(kMCColdTimeSkillIconFilepath);
    CCProgressTimer *progressTimer = CCProgressTimer::create(coldSprite);
    
    progressTimer->setReverseProgress(true);
    progressTimer->setAnchorPoint(CCPointZero);
    addChild(progressTimer);
    
    setOpacity(kMCSkillBarItemColdTimeOpacity);
    progressTimer->runAction(CCSequence::createWithTwoActions(CCProgressFromTo::create(skill_->coldTime, 100.f, 0.0f),
                                                              CCCallFuncO::create(this,
                                                                                  callfuncO_selector(MCSkillBarItem::coldTimeDidFinish),
                                                                                  progressTimer)));
}
bool ControlEngine::initProgressIndicator( int tag, cocos2d::CCPoint point, cocos2d::CCPoint anchor )
{
    CCSprite* progressIndicatorSprite = CCSprite::create( this->getProgressIndicatorName().getCString() );
    if( progressIndicatorSprite )
    {
        CCProgressTimer* progressIndicator = CCProgressTimer::create( progressIndicatorSprite );
        if( progressIndicator )
        {
            progressIndicator->ignoreAnchorPointForPosition( false );
            progressIndicator->setAnchorPoint( anchor );
            progressIndicator->setPosition( point );
            this->addChild( progressIndicator, Child::Z::progressIndicator, tag );
            return true;
        }
    }
    return false;
}
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->setPosition(ccp(size.width/2, size.height/2));
    pNode->setAnchorPoint(ccp(0.5f,0.5f));
    
    return pNode;
}
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->setPosition(ccp(size.width/2, size.height/2));
    pNode->setAnchorPoint(ccp(0.5f,0.5f));
    
    return pNode;
}
Ejemplo n.º 8
0
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);
    }
}
Ejemplo n.º 9
0
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);
			m_visionLabel->setPosition(ccp(visibleSize.width -m_visionLabel->getContentSize().width/2,
				visibleSize.height -m_visionLabel->getContentSize().height/2));
		}

		m_layout = UIManager::sharedManager()->CreateUILayoutFromFile("UIplist/splashUI.plist", this, "SplashLayout");
		UIManager::sharedManager()->RegisterMenuHandler("SplashLayout","FrontCoverLayer::menuLoginGameCallback",
			menu_selector(FrontCoverLayer::menuLoginGameCallback), this);
		UIManager::sharedManager()->RegisterMenuHandler("SplashLayout","FrontCoverLayer::onClickedMoreSever",
			menu_selector(FrontCoverLayer::onClickedMoreSever), this);
		UIManager::sharedManager()->RegisterMenuHandler("SplashLayout","FrontCoverLayer::onCLickedSeverCloseBt",
			menu_selector(FrontCoverLayer::onCLickedSeverCloseBt), this);
		UIManager::sharedManager()->RegisterMenuHandler("SplashLayout","FrontCoverLayer::onClickedLatestSever",
			menu_selector(FrontCoverLayer::onClickedLatestSever), this);
		
		if(m_layout)
		{
			m_severScrollPage = m_layout->FindChildObjectByName<UIScrollPage>("severScrollPage");
			setLastServerLabel();
			m_layout->setVisible(false);
		}
		
		/// response to keyboard
		this->setKeypadEnabled(true);
		
		bRet = true;
	}while (0);
	return bRet;
}