我不知道为什么,但我似乎无法找出为什么这不起作用...... 我正在尝试制作一些非常简单的东西,比如刚刚脱离屏幕的东西。
看起来网站上的最新下载和第一个示例代码,我仍然错了。
我有这个:
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections;
using Microsoft.Xna.Framework.Input;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Collision.Shapes;
namespace Cross {
public class Game1 : Microsoft.Xna.Framework.Game {
GraphicsDeviceManager graphics;
public Game1() {
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
graphics.IsFullScreen = false;
graphics.PreferredBackBufferHeight = 600;
graphics.PreferredBackBufferWidth = 1200;
this.Window.Title = "Game";
}
protected override void Initialize() {
World world = new World(Vector2.Zero);
Body myBody = world.CreateBody();
myBody.BodyType = BodyType.Dynamic;
CircleShape circleShape = new CircleShape(0.5f);
Fixture fixture = myBody.CreateFixture(circleShape);
base.Initialize();
}
protected override void LoadContent() {
}
protected override void UnloadContent() {
}
protected override void Update(GameTime gameTime) {
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime) {
base.Draw(gameTime);
}
}
}
但我得到 2 错误:
没有CreateBody()
方法(虽然有AddBreakableBody()
)
'FarseerPhysics.Dynamics.World' does not contain a definition for 'CreateBody' and no extension method 'CreateBody' accepting a first argument of type 'FarseerPhysics.Dynamics.World' could be found (are you missing a using directive or an assembly reference?)
CircleShape构造函数有2个参数(这个很容易,但在示例中仍然是错误的)
'FarseerPhysics.Collision.Shapes.CircleShape' does not contain a constructor that takes 1 arguments
我已经尝试了很多东西而且我很困惑为什么我能得到这个。这段代码适用于其他人吗?我的dll搞砸了吗?
答案 0 :(得分:3)
Their example错了,你是对的! (我很惊讶他们有这样明显的错误。)
转到CircleShape类,查看参数的顺序。圆由定位和半径定义,而不仅仅是半径。
然后在你的项目中搜索CreateBody(),看看应该从哪个方法调用它。