Game State / Screen Management
- by Ashylnn Mac
What's the best way to handle game states / screens? My problem is this:
PlayGameScreen adds a new InventoryGameScreen to the game during it's update. This immediately adds InventoryGameScreen to the array of GameScreens. That's throwing an exception when iterating over the array that the contents of the array have changed.
Should I have two more arrays, like screensToBeAdded and screensToBeRemoved and do all the processing for them at the end of the game loop after drawing all the other screens?