void AutoAttackComponent::stopAttack() { CCLOG("AutoAttackComponent::stopAttack"); CCDirector* director = CCDirector::sharedDirector(); CCScheduler* pScheduler = director->getScheduler(); pScheduler->unscheduleSelector(schedule_selector(AutoAttackComponent::updateAttack),this); }
void HeartBeatPackageSender::EndSender() { CCScheduler * pSchedule = CCDirector::sharedDirector()->getScheduler(); if (pSchedule) { pSchedule->unscheduleSelector(schedule_selector(HeartBeatPackageSender::SendHeartBeatMessage), this); } }
/** * 开始移动 * 设置移动动画的定时器 */ void SimpleMoveComponent::startMove() { CCLOG("startMove"); m_moveState=MoveStart; CCDirector* director = CCDirector::sharedDirector(); CCScheduler* pScheduler = director->getScheduler(); pScheduler->scheduleSelector(m_update,this, 0, false); didMoveStart(); }
void AutoAttackComponent::attack() { CCLOG("AutoAttackComponent::startAttack"); if (m_target) { CCDirector* director = CCDirector::sharedDirector(); CCScheduler* pScheduler = director->getScheduler(); pScheduler->scheduleSelector(schedule_selector(AutoAttackComponent::updateAttack),this, m_attackSpeed, false); } }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. TargetPlatform target = getTargetPlatform();//获取当前设备类型 if (target == kTargetIpad){//如果是Ipad if (pDirector->enableRetinaDisplay(true)){ //如果开启高清视网膜 }else { } } else if (target == kTargetIphone) {//如果是iphone if (pDirector->enableRetinaDisplay(true)) { } else { } } else if (target == kTargetAndroid)//如果是android { } else if (target == kTargetWindows)//如果是Windows { } else if (target == kTargetMacOS)//如果是MacOS { } // turn on display FPS pDirector->setDisplayStats(false); // set FPS. the default value is 1.0/60 if you don't call thisdf pDirector->setAnimationInterval(1.0 / 60); // game init CCScheduler * scheduler = CCDirector::sharedDirector()->getScheduler(); scheduler->scheduleSelector(schedule_selector(AppDelegate::AppUpdate), this, 1.0f/60, false); if( GameControl::RunGameControl() ) { NetMessageManager::GetMessageManager(); } if( SceneManage::GetSceneManageHendle() ) { SceneManage::GetSceneManageHendle()->RunScece( SCENE_LOGIN, false ); } return true; }
void HeartBeatPackageSender::StartSender() { CCScheduler * pSchedule = CCDirector::sharedDirector()->getScheduler(); if (pSchedule) { pSchedule->scheduleSelector(schedule_selector(HeartBeatPackageSender::SendHeartBeatMessage), this, messageSenderDeltaTimer, false); } }
NDTimer::~NDTimer() { DEC_NDOBJ("NDTimer"); CCScheduler *sch = GetScheduler(); MAP_TIMER::iterator it = m_mapTimer.begin(); for (; it != m_mapTimer.end(); it++) { Timer *timer = it->second; sch->unscheduleSelector(schedule_selector(Timer::onTimer), timer); timer->release(); } }
CCUDPSocketHub::~CCUDPSocketHub() { CCScheduler* s = CCDirector::sharedDirector()->getScheduler(); s->unscheduleUpdateForTarget(this); for (CCUDPSocketList::iterator iter = m_lstSocket.begin(); iter != m_lstSocket.end(); ++iter) { int tag = (*iter)->getTag(); CC_SAFE_RELEASE(*iter); CCUDPSocketListener* l = getListener(tag); if(l) { l->onUDPSocketClosed(tag); } } }
/** * 停止移动 * 取消移动动画的定时器 */ void SimpleMoveComponent::stopMove() { // if(m_moveState==MoveStart){ // m_moveState=MoveWillStop; // }else { CCDirector* director = CCDirector::sharedDirector(); CCScheduler* pScheduler = director->getScheduler(); pScheduler->unscheduleSelector(m_update, this); m_moveState=MoveStop; //NSLog(@"stop entity move schedule:update"); didMoveStop(); // } }
void MyCCOjbectImpl::RemoveUnusedRes(float fDelay) { if (fDelay <= 0) { this->RemoveUnusedResImm(0); return; } CCScheduler* pScheduler = CCDirector::sharedDirector()->getScheduler(); if (NULL == pScheduler) { return; } pScheduler->scheduleSelector(schedule_selector(MyCCOjbectImpl::RemoveUnusedResImm), this, 0, 0, fDelay, false); }
void NDTimer::KillTimer(ITimerCallback* timerCallback, OBJID tag) { IMP_CALLBACK cbImp; cbImp.tag = tag; cbImp.timerCallback = timerCallback; MAP_TIMER::iterator it = m_mapTimer.find(cbImp); if (it != m_mapTimer.end()) { CCScheduler *sch = GetScheduler(); Timer *timer = it->second; sch->unscheduleSelector(schedule_selector(Timer::onTimer), timer); timer->release(); m_mapTimer.erase(it); } }
void CCResourceLoader::doLoad(float delta) { if(m_remainingIdle > 0) { m_remainingIdle -= delta; } else if(m_loadTaskList.size() <= m_nextLoad) { if(m_listener) m_listener->onResourceLoadingDone(); CCScheduler* scheduler = CCDirector::sharedDirector()->getScheduler(); scheduler->unscheduleSelector(schedule_selector(CCResourceLoader::doLoad), this); autorelease(); } else { LoadTask* lp = m_loadTaskList.at(m_nextLoad++); m_remainingIdle = lp->idle; lp->load(); if(m_listener) m_listener->onResourceLoadingProgress(m_nextLoad * 100 / m_loadTaskList.size()); } }
void NDTimer::SetTimer(ITimerCallback* timerCallback, OBJID tag, float interval) { if (timerCallback && interval > 0) { IMP_CALLBACK cbImp; cbImp.tag = tag; cbImp.timerCallback = timerCallback; if (m_mapTimer.count(cbImp) <= 0) { CCScheduler *sch = GetScheduler(); Timer *timer = new Timer; timer->setTag(tag); timer->setTimerCallback(timerCallback); sch->scheduleSelector(schedule_selector(Timer::onTimer), timer, interval, false); m_mapTimer[cbImp] = timer; } } }
void CCResourceLoader::run() { CCScheduler* scheduler = CCDirector::sharedDirector()->getScheduler(); scheduler->scheduleSelector(schedule_selector(CCResourceLoader::doLoad), this, 0, kCCRepeatForever, m_delay, false); }
void HelloWorld::BeginContact(b2Contact *contact){ B2Sprite *p = (B2Sprite *)contact->GetFixtureA()->GetBody()->GetUserData(); if(p->getTag()==SPRITE_TAG_GROUND) { CCDirector::sharedDirector()->getScheduler()->setTimeScale(1.f); //mBird->setRotation(-90.f); //CCMessageBox("Game Over!", "Game Over!"); //mBird->setVisible(false); this->runAction(CCShake::create(1,5)); //std::string fullPath; //#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) //fullPath = CCFileUtils::sharedFileUtils()->getWritablePath(); //fullPath += "score.abc"; //unsigned long size; //unsigned char *str = CCFileUtils::sharedFileUtils()->getFileData(fullPath,"wt+",&size); m_bnew=false; string filedata; filedata = TDInvFileUtils::getFileByName("score.abc"); int filescore = 0; if (filedata != "") { filescore = atoi(filedata.c_str()); if (filescore < testnum) { m_bnew=true; m_bestscore = testnum; char str[10]; char temp[256]; sprintf(str,"%d",testnum); TDInvFileUtils::saveFile(str,"score.abc"); } else { m_bestscore = filescore; } } else { m_bestscore = testnum; char str[10]; sprintf(str,"%d",testnum); TDInvFileUtils::saveFile(str,"score.abc"); } //#else //#endif //Sleep(1000); if(!m_bhitbar) { // EFFECT_PLAY(true,MUSIC_HIT); } else { // EFFECT_PLAY(true,MUSIC_DIE); } stopGame(); } if(p == mBird || p == mBird){ CCScheduler* pScheduler = CCDirector::sharedDirector()->getScheduler(); pScheduler->setTimeScale(0.f);//实现减速效果 //scheduleOnce(schedule_selector(HelloWorld::ResumeSpeed), 1); long now=millisecondNow(); while(false){ if((millisecondNow()-now)>1000) { break; } }; CCDirector::sharedDirector()->getScheduler()->setTimeScale(1.f); //CCDirector::sharedDirector()->getScheduler()->setTimeScale(0.2f); //mBird->getB2Body()->SetLinearVelocity(b2Vec2(0, -5)); myflag=1; b2Filter myfilter; myfilter.maskBits=0x0002; mBird->getB2Body()->GetFixtureList()->SetFilterData(myfilter); m_istatus=GAMEOVER; m_bhitbar=true; // EFFECT_PLAY(true,MUSIC_HIT); //stopGame(); // CCMessageBox("Game Over!", "Game Over!"); } }