0
\$\begingroup\$

It is possible to set draw order of a DrawableGameComponent by setting DrawOrder property. But is it possible to set draw order of "main" Game class?

I have 2 DrawableGameComponents, and Draw method of a main Game class is called first, while I want it to be the last. Should I just mode all "main" draw code to another component and set it DrawOrder?

\$\endgroup\$
  • \$\begingroup\$ Yes you should :) \$\endgroup\$ – Roy T. Mar 30 '12 at 8:55
  • \$\begingroup\$ @RoyT. seems like I'm just confused myself a little. Black on black, that's why I didn't saw it. Main Draw is called last, as expected. I'll remove question soon. \$\endgroup\$ – Petr Abdulin Mar 30 '12 at 9:19
0
\$\begingroup\$

I wanted to clarify: Inside MyGame.Draw there is usually a call to base.Draw. It is my impression that this line is responsible for drawing attached components. Whatever code you put above it will be drawn before, whatever you put below it will be drawn after. If you remove the call to base, presumably the components will not be drawn.

If you have components A, B and C, and you would like MyGame.Draw to draw A and B, then draw some of its own stuff, and then draw C, it seems you'd have to draw each component manually by iterating through MyGame.Components.

\$\endgroup\$
  • \$\begingroup\$ Thanks, this certanly clarifies situation. Rather then remove my question, I will mark this as answer, since it might help others. \$\endgroup\$ – Petr Abdulin Mar 30 '12 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.