简体   繁体   English

更古老的物理......你好世界......?

[英]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: 但我得到2个错误:

No CreateBody() method (there is an AddBreakableBody() though) 没有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 constructor takes 2 arguments (this ones easy but still error in the example) CircleShape构造函数有两个参数(这个很简单,但在示例中仍然是错误的)

'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. 转到CircleShape类,查看参数的顺序。 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. 然后在项目中搜索CreateBody(),以查看应从何处调用该方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM