void GameLayer::update(float dt) { // check if animationing if (m_isAnimationing) { // init with false m_isAnimationing = false; for (int i = 0; i < m_height * m_width; i++) { Monster *mon = m_matrix[i]; if (mon && mon->getNumberOfRunningActions() > 0) { m_isAnimationing = true; break; } } } // if Monter is moving, ignore use touch event m_isTouchEnable = !m_isAnimationing; if (!m_isAnimationing) { if (m_isNeedFillVacancies) { //爆炸效果结束后才掉落新怪物,增强打击感 fillVacancies(); m_isNeedFillVacancies = false; } else { checkAndRemoveChain(); } } }
void PlayLayer::removeSushi(std::list<SushiSprite *> &sushiList) { // make sequence remove m_isAnimationing = true; std::list<SushiSprite *>::iterator itList; for (itList = sushiList.begin(); itList != sushiList.end(); itList++) { SushiSprite *sushi = (SushiSprite *)*itList; // remove sushi from the metrix m_matrix[sushi->getRow() * m_width + sushi->getCol()] = NULL; explodeSushi(sushi); } // drop to fill empty fillVacancies(); }
void BallMap::update(float dt) { // check if animationing if (m_isAnimationing) { // init with false m_isAnimationing = false; for (int i = 0; i < m_size.height * m_size.width; i++) { BallSprite *ball = m_matrix[i]; if (ball && ball->get_isMoving()) { m_isAnimationing = true; break; } } } // if Ball is moving, ignore use touch event m_isTouchEnable = !m_isAnimationing; if (!m_isAnimationing) { if (m_isNeedFillVacancies) { //爆炸效果结束后才掉落新寿司,增强打击感 fillVacancies(); m_isNeedFillVacancies = false; } else { if (m_isNeedCheckSelf) { checkAndRemoveChain(); } } } }
void PlayLayer::update(float dt) { // Kiểm tra giá trị lần đầu của m_isAnimationing, mỗi bước thời gian dt, sẽ lại kiểm tra m_isAnimationing là true hay flase if (m_isAnimationing) { // nếu True // Gán = false m_isAnimationing = false; // Duyệt trong toàn ma trận for (int i = 0; i < m_height * m_width; i++) { SushiSprite *sushi = m_matrix[i]; // Nếu tồn tại 1 Sushi mà đang có "Action" thì m_isAnimationing = true, và thoát vòng lặp if (sushi && sushi->getNumberOfRunningActions() > 0) { m_isAnimationing = true; break; } } } // Đến khi không có Action nào của Sushi tại bước thời gian dt nào đó, thì kiểm tra việc "Ăn" dãy Sushi nếu tồn tại // Thiết lập cờ cho phép Touch khi không còn chuyển động, và ngược lại m_isTouchEnable = !m_isAnimationing; //Nếu ko có chuyển động if (!m_isAnimationing) { // Xét xem phải điền đầy ô trống không if (m_isNeedFillVacancies) { fillVacancies(); // điền đầy m_isNeedFillVacancies = false; } else { checkAndRemoveChain(); // Kiểm tra và ăn các chuỗi } } }