Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
    
Yes you should :) –  Roy T. Mar 30 '12 at 8:55
    
@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. –  Petr Abdulin Mar 30 '12 at 9:19
add comment

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
    
Thanks, this certanly clarifies situation. Rather then remove my question, I will mark this as answer, since it might help others. –  Petr Abdulin Mar 30 '12 at 10:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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