//------------------------------------------------------------------ // // SpriteEase // //------------------------------------------------------------------ KDvoid SpriteEase::onEnter ( KDvoid ) { TestEaseActions::onEnter ( ); const CCSize& s = this->getContentSize ( ); CCActionInterval* move = CCMoveBy::create(3, ccp(s.cx-130,0 ) ); CCActionInterval* move_back = move->reverse(); CCActionInterval* move_ease_in = CCEaseIn::create ( CCCA ( move ), 2.5f); CCActionInterval* move_ease_in_back = move_ease_in->reverse(); CCActionInterval* move_ease_out = CCEaseOut::create ( CCCA ( move ), 2.5f); CCActionInterval* move_ease_out_back = move_ease_out->reverse(); CCDelayTime *delay = CCDelayTime::create(0.25f); CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), KD_NULL); CCSequence* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), KD_NULL); CCSequence* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), KD_NULL); CCAction *a2 = m_grossini->runAction(CCRepeatForever::create ( seq1 ) ); a2->setTag(1); CCAction *a1 = m_tamara->runAction(CCRepeatForever::create ( seq2 ) ); a1->setTag(1); CCAction *a = m_kathia->runAction(CCRepeatForever::create ( seq3 ) ); a->setTag(1); schedule(schedule_selector(SpriteEase::testStopAction), 6.25f); }
//------------------------------------------------------------------ // // LayerTest2 // //------------------------------------------------------------------ void LayerTest2::onEnter() { LayerTest::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLayerColor* layer1 = CCLayerColor::create( ccc4(255, 255, 0, 80), 100, 300); layer1->setPosition(ccp(s.width/3, s.height/2)); layer1->ignoreAnchorPointForPosition(false); addChild(layer1, 1); CCLayerColor* layer2 = CCLayerColor::create( ccc4(0, 0, 255, 255), 100, 300); layer2->setPosition(ccp((s.width/3)*2, s.height/2)); layer2->ignoreAnchorPointForPosition(false); addChild(layer2, 1); CCActionInterval* actionTint = CCTintBy::create(2, -255, -127, 0); CCActionInterval* actionTintBack = actionTint->reverse(); CCActionInterval* seq1 = CCSequence::create( actionTint, actionTintBack, NULL); layer1->runAction(seq1); CCActionInterval* actionFade = CCFadeOut::create(2.0f); CCActionInterval* actionFadeBack = actionFade->reverse(); CCActionInterval* seq2 = CCSequence::create(actionFade, actionFadeBack, NULL); layer2->runAction(seq2); }
//------------------------------------------------------------------ // // SpriteEaseBack // //------------------------------------------------------------------ KDvoid SpriteEaseBack::onEnter ( KDvoid ) { TestEaseActions::onEnter ( ); CCSize s = this->getContentSize ( ); CCActionInterval* move = CCMoveBy::create(3, ccp(s.cx-130, 0 ) ); CCActionInterval* move_back = move->reverse(); CCActionInterval* move_ease_in = CCEaseBackIn::create ( CCCA ( move ) ); CCActionInterval* move_ease_in_back = move_ease_in->reverse(); CCActionInterval* move_ease_out = CCEaseBackOut::create ( CCCA ( move ) ); CCActionInterval* move_ease_out_back = move_ease_out->reverse(); CCDelayTime *delay = CCDelayTime::create(0.25f); CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), KD_NULL); CCSequence* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), KD_NULL); CCSequence* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), KD_NULL); m_grossini->runAction(CCRepeatForever::create ( seq1 ) ); m_tamara->runAction(CCRepeatForever::create ( seq2 ) ); m_kathia->runAction(CCRepeatForever::create ( seq3 ) ); }
void GameScene::birdReadyAction() { CCSize winSize =CCDirector::sharedDirector()->getWinSize(); // 添加bird精灵 CCSprite *bird =CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("bird1.png")); bird->setPosition(ccp(winSize.width/2-80,winSize.height/2+20)); bird->setZOrder(20); bird->setScale(0.6); bird->setTag(TAG_BIRD); bird->setVisible(false); this->addChild(bird); // 创建动画对象 CCAnimation *birdAnimation =CCAnimation::create(); birdAnimation->setDelayPerUnit(0.2); birdAnimation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("bird1.png")); birdAnimation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("bird2.png")); birdAnimation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("bird3.png")); // 创建动画动作 birdanimate =CCAnimate::create(birdAnimation); CCActionInterval *action =CCMoveBy::create(0.2,ccp(0,10)); CCActionInterval *action1 =action->reverse(); CCActionInterval *sequence =CCSequence::create(action,action1,NULL); CCSpawn *spawn =CCSpawn::create(sequence,birdanimate,NULL); CCRepeatForever *birdrepeatForever =CCRepeatForever::create(spawn); // 让bird精灵一直运行动画 bird->runAction(birdrepeatForever); }
//------------------------------------------------------------------ // // StressTest2 // //------------------------------------------------------------------ StressTest2::StressTest2() { CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLayer* sublayer = CCLayer::create(); CCSprite *sp1 = CCSprite::create(s_pPathSister1); sp1->setPosition( ccp(80, s.height/2) ); CCActionInterval* move = CCMoveBy::create(3, ccp(350,0)); CCActionInterval* move_ease_inout3 = CCEaseInOut::create((CCActionInterval*)(move->copy()->autorelease()), 2.0f); CCActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse(); CCSequence* seq3 = CCSequence::create( move_ease_inout3, move_ease_inout_back3, NULL); sp1->runAction( CCRepeatForever::create(seq3) ); sublayer->addChild(sp1, 1); CCParticleFire* fire = CCParticleFire::create(); fire->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png")); fire->setPosition( ccp(80, s.height/2-50) ); CCActionInterval* copy_seq3 = (CCActionInterval*)(seq3->copy()->autorelease()); fire->runAction( CCRepeatForever::create(copy_seq3) ); sublayer->addChild(fire, 2); schedule(schedule_selector(StressTest2::shouldNotLeak), 6.0f); addChild(sublayer, 0, kTagSprite1); }
//------------------------------------------------------------------ // // Effect2 // //------------------------------------------------------------------ void Effect2::onEnter() { EffectAdvanceTextLayer::onEnter(); CCNode* target = getChildByTag(kTagBackground); // To reuse a grid the grid size and the grid type must be the same. // in this case: // ShakyTiles is TiledGrid3D and it's size is (15,10) // Shuffletiles is TiledGrid3D and it's size is (15,10) // TurnOfftiles is TiledGrid3D and it's size is (15,10) CCActionInterval* shaky = CCShakyTiles3D::actionWithRange(4, false, ccg(15,10), 5); CCActionInterval* shuffle = CCShuffleTiles::actionWithSeed(0, ccg(15,10), 3); CCActionInterval* turnoff = CCTurnOffTiles::actionWithSeed(0, ccg(15,10), 3); CCActionInterval* turnon = turnoff->reverse(); // reuse 2 times: // 1 for shuffle // 2 for turn off // turnon tiles will use a new grid CCFiniteTimeAction* reuse = CCReuseGrid::actionWithTimes(2); CCActionInterval* delay = CCDelayTime::actionWithDuration(1); // id orbit = [OrbitCamera::actionWithDuration:5 radius:1 deltaRadius:2 angleZ:0 deltaAngleZ:180 angleX:0 deltaAngleX:-90]; // id orbit_back = [orbit reverse]; // // [target runAction: [RepeatForever::actionWithAction: [Sequence actions: orbit, orbit_back, nil]]]; target->runAction( (CCActionInterval *)(CCSequence::actions( shaky, delay, reuse, shuffle, delay->copy()->autorelease(), turnoff, turnon, NULL) ) ); }
bool SplashScreen::init() { if (!CCLayer::init()) { return false; } CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCSprite *logo = CCSprite::create("logo.png"); logo->setOpacity(0); logo->setPosition(VisibleRect::center()); CCSprite *splash = CCSprite::create("splash.png"); CCSize splashSize = splash->getContentSize(); splash->setOpacity(0); splash->setPosition(VisibleRect::center()); CCActionInterval *fadeIn = CCFadeIn::create(0.5f); CCCallFunc *loadHandler = CCCallFunc::create(this, callfunc_selector(SplashScreen::__loadAssets)); CCActionInterval *delayAct = CCDelayTime::create(1.0f); CCActionInterval *fadeOut = CCFadeOut::create(0.5f); CCCallFunc *startHandler = CCCallFunc::create(this, callfunc_selector(SplashScreen::__startGame)); CCSequence *splashSeq = CCSequence::create(fadeIn,loadHandler,delayAct,fadeOut,startHandler,NULL); addChild(splash); addChild(logo); splash->setScaleX(winSize.width/splashSize.width); logo->setScale(winSize.width/splashSize.width); splash->setScaleY(winSize.height/splashSize.height); logo->runAction(splashSeq); splash->runAction((CCActionInterval*)fadeIn->copy()); return true; }
void CCTransitionRotoZoom:: onEnter() { CCTransitionScene::onEnter(); m_pInScene->setScale(0.001f); m_pOutScene->setScale(1.0f); m_pInScene->setAnchorPoint(ccp(0.5f, 0.5f)); m_pOutScene->setAnchorPoint(ccp(0.5f, 0.5f)); CCActionInterval *rotozoom = (CCActionInterval*)(CCSequence::create ( CCSpawn::create ( CCScaleBy::create(m_fDuration/2, 0.001f), CCRotateBy::create(m_fDuration/2, 360 * 2), NULL ), CCDelayTime::create(m_fDuration/2), NULL )); m_pOutScene->runAction(rotozoom); m_pInScene->runAction ( CCSequence::create ( rotozoom->reverse(), CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), NULL ) ); }
CCActionInterval* CCActionInterval::create(float d){ CCActionInterval *pAction = new CCActionInterval(); pAction->initWithDuration(d); // pAction->autorelease(); return pAction; }
//------------------------------------------------------------------ // // NodeToWorld // //------------------------------------------------------------------ NodeToWorld::NodeToWorld() { // // This code tests that nodeToParent works OK: // - It tests different anchor Points // - It tests different children anchor points CCSprite *back = CCSprite::spriteWithFile(s_back3); addChild( back, -10); back->setAnchorPoint( CCPointMake(0,0) ); CCSize backSize = back->getContentSize(); CCMenuItem *item = CCMenuItemImage::itemFromNormalImage(s_PlayNormal, s_PlaySelect); CCMenu *menu = CCMenu::menuWithItems(item, NULL); menu->alignItemsVertically(); menu->setPosition( CCPointMake(backSize.width/2, backSize.height/2)); back->addChild(menu); CCActionInterval* rot = CCRotateBy::actionWithDuration(5, 360); CCAction* fe = CCRepeatForever::actionWithAction( rot); item->runAction( fe ); CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(200,0)); CCActionInterval* move_back = move->reverse(); CCFiniteTimeAction* seq = CCSequence::actions( move, move_back, NULL); CCAction* fe2 = CCRepeatForever::actionWithAction((CCActionInterval*)seq); back->runAction(fe2); }
void ParticleComponentTest::defaultPlay() { CCComRender* Particle = static_cast<CCComRender*>(m_rootNode->getChildByTag(10020)->getComponent("CCParticleSystemQuad")); CCActionInterval* jump = CCJumpBy::create(5, ccp(-500,0), 50, 4); CCFiniteTimeAction* action = CCSequence::create( jump, jump->reverse(), NULL); Particle->getNode()->runAction(action); }
void SpriteEaseBack::onEnter() { EaseSpriteDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCActionInterval* move = CCMoveBy::create(3, CCPointMake(s.width-130, 0)); CCActionInterval* move_back = move->reverse(); CCActionInterval* move_ease_in = CCEaseBackIn::create((CCActionInterval*)(move->copy()->autorelease())); CCActionInterval* move_ease_in_back = move_ease_in->reverse(); CCActionInterval* move_ease_out = CCEaseBackOut::create((CCActionInterval*)(move->copy()->autorelease())); CCActionInterval* move_ease_out_back = move_ease_out->reverse(); CCDelayTime *delay = CCDelayTime::create(0.25f); CCFiniteTimeAction* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL); CCFiniteTimeAction* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL); CCFiniteTimeAction* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL); m_grossini->runAction(CCRepeatForever::create((CCActionInterval*)seq1)); m_tamara->runAction(CCRepeatForever::create((CCActionInterval*)seq2)); m_kathia->runAction(CCRepeatForever::create((CCActionInterval*)seq3)); }
//------------------------------------------------------------------ // // NodeToWorld // //------------------------------------------------------------------ NodeToWorld::NodeToWorld() { // // This code tests that nodeToParent works OK: // - It tests different anchor Points // - It tests different children anchor points CCSprite *back = CCSprite::create(s_back3); addChild( back, -10); back->setAnchorPoint( ccp(0,0) ); CCSize backSize = back->getContentSize(); CCMenuItem *item = CCMenuItemImage::create(s_PlayNormal, s_PlaySelect); CCMenu *menu = CCMenu::create(item, NULL); menu->alignItemsVertically(); menu->setPosition( ccp(backSize.width/2, backSize.height/2)); back->addChild(menu); CCActionInterval* rot = CCRotateBy::create(5, 360); CCAction* fe = CCRepeatForever::create( rot); item->runAction( fe ); CCActionInterval* move = CCMoveBy::create(3, ccp(200,0)); CCActionInterval* move_back = move->reverse(); CCSequence* seq = CCSequence::create( move, move_back, NULL); CCAction* fe2 = CCRepeatForever::create(seq); back->runAction(fe2); }
void SpriteEaseInOut::onEnter() { EaseSpriteDemo::onEnter(); CCActionInterval* move = CCMoveBy::create(3, ccp(VisibleRect::right().x-130,0)); // id move_back = move->reverse(); CCActionInterval* move_ease_inout1 = CCEaseInOut::create((CCActionInterval*)(move->copy()->autorelease()), 0.65f); CCActionInterval* move_ease_inout_back1 = move_ease_inout1->reverse(); CCActionInterval* move_ease_inout2 = CCEaseInOut::create((CCActionInterval*)(move->copy()->autorelease()), 1.35f); CCActionInterval* move_ease_inout_back2 = move_ease_inout2->reverse(); CCActionInterval* move_ease_inout3 = CCEaseInOut::create((CCActionInterval*)(move->copy()->autorelease()), 1.0f); CCActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse(); CCDelayTime *delay = CCDelayTime::create(0.25f); CCSequence* seq1 = CCSequence::create( move_ease_inout1, delay, move_ease_inout_back1, CCCA(delay), NULL); CCSequence* seq2 = CCSequence::create( move_ease_inout2, CCCA(delay), move_ease_inout_back2, CCCA(delay), NULL); CCSequence* seq3 = CCSequence::create( move_ease_inout3, CCCA(delay), move_ease_inout_back3, CCCA(delay), NULL); m_tamara->runAction(CCRepeatForever::create(seq1)); m_kathia->runAction(CCRepeatForever::create(seq2)); m_grossini->runAction(CCRepeatForever::create(seq3)); }
//------------------------------------------------------------------ // // Test6 // //------------------------------------------------------------------ Test6::Test6() { CCSprite* sp1 = CCSprite::create(s_pPathSister1); CCSprite* sp11 = CCSprite::create(s_pPathSister1); CCSprite* sp2 = CCSprite::create(s_pPathSister2); CCSprite* sp21 = CCSprite::create(s_pPathSister2); sp1->setPosition(ccp(100,160)); sp2->setPosition(ccp(380,160)); CCActionInterval* rot = CCRotateBy::create(2, 360); CCActionInterval* rot_back = rot->reverse(); CCAction* forever1 = CCRepeatForever::create(CCSequence::create(rot, rot_back, NULL)); CCAction* forever11 = (CCAction*)(forever1->copy()->autorelease()); CCAction* forever2 = (CCAction*)(forever1->copy()->autorelease()); CCAction* forever21 = (CCAction*)(forever1->copy()->autorelease()); addChild(sp1, 0, kTagSprite1); sp1->addChild(sp11); addChild(sp2, 0, kTagSprite2); sp2->addChild(sp21); sp1->runAction(forever1); sp11->runAction(forever11); sp2->runAction(forever2); sp21->runAction(forever21); schedule( schedule_selector(Test6::addAScutRemove), 2.0f); }
//------------------------------------------------------------------ // // LayerTest2 // //------------------------------------------------------------------ void LayerTest2::onEnter() { LayerTest::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLayerColor* layer1 = CCLayerColor::layerWithColorWidthHeight( ccc4(255, 255, 0, 80), 100, 300); layer1->setPosition(CCPointMake(s.width/3, s.height/2)); layer1->setIsRelativeAnchorPoint(true); addChild(layer1, 1); CCLayerColor* layer2 = CCLayerColor::layerWithColorWidthHeight( ccc4(0, 0, 255, 255), 100, 300); layer2->setPosition(CCPointMake((s.width/3)*2, s.height/2)); layer2->setIsRelativeAnchorPoint(true); addChild(layer2, 1); CCActionInterval* actionTint = CCTintBy::actionWithDuration(2, -255, -127, 0); CCActionInterval* actionTintBack = actionTint->reverse(); CCActionInterval* seq1 = (CCActionInterval*)CCSequence::actions( actionTint, actionTintBack, NULL); layer1->runAction(seq1); CCActionInterval* actionFade = CCFadeOut::actionWithDuration(2.0f); CCActionInterval* actionFadeBack = actionFade->reverse(); CCActionInterval* seq2 = (CCActionInterval*)CCSequence::actions(actionFade, actionFadeBack, NULL); layer2->runAction(seq2); }
//------------------------------------------------------------------ // // ParallaxParticle // //------------------------------------------------------------------ void ParallaxParticle::onEnter() { ParticleDemo::onEnter(); m_background->getParent()->removeChild(m_background, true); m_background = NULL; CCParallaxNode* p = CCParallaxNode::node(); addChild(p, 5); CCSprite *p1 = CCSprite::spriteWithFile(s_back3); CCSprite *p2 = CCSprite::spriteWithFile(s_back3); p->addChild( p1, 1, CGPointMake(0.5f,1), CGPointMake(0,250) ); p->addChild(p2, 2, CGPointMake(1.5f,1), CGPointMake(0,50) ); m_emitter = CCParticleFlower::node(); m_emitter->retain(); m_emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage(s_fire) ); p1->addChild(m_emitter, 10); m_emitter->setPosition( CGPointMake(250,200) ); CCParticleSun* par = CCParticleSun::node(); p2->addChild(par, 10); par->setTexture( CCTextureCache::sharedTextureCache()->addImage(s_fire) ); CCActionInterval* move = CCMoveBy::actionWithDuration(4, CGPointMake(300,0)); CCActionInterval* move_back = move->reverse(); CCFiniteTimeAction* seq = CCSequence::actions( move, move_back, NULL); p->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq)); }
void SpriteEase::onEnter() { EaseSpriteDemo::onEnter(); CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0) ); CCActionInterval* move_back = move->reverse(); CCActionInterval* move_ease_in = (CCActionInterval*)CCEaseIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 3.0f); CCActionInterval* move_ease_in_back = move_ease_in->reverse(); CCActionInterval* move_ease_out = CCEaseOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 3.0f); CCActionInterval* move_ease_out_back = move_ease_out->reverse(); CCFiniteTimeAction* seq1 = CCSequence::actions(move, move_back, NULL); CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_in, move_ease_in_back, NULL); CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_out, move_ease_out_back, NULL); CCAction *a2 = m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1) ); a2->setTag(1); CCAction *a1 = m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2) ); a1->setTag(1); CCAction *a = m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3) ); a->setTag(1); schedule(schedule_selector(SpriteEase::testStopAction), 6); }
void SpriteEaseInOut::onEnter() { EaseSpriteDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCActionInterval* move = CCMoveBy::create(3, CCPointMake(s.width-130,0)); // id move_back = move->reverse(); CCActionInterval* move_ease_inout1 = CCEaseInOut::create((CCActionInterval*)(move->copy()->autorelease()), 0.65f); CCActionInterval* move_ease_inout_back1 = move_ease_inout1->reverse(); CCActionInterval* move_ease_inout2 = CCEaseInOut::create((CCActionInterval*)(move->copy()->autorelease()), 1.35f); CCActionInterval* move_ease_inout_back2 = move_ease_inout2->reverse(); CCActionInterval* move_ease_inout3 = CCEaseInOut::create((CCActionInterval*)(move->copy()->autorelease()), 1.0f); CCActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse(); CCDelayTime *delay = CCDelayTime::create(0.25f); CCFiniteTimeAction* seq1 = CCSequence::create( move_ease_inout1, delay, move_ease_inout_back1, CCCA(delay), NULL); CCFiniteTimeAction* seq2 = CCSequence::create( move_ease_inout2, CCCA(delay), move_ease_inout_back2, CCCA(delay), NULL); CCFiniteTimeAction* seq3 = CCSequence::create( move_ease_inout3, CCCA(delay), move_ease_inout_back3, CCCA(delay), NULL); m_tamara->runAction(CCRepeatForever::create((CCActionInterval*)seq1)); m_kathia->runAction(CCRepeatForever::create((CCActionInterval*)seq2)); m_grossini->runAction(CCRepeatForever::create((CCActionInterval*)seq3)); }
void MapScene::reduceLife(int num) { (player->getsprite())->stopAllActions(); /*switch(playerlife){ case 3: life1->setIsVisible(false); playerlife --; break; case 2: life2->setIsVisible(false); playerlife --; break; case 1: life3->setIsVisible(false); playerlife --; break; }*/ if(player->life-num == 5) { } CCActionInterval* action = CCRotateBy::actionWithDuration(0.05, 15); (player->getsprite())->runAction(CCSequence::actions(action, action->reverse(), NULL)); //这里还需要加入对frozen状态的判断此时不无敌,即reduce=false; //schedule(schedule_selector(MapScene::resetreduce), 0.2f); //isreduce = true; }
void CCTransitionSplitCols::onEnter() { CCTransitionScene::onEnter(); m_pInScene->setVisible(false); CCActionInterval* split = action(); CCActionInterval* seq = (CCActionInterval*)CCSequence::create ( split, CCCallFunc::create(this, callfunc_selector(CCTransitionScene::hideOutShowIn)), split->reverse(), NULL ); this->runAction ( CCSequence::create ( easeActionWithAction(seq), CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), CCStopGrid::create(), NULL ) ); }
void SpriteEase::onEnter() { EaseSpriteDemo::onEnter(); CCActionInterval* move = CCMoveBy::create(3, ccp(VisibleRect::right().x-130,0)); CCActionInterval* move_back = move->reverse(); CCActionInterval* move_ease_in = CCEaseIn::create((CCActionInterval*)(move->copy()->autorelease()), 2.5f); CCActionInterval* move_ease_in_back = move_ease_in->reverse(); CCActionInterval* move_ease_out = CCEaseOut::create((CCActionInterval*)(move->copy()->autorelease()), 2.5f); CCActionInterval* move_ease_out_back = move_ease_out->reverse(); CCDelayTime *delay = CCDelayTime::create(0.25f); CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL); CCSequence* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL); CCSequence* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL); CCAction *a2 = m_grossini->runAction(CCRepeatForever::create(seq1)); a2->setTag(1); CCAction *a1 = m_tamara->runAction(CCRepeatForever::create(seq2)); a1->setTag(1); CCAction *a = m_kathia->runAction(CCRepeatForever::create(seq3)); a->setTag(1); schedule(schedule_selector(SpriteEase::testStopAction), 6.25f); }
//------------------------------------------------------------------ // // Test6 // //------------------------------------------------------------------ Test6::Test6() { CCSprite* sp1 = CCSprite::spriteWithFile(s_pPathSister1); CCSprite* sp11 = CCSprite::spriteWithFile(s_pPathSister1); CCSprite* sp2 = CCSprite::spriteWithFile(s_pPathSister2); CCSprite* sp21 = CCSprite::spriteWithFile(s_pPathSister2); sp1->setPosition(CCPointMake(100,160)); sp2->setPosition(CCPointMake(380,160)); CCActionInterval* rot = CCRotateBy::actionWithDuration(2, 360); CCActionInterval* rot_back = rot->reverse(); CCAction* forever1 = CCRepeatForever::actionWithAction( (CCActionInterval*)(CCSequence::actions(rot, rot_back, NULL))); CCAction* forever11 = (CCAction*)(forever1->copy()->autorelease()); CCAction* forever2 = (CCAction*)(forever1->copy()->autorelease()); CCAction* forever21 = (CCAction*)(forever1->copy()->autorelease()); addChild(sp1, 0, kTagSprite1); sp1->addChild(sp11); addChild(sp2, 0, kTagSprite2); sp2->addChild(sp21); sp1->runAction(forever1); sp11->runAction(forever11); sp2->runAction(forever2); sp21->runAction(forever21); schedule( schedule_selector(Test6::addAndRemove), 2.0f); }
CCObject* CCActionInterval::copyWithZone(CCZone *pZone) { CCZone* pNewZone = NULL; CCActionInterval* pCopy = NULL; if(pZone && pZone->m_pCopyObject) { //in case of being called at sub class pCopy = (CCActionInterval*)(pZone->m_pCopyObject); } else { // action's base class , must be called using __super::copyWithZone(), after overriding from derived class CCAssert(0, ""); pCopy = new CCActionInterval(); pZone = pNewZone = new CCZone(pCopy); } CCFiniteTimeAction::copyWithZone(pZone); CC_SAFE_DELETE(pNewZone); pCopy->initWithDuration(m_fDuration); return pCopy; }
void SpriteEaseSine::onEnter() { EaseSpriteDemo::onEnter(); CCActionInterval* move = CCMoveBy::create(3, ccp(VisibleRect::right().x-130, 0)); CCActionInterval* move_back = move->reverse(); CCActionInterval* move_ease_in = CCEaseSineIn::create((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_in_back = move_ease_in->reverse(); CCActionInterval* move_ease_out = CCEaseSineOut::create((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_out_back = move_ease_out->reverse(); CCDelayTime *delay = CCDelayTime::create(0.25f); CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL); CCSequence* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL); CCSequence* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL); m_grossini->runAction( CCRepeatForever::create(seq1)); m_tamara->runAction( CCRepeatForever::create(seq2)); m_kathia->runAction( CCRepeatForever::create(seq3)); }
// // IntervalAction // CCActionInterval* CCActionInterval::actionWithDuration(ccTime d) { CCActionInterval *pAction = new CCActionInterval(); pAction->initWithDuration(d); pAction->autorelease(); return pAction; }
void FairyControlPanel::setVisiable(){ if(!isDoClick){ CCActionInterval * moveBy = CCMoveBy::create(0.3f,ccp(0, -panelBack->getContentSize().height - 30)); panelBack->runAction(CCSequence::create(moveBy->reverse(), CCCallFuncN::create(this,callfuncN_selector(FairyControlPanel::finishDoClick)),NULL)); } }
void BaseBug::byPress(){ m_bug->setScale(1.0f); CCActionInterval* action = CCScaleBy::create(0.05f, 0.9f); CCActionInterval* actionReverse = action->reverse(); CCFiniteTimeAction* finiteAction = CCSequence::create(action, actionReverse,NULL); m_bug->runAction(finiteAction); CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("press.mp3"); showFlower(); }
Parallax1::Parallax1() { // Top Layer, a simple image CCSprite* cocosImage = CCSprite::spriteWithFile(s_Power); // scale the image (optional) cocosImage->setScale( 2.5f ); // change the transform anchor point to 0,0 (optional) cocosImage->setAnchorPoint( ccp(0,0) ); // Middle layer: a Tile map atlas CCTileMapAtlas *tilemap = CCTileMapAtlas::tileMapAtlasWithTileFile(s_TilesPng, s_LevelMapTga, 16, 16); tilemap->releaseMap(); // change the transform anchor to 0,0 (optional) tilemap->setAnchorPoint( ccp(0, 0) ); // Anti Aliased images tilemap->getTexture()->setAntiAliasTexParameters(); // background layer: another image CCSprite* background = CCSprite::spriteWithFile(s_back); // scale the image (optional) background->setScale( 1.5f ); // change the transform anchor point (optional) background->setAnchorPoint( ccp(0,0) ); // create a void node, a parent node CCParallaxNode* voidNode = CCParallaxNode::node(); // NOW add the 3 layers to the 'void' node // background image is moved at a ratio of 0.4x, 0.5y voidNode->addChild(background, -1, ccp(0.4f,0.5f), CCPointZero); // tiles are moved at a ratio of 2.2x, 1.0y voidNode->addChild(tilemap, 1, ccp(2.2f,1.0f), ccp(0,-200) ); // top image is moved at a ratio of 3.0x, 2.5y voidNode->addChild(cocosImage, 2, ccp(3.0f,2.5f), ccp(200,800) ); // now create some actions that will move the 'void' node // and the children of the 'void' node will move at different // speed, thus, simulation the 3D environment CCActionInterval* goUp = CCMoveBy::actionWithDuration(4, ccp(0,-500) ); CCActionInterval* goDown = goUp->reverse(); CCActionInterval* go = CCMoveBy::actionWithDuration(8, ccp(-1000,0) ); CCActionInterval* goBack = go->reverse(); CCFiniteTimeAction* seq = CCSequence::actions(goUp, go, goDown, goBack, NULL); voidNode->runAction( (CCRepeatForever::actionWithAction((CCActionInterval*) seq) )); addChild( voidNode ); }
ParticleDemo::ParticleDemo(void) { initWithColor( ccc4(127,127,127,255) ); m_emitter = NULL; setIsTouchEnabled( true ); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 28); addChild(label, 100, 1000); label->setPosition( CCPointMake(s.width/2, s.height-50) ); CCLabelTTF *tapScreen = CCLabelTTF::labelWithString("(Tap the Screen)", "Arial", 20); tapScreen->setPosition( CCPointMake(s.width/2, s.height-80) ); addChild(tapScreen, 100); CCMenuItemImage* item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(ParticleDemo::backCallback) ); CCMenuItemImage* item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(ParticleDemo::restartCallback) ); CCMenuItemImage* item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(ParticleDemo::nextCallback) ); CCMenuItemToggle* item4 = CCMenuItemToggle::itemWithTarget( this, menu_selector(ParticleDemo::toggleCallback), CCMenuItemFont::itemFromString( "Free Movement" ), CCMenuItemFont::itemFromString( "Relative Movement" ), CCMenuItemFont::itemFromString( "Grouped Movement" ), NULL ); CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, item4, NULL); menu->setPosition( CCPointZero ); item1->setPosition( CCPointMake( s.width/2 - 100,30) ); item2->setPosition( CCPointMake( s.width/2, 30) ); item3->setPosition( CCPointMake( s.width/2 + 100,30) ); item4->setPosition( CCPointMake( 0, 100) ); item4->setAnchorPoint( CCPointMake(0,0) ); addChild( menu, 100 ); CCLabelAtlas* labelAtlas = CCLabelAtlas::labelWithString("0000", "fonts/fps_images.png", 16, 24, '.'); addChild(labelAtlas, 100, kTagLabelAtlas); labelAtlas->setPosition( CCPointMake(s.width-66,50) ); // moving background m_background = CCSprite::spriteWithFile(s_back3); addChild(m_background, 5); m_background->setPosition( CCPointMake(s.width/2, s.height-180) ); CCActionInterval* move = CCMoveBy::actionWithDuration(4, CCPointMake(300,0) ); CCActionInterval* move_back = move->reverse(); CCFiniteTimeAction* seq = CCSequence::actions( move, move_back, NULL); m_background->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq) ); schedule( schedule_selector(ParticleDemo::step) ); }