void LevelManager::repeatAction(CCNode* psender) { CCDelayTime* delay = CCDelayTime::create(1); CCMoveBy* mv = CCMoveBy::create(1,ccp(100+100*CCRANDOM_0_1(),0)); CCFiniteTimeAction* seq = CCSequence::create(delay,mv,delay->copy(), mv->reverse(), NULL); psender->runAction(CCRepeatForever::create((CCActionInterval*)seq)); }
// // DelayTime // CCDelayTime* CCDelayTime::actionWithDuration(ccTime d) { CCDelayTime* pAction = new CCDelayTime(); pAction->initWithDuration(d); pAction->autorelease(); return pAction; }
// // DelayTime // CCDelayTime* CCDelayTime::create(float d) { CCDelayTime* pAction = new CCDelayTime(); pAction->initWithDuration(d); pAction->autorelease(); return pAction; }
void TestController::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent) { stopAllActions(); CCDelayTime* delaytime = CCDelayTime::actionWithDuration(0.2); delaytime->setTag(99); this->runAction(delaytime); CCSetIterator it = pTouches->begin(); CCTouch* touch = (CCTouch*)(*it); m_tBeginPos = touch->locationInView(touch->view()); }
bool Boss::init(){ if ( !CCSprite::init() ) { return false; } this->initWithFile(s_boss_one); m_bomb = new Enemy(); m_bomb->autorelease(); m_bomb->initWithFile(s_boss_one_bomb); addChild(m_bomb,1); CCSize size = this->getContentSize(); m_bomb->setAnchorPoint(ccp(0.5,0.8)); m_bomb->setPosition(ccp(size.width/2,size.height/2)); CCDelayTime *delay = CCDelayTime::create(1); CCMoveBy *mv = CCMoveBy::create(6, ccp(300, 0)); CCFiniteTimeAction *seq = CCSequence::create(delay, mv, delay->copy(), mv->reverse(), NULL); this->runAction(CCRepeatForever::create((CCActionInterval*)seq)); this->schedule(schedule_selector(Boss::calRoat),1); childrenInit(); }