//汉字掉落状态捕捉函数,当新汉字掉落完,并清除出新汉字盒子时,掉落完毕 void ChrsGrid::onChrsDropping(float dt) { //如果新汉字都掉落完,停止该捕捉函数,并恢复触摸 if (m_NewChrs.empty()) { unschedule(schedule_selector(ChrsGrid::onChrsDropping)); //判断是否是死图 while (isDeadMap()) { //这里稍后做一个更新的算法 //1.根据布局大小创建出汉字阵列 //2.布局坐标以左下角为原点,x右y上为正方向 for (int x = 0; x < m_col; x++) { for (int y = 0; y < m_row; y++) { m_ChrsBox[x][y]->removeFromParent(); m_ChrsBox[x][y] = createAChr(x, y); } } } //游戏步数减去1,并加分 auto gamescene = getGameScene(); int cur_step = gamescene->subStep(); int cur_score = gamescene->addScore(m_bonus); m_bonus = 0; int step_need = gamescene->getStepNeed(); int score_need = gamescene->getScoreNeed(); //判断游戏是否结束 if (cur_step == 0) { if (cur_score < score_need) { gamescene->gameover(false); } else { gamescene->gameover(true); } this->unscheduleAllSelectors(); } else { if (cur_score >= score_need) { gamescene->gameover(true); this->unscheduleAllSelectors(); } else { //游戏没有结束,恢复触摸 _eventDispatcher->resumeEventListenersForTarget(this); } } } }
void AControllerBase::Step(double dt) { mDT = dt; subStep(dt); if(mIdle) { character->mCurMovState = MoveState::Idle; } mIdle = true; }
void SimStepStrategy::step() { preSubSteps(); while ( ! subStepsDone() ) { subStep(); } postSubSteps(); }
void ACombatModelBase::Step(double dt) { subStep(dt); auto it = mActions.begin(); while(it != mActions.end()) { if(*it == 0) { it++; continue; } (*it)->GetDuration() -= dt; if( (*it)->GetDuration() < 0 ) { (*it)->Step(dt); delete *it; *it = 0; } else { if((*it)->IsRepeating) { (*it)->Step(dt); } } it++; } }