我刚刚成功使用了,并创建了一个快速 / 粗略的基础对象,可以轻松创建物体。
因此,我设置了一个快速模拟,它看起来像这样:
在DebugView中,它看起来像这样:
经过仔细检查,启用两种模式后,我发现橙色框缺少一行和一列像素:
有人知道可能是什么原因吗?
因此,我设置了一个快速模拟,它看起来像这样:
![Farseer example of boxes not colliding](https://istack.dev59.com/mW7XQ.webp)
![Farseer example of boxes in debug mode](https://i.imgur.com/Yf2Qx.png)
![Missing pixel on texture](https://i.imgur.com/hcPy0.png)
class BasePhys
{
public float unitToPixel;
public float pixelToUnit;
public Vector2 size;
public Body body;
public Texture2D texture;
public BasePhys(World world, int x, int y)
{
this.unitToPixel = 100.0f;
this.pixelToUnit = 1 / unitToPixel;
TextureManager.GetTextureByName("base", ref this.texture);
this.size = new Vector2(this.texture.Width, this.texture.Height);
this.body = BodyFactory.CreateRectangle(world, this.size.X * this.pixelToUnit, this.size.Y * this.pixelToUnit, 1);
this.body.BodyType = BodyType.Dynamic;
this.body.Position = new Vector2(x * this.pixelToUnit, y * this.pixelToUnit);
}
public void Draw(SpriteBatch spriteBatch)
{
Vector2 scale = new Vector2(this.size.X / (float)this.texture.Width, this.size.Y / (float)this.texture.Height);
Vector2 position = this.body.Position * unitToPixel;
spriteBatch.Draw(this.texture, position, null, Color.White, this.body.Rotation, new Vector2(this.texture.Width / 2.0f, this.texture.Height / 2.0f), scale, SpriteEffects.None, 0);
}
}
有人知道这可能是为什么吗?并非所有Farseer演示都会出现这种情况。我已经检查了纹理,它没有任何不可见的像素
,橙色像素
填充整个文件。