XNA Creators Club Online
Page 1 of 1 (6 items)
Sort Posts: Previous Next

DrawableGameComponent and rendering it behind SpriteFont

Last post 6/13/2008 5:48 PM by Greg the Mad. 5 replies.
  • 6/13/2008 1:38 PM

    DrawableGameComponent and rendering it behind SpriteFont

    I just finished (realy, just a few secs ago) the basic code of a sample I'm writing for Ziggyware.com, and now started tuning code and documentary.

    In the sample I used a lot of DrawableGameComponents, because it made it easyer to keep the overview, but that leaded to the problem that the model and some VertexPositionColor list are drawen over the strings  I use to display importent values, which I draw in the main Game Class.

    Is the some way I can tell the game to draw the string AFTER it has drawn the rest of the samples?

     

    Thanks in advance! :)

     

    Greg the Mad

  • 6/13/2008 1:46 PM In reply to

    Re: DrawableGameComponent and rendering it behind SpriteFont

    Why don't you put the text drawing component in another DrawableGameComponent, and just set the order so that it draws on top of the rest?
    Joel Martinez - XNA MVP
    Blog: http://codecube.net
    XNA Unit Testing: Scurvy Test
  • 6/13/2008 2:22 PM In reply to

    Re: DrawableGameComponent and rendering it behind SpriteFont

    That could work, but how do I set the order? When I write the line "Components.Add(Whatever);" ?

    And what if I only got one DrawableGameComponent and I want that to be drawn 'normal'?

    But thanks for the advice, I'll look into it. :)

     

    Greg the Mad

  • 6/13/2008 4:02 PM In reply to

    Re: DrawableGameComponent and rendering it behind SpriteFont

    Set the DrawOrder property on the DrawableGameComponent.
  • 6/13/2008 5:21 PM In reply to

    Re: DrawableGameComponent and rendering it behind SpriteFont

    Alternatively if you want to draw text on top of the drawable game component, just draw the text after you call base.Draw in your game class:


    protected override void Draw(GameTime gameTime) 
       GraphicsDevice.Clear(Color.Black); 
     
       //draw some stuff 
     
       //this draws your game components 
       base.Draw(gameTime); 
     
       //draw you text here 
  • 6/13/2008 5:48 PM In reply to

    Re: DrawableGameComponent and rendering it behind SpriteFont

    Thank you Nick. Your code was the one that realy help me with that problem. :)

    But also the others where a great help, not I know how to change the order I discovered that is no that simple to draw 3D stuff 'at the same time'.

    What I mean is that on DrawableGameComponent can intersect a nother one, like if they are drawn in the game class, is this possible?

     

    Thanks again :)

     

    Greg the Mad

Page 1 of 1 (6 items) Previous Next