Shashwat
Shashwat

Reputation: 2668

In what order does the Components are drawn in XNA4 Game Class?

I'm creating a Bomberman Game with different Components. I've created separate DrawableGameComponents for BombList, PlayerList, WallList, PlayerDisplay (List of players when TAB is pressed) and added them in the Components list. The backboard and instruction texts are drawn in the main Game1 class.

I want to know in what order these Components are rendered. Is it in the order in which they are in Components List? Initially it seemed like that.

Later, I needed to update BombList, PlayerList and WallList. But this time, it was rendering PlayersDisplay at the back. I tried to insert them at different positions but I realized what matters is the order in which the Components are added (no matter at what position).

My questions are

Upvotes: 0

Views: 52

Answers (1)

William
William

Reputation: 772

Reading up on the documentation explains that.

It has the following member: .DrawOrder

Order in which the component should be drawn, relative to other components that are in the same GameComponentCollection.

Additionally, when you call base.Draw() in your Draw override you're calling the .Draw method for all components.

Upvotes: 1

Related Questions