I'm just starting with XNA and I wanted to draw Debug Lines around my Texture/Sprite to help me.
Is there an easy way to do it with SpriteBatch? I haven't used the GraphicsDevice yet to draw....
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.Sign up to join this community
I would suggest to create subclass of SpriteBatch that would have DrawLine and DrawRectangle function and in constructor create 1x1 texture.
Check out this forum post in which the poster details how he is making spriteBatch draw in wireframe mode.
Basically you just need to change your draw code to this;
spriteBatch.Begin(SpriteSortMode.Immediate,BlendState.Opaque); RasterizerState state = new RasterizerState(); state.FillMode = FillMode.WireFrame; spriteBatch.GraphicsDevice.RasterizerState = state; spriteBatch.Draw(sprite, position, Color.White); spriteBatch.End();
And obviously change "spriteBatch.Draw(sprite, position, Color.White)" to be a loop drawing all of your sprites.