void SpeedTest::onEnter() { EaseSpriteDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); // rotate and jump CCActionInterval *jump1 = CCJumpBy::create(4, ccp(-s.width+80, 0), 100, 4); CCActionInterval *jump2 = jump1->reverse(); CCActionInterval *rot1 = CCRotateBy::create(4, 360*2); CCActionInterval *rot2 = rot1->reverse(); CCSequence* seq3_1 = CCSequence::create(jump2, jump1, NULL); CCSequence* seq3_2 = CCSequence::create( rot1, rot2, NULL); CCSpawn* spawn = CCSpawn::create(seq3_1, seq3_2, NULL); CCSpeed* action = CCSpeed::create(CCRepeatForever::create(spawn), 1.0f); action->setTag(kTagAction1); CCAction* action2 = (CCAction*)(action->copy()->autorelease()); CCAction* action3 = (CCAction*)(action->copy()->autorelease()); action2->setTag(kTagAction1); action3->setTag(kTagAction1); m_grossini->runAction(action2); m_tamara->runAction(action3); m_kathia->runAction(action); this->schedule(schedule_selector(SpeedTest::altertime), 1.0f);//:@selector(altertime:) interval:1.0f]; }
void SpeedTest::onEnter() { EaseSpriteDemo::onEnter(); // rotate and jump CCActionInterval *jump1 = CCJumpBy::actionWithDuration(4, CCPointMake(-400,0), 100, 4); CCActionInterval *jump2 = jump1->reverse(); CCActionInterval *rot1 = CCRotateBy::actionWithDuration(4, 360*2); CCActionInterval *rot2 = rot1->reverse(); CCFiniteTimeAction* seq3_1 = CCSequence::actions(jump2, jump1, NULL); CCFiniteTimeAction* seq3_2 = CCSequence::actions( rot1, rot2, NULL); CCFiniteTimeAction* spawn = CCSpawn::actions(seq3_1, seq3_2, NULL); CCSpeed* action = CCSpeed::actionWithAction(CCRepeatForever::actionWithAction((CCActionInterval*)spawn), 1.0f); action->setTag(kTagAction1); CCAction* action2 = (CCAction*)(action->copy()->autorelease()); CCAction* action3 = (CCAction*)(action->copy()->autorelease()); action2->setTag(kTagAction1); action3->setTag(kTagAction1); m_grossini->runAction( action2 ); m_tamara->runAction( action3 ); m_kathia->runAction( action ); this->schedule(schedule_selector(SpeedTest::altertime), 1.0f);//:@selector(altertime:) interval:1.0f]; }
KDvoid SpeedTest::onEnter ( KDvoid ) { TestEaseActions::onEnter ( ); CCSize s = this->getContentSize ( ); // rotate and jump CCActionInterval *jump1 = CCJumpBy::create(4, ccp(-s.cx+80, 0), 100, 4); CCActionInterval *jump2 = jump1->reverse(); CCActionInterval *rot1 = CCRotateBy::create(4, 360*2); CCActionInterval *rot2 = rot1->reverse(); CCSequence* seq3_1 = CCSequence::create(jump2, jump1, KD_NULL); CCSequence* seq3_2 = CCSequence::create( rot1, rot2, KD_NULL); CCSpawn* spawn = CCSpawn::create(seq3_1, seq3_2, KD_NULL); CCSpeed* action = CCSpeed::create(CCRepeatForever::create ( spawn), 1.0f); action->setTag(kTagAction1); CCAction* action2 = (CCAction*)(action->copy()->autorelease( ) ); CCAction* action3 = (CCAction*)(action->copy()->autorelease( ) ); action2->setTag(kTagAction1); action3->setTag(kTagAction1); m_grossini->runAction(action2); m_tamara->runAction(action3); m_kathia->runAction(action); this->schedule(schedule_selector(SpeedTest::altertime), 1.0f); }
CCSpeed* CCSpeed::create(CCActionInterval* pAction, float fSpeed) { CCSpeed *pRet = new CCSpeed(); if (pRet && pRet->initWithAction(pAction, fSpeed)) { pRet->autorelease(); return pRet; } CC_SAFE_DELETE(pRet); return NULL; }
CCSpeed * CCSpeed::actionWithAction(CCActionInterval *pAction, float fRate) { CCSpeed *pRet = new CCSpeed(); if (pRet && pRet->initWithAction(pAction, fRate)) { pRet->autorelease(); return pRet; } CCX_SAFE_DELETE(pRet) return NULL; }
CCObject *CCSpeed::copyWithZone(CCZone *pZone) { CCZone* pNewZone = NULL; CCSpeed* pRet = NULL; if(pZone && pZone->m_pCopyObject) //in case of being called at sub class 子类调用 { pRet = (CCSpeed*)(pZone->m_pCopyObject); } else { pRet = new CCSpeed(); pZone = pNewZone = new CCZone(pRet); } CCAction::copyWithZone(pZone); pRet->initWithAction( (CCActionInterval*)(m_pInnerAction->copy()->autorelease()) , m_fSpeed ); CC_SAFE_DELETE(pNewZone); return pRet; }