We need to add logic to restart our game and to move our pickup star to a new position. But first, let's kill the player!
Inside the
killPlayer
method, add the following lines:void GameLayer::killPlayer() { SimpleAudioEngine::getInstance()->stopBackgroundMusic(); SimpleAudioEngine::getInstance()->stopAllEffects(); SimpleAudioEngine::getInstance()->playEffect("shipBoom.wav"); _boom->setPosition(_rocket->getPosition()); _boom->resetSystem(); _rocket->setVisible(false); _jet->stopSystem(); _lineContainer->setLineType ( LINE_NONE ); _running = false; _state = kGameOver; _gameOver->setVisible(true); _pauseBtn->setVisible(false); }
Inside
resetStar
, add the following lines:void GameLayer::resetStar() { Point position = _grid[_gridIndex]; _gridIndex++; if (_gridIndex == _grid.size()) _gridIndex = 0; //reset star particles _star->setPosition...