开发者

Farseer physics...hello world...?

I have no idea why but I cant seem to find out why this isn't working... I'm trying to make something really simple, like something that just falls off the screen.

It seems like with the latest download and the first example code on the site, I'm still wrong.

I have this:

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);
        }
    }
}

But I get 2 errors:

No CreateBody() method (there is an AddBreakableBody() though)

'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 constructor takes 2 arguments (this ones easy but still error in the example)

'FarseerPhysics.Collision.Shapes.CircleShape' does not contain a constructor that takes 1开发者_开发百科 arguments

I've tried so many things and I'm confused why I can get this. Does this code work for others? Is my dll messed up?


Their example is wrong, you're right! (I'm surprised that they have such glaring errors.)

Go to the class CircleShape and see which order the parameters go. A circle is defined by a position and a radius, not just a radius.

Then search your project for CreateBody(), to see where that method should be called from.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜