I would like some 2D sprites to occlude some 3D DrawableGameComponents. For a simplified example, a pause menu (implemented as a 2D sprite) should be drawn on top of a paused space ship (implemented as 3D game component).
The XNA framework automatically calls Draw methods of classes from Microsoft.Xna.Framework.Game and Microsoft.Xna.Framework.DrawableGameComponent.
In my experience, I am finding that the draw order is:
- Game Draw() methods
- DrawableGameComponent Draw() methods
My spriteBatch draw method calls are the draw method of my Game class. Therefore, the space ship is drawn over the top of the pause menu (making it unreadable).
It seems to me that the simplest way to solve my problem would be to reverse the order that the draw methods are called. Is this possible?
I have tried setting the DrawOrder of the DrawableGameComponents to different values (1000, 1, 0, -1, -1000) but it has no effect on the XNA framework Draw() method call order between instances of Game and DrawableGameComponent.
I have looked into the layerDepth of SpriteBatch Draw method calls, but they appear to be unrelated to the XNA Framework draw order between the Game and DrawableGameComponent classes. Layer depth only seems to affect the sprites in the SpriteBatch.
I am new to using XNA but I suspect that I am asking too much of the framework. If this is the case, what would be the normal way to achieve the placing of 2D objects on top of 3D objects?
Any assistance would be appreciated.