I'm working on a multiplayer game iOS app and I've come to a point in the design where it seems that I would benefit from creating two singletons but I don't know if there is a superior design pattern.
- A live game singleton: to get/set properties and start/stop the game from anywhere in the app.
- A location manager singleton: to manage user location updates/properties from anywhere in the app but especially from inside of the live game singleton because the game mechanics affect the properties of the location manager.
And if you are wondering do I really need to interact with these objects from absolutely anywhere in the app, the answer is a definite yes. This is a live multiplayer experience so everything related to gameplay needs to persist cleanly throughout the app's lifecycle.
So would this be a correct use of the singleton pattern or is there a better method, and if there is why is it better?
Aucun commentaire:
Enregistrer un commentaire