1

我如何通过使用浮点值而不是整数在 XNA(C#)中画线,因为整数消除了点之后的值

喜欢:20.12

4

1 回答 1

0

您可以尝试使用该SpriteBatch.Draw (Texture2D, Vector2, Nullable<Rectangle>, Color, Single, Vector2, Vector2, SpriteEffects, Single)方法。您需要先创建一个Texture2D代表您的线的。

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)

我已经很久没有使用 XNA 了,所以我不能保证这会奏效。
无论如何,我希望它有所帮助。

于 2013-03-12T12:19:59.043 回答