开发者

How to reset all the values after completion of the game, before starting it again?

开发者 https://www.devze.com 2022-12-26 08:51 出处:网络
I have writing a small shooting g开发者_JS百科ame in cocos2d. Winning the game is to eliminate all the 10 enemies. After that end screen comes showing \'You Won\' and \'Play Again\'. If I go for \'Pla

I have writing a small shooting g开发者_JS百科ame in cocos2d. Winning the game is to eliminate all the 10 enemies. After that end screen comes showing 'You Won' and 'Play Again'. If I go for 'Play Again' option the game is starting from where I need. But, the problem is that the game is continuing from previously ended state. I mean it is not starting from enemy 1 again instead it is just showing the end of 10 enemy. I think I have to reset all the values before pushing the scene. But should I reset all the values I have used or there is any other way ?

Thank You.


Resetting the state seems a logical choice.

It would probably make for cleaner code if you re-factor so all your game state related information is held in one instance of a GameState object. Then it could have a method reset that puts values back as you want them.

0

精彩评论

暂无评论...
验证码 换一张
取 消