How can i draw line in XNA (C#) by using float values, not integer because an integer number eliminate the values after points
like: 20.12
How can i draw line in XNA (C#) by using float values, not integer because an integer number eliminate the values after points
like: 20.12
You can try using the SpriteBatch.Draw (Texture2D, Vector2, Nullable<Rectangle>, Color, Single, Vector2, Vector2, SpriteEffects, Single)
method.
You'll need to create a Texture2D
that represents your line first.
Vector2 pos = new Vector2(20.12F, 20.12F);
Vector2 scale = new Vector2(150.23F, 1);
Color myColor = Color.Blue;
Texture2D simpleTexture = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
// Draws a "line" with size (1, 1), at position (20.12, 20.12), with blue color, rotated by 45° (Pi/4), with origin at (0, 0) (the line will begin at 'pos'), scaled by (150.23, 1) (gives the line a size of (150.23, 1) )
this.spriteBatch.Draw(simpleTexture, pos, null, myColor, MathHelper.PiOver4, Vector2.Zero, scale, SpriteEffects.None, 0)
It's been long since I've been working with XNA, so I can't guarantee that this will work.
I hope it helps anyways.