【发布时间】:2014-10-08 11:24:14
【问题描述】:
所以我在我正在制作的这个 2D 平台游戏中使用了 Farseer 物理,但由于某种原因,它使动画变得断断续续,令人恼火。我用两种不同的精灵尝试过。第一个有 4 帧,另一个有 10 帧。动画只有在使用 farseer 时才会断断续续。
这是我为精灵创建主体的代码:
public void CreateBody(World world, float density, Vector2 position, object userData = null)
{
//magic number; so player doesn't look silly running into something he isn't touching because of a weapon-- CHANGE LATER
_body = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(_attackForkFrames[0].Width * _scale.X - 20), ConvertUnits.ToSimUnits(_attackForkFrames[0].Height * _scale.Y - 2), density, ConvertUnits.ToSimUnits(position), userData);
_body.BodyType = BodyType.Dynamic;
_body.Restitution = 0f;
_body.CollisionCategories = Category.All;//Category.Cat1;
_body.CollidesWith = Category.All;//Category.Cat10;
...
这是更新位置的代码:
_body.Position = new Vector2(_body.Position.X + ConvertUnits.ToSimUnits(_movementSpeed), _body.Position.Y);
我确实将_body.position 转换为显示单位。
【问题讨论】:
-
这是 XNA 还是 MonoGame?
-
以后,请不要发布您的代码图片。花点时间把它翻译成网站。
-
以后不要用
xna标记关于monogame的问题,因为前者是后者的分支,不同的产品也是如此 -
@User52784246 在这种情况下,我认为标记 XNA 和 Monogame 没有问题,因为这两个框架是相似的,并且提供的代码可以用于其中一个或。
标签: c# monogame physics-engine farseer