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; }
// CCTransitionProgress void CCTransitionProgress::onEnter() { CCTransitionScene::onEnter(); setupTransition(); // 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 *texture = CCRenderTexture::create((int)size.width, (int)size.height); texture->getSprite()->setAnchorPoint(ccp(0.5f,0.5f)); texture->setCenterOrigin(ccp(size.width/2, size.height/2)); // render outScene to its texturebuffer texture->clear(0, 0, 0, 1); texture->begin(); m_pSceneToBeModified->visit(); texture->end(); // Since we've passed the outScene to the texture we don't need it. if (m_pSceneToBeModified == m_pOutScene) { hideOutShowIn(); } // We need the texture in RenderTexture. CCProgressTimer *pNode = progressTimerNodeWithRenderTexture(texture); // create the blend action CCActionInterval* layerAction = (CCActionInterval*)CCSequence::create( CCProgressFromTo::create(m_fDuration, m_fFrom, m_fTo), CCCallFunc::create(this, callfunc_selector(CCTransitionProgress::finish)), NULL); // run the blend action pNode->runAction(layerAction); // add the layer (which contains our two rendertextures) to the scene pNode->setTag(kCAWindowRadial); this->insertSubview(pNode, 2); }