Hi! I'm a game developer working on an engine in Flash ActionScript 3.0.
The engine features some global instances of classes, which are used much like a Singleton would.
For example, the SpriteManager is used whenever a game sprite needs to be created, so each class that uses a sprite accesses the SpriteManager globally.
One problem this presents is in the case where we have several games running inside the same application, and we want a different SpriteManager for each one of them.
A possible solution is to pass the SpriteManager (or any other of the current Singletons) around as arguments, but that seems hard to mantain and not very elegant - we'd have to pass it through *many* classes.
What would be a better / more OOP-friendly solution?
Any comment would be appreciated!
The engine features some global instances of classes, which are used much like a Singleton would.
For example, the SpriteManager is used whenever a game sprite needs to be created, so each class that uses a sprite accesses the SpriteManager globally.
One problem this presents is in the case where we have several games running inside the same application, and we want a different SpriteManager for each one of them.
A possible solution is to pass the SpriteManager (or any other of the current Singletons) around as arguments, but that seems hard to mantain and not very elegant - we'd have to pass it through *many* classes.
What would be a better / more OOP-friendly solution?
Any comment would be appreciated!