Getting Data to a Singleton's Constructor

I’m trying to make a SpriteStore singleton which has a reference to my main graphics class. The SpriteStore will then, in turn, give each Sprite a reference to the graphics class. In this manner I hope to simplify drawing, as well as make future changes simplified by centralizing all of the graphics operations. Each sprite will make calls to the graphics class on its own, without the user worrying about it.

If it turns out that I cannot do this, I suppose I’ll have to have the graphics class simply take sprite objects and/or entities and resolve the image object itself. The solution sounds dirty to me. I couldn’t think of any other alternatives though.

Any help would be appreciated.

-Kris

What’s the code of your SpriteStore class?

Possibly add an init(Graphics g) method on your singleton called at the start of your rendering loop. This would also allow you to use it against a different graphics resource should your core game change later.

Kev

Agreed - this is what I do.