C# Farseer ContactListener不工作

C# Farseer ContactListener不工作,c#,xna,game-physics,farseer,C#,Xna,Game Physics,Farseer,我在XNA项目中使用Farseer,但ContactListener有一些问题。我为ContactListener创建了一个类,但我总是收到这两条错误消息,我不知道如何解决这些问题 找不到类型或命名空间名称“ContactListener”(是否缺少using指令或程序集引用?) 找不到类型或命名空间名称“ContactImpulse”(是否缺少using指令或程序集引用?) 我的ContactListener类有什么问题 class MyContactListener: ContactList

我在XNA项目中使用Farseer,但ContactListener有一些问题。我为ContactListener创建了一个类,但我总是收到这两条错误消息,我不知道如何解决这些问题

找不到类型或命名空间名称“ContactListener”(是否缺少using指令或程序集引用?)

找不到类型或命名空间名称“ContactImpulse”(是否缺少using指令或程序集引用?)

我的ContactListener类有什么问题

class MyContactListener: ContactListener
{
    void BeginContact(Contact contact)

    { /* handle begin event */ }


    void EndContact(Contact contact)

    { /* handle end event */ }


     void PreSolve(Contact contact, ref Manifold oldManifold)
    {
      Fixture fixtureA = contact.FixtureA;
      Fixture fixtureB = contact.FixtureB;

      if (fixtureB.CollisionCategories == Category.Cat10)
      {
        contact.Enabled = false;
      }
    }

    void PostSolve(Contact contact, ref ContactImpulse impulse)

   { /* handle post-solve event */ }

}
试试这个:

  • 开放VS
  • 转到
    解决方案资源管理器
    窗口
  • 搜索名为
    References
    的文件夹,然后右键单击它
  • 选择
    添加引用…
  • 查找Farseer组件并添加它
并尝试在代码中添加以下内容:

using FarseerPhysics.Collision.Shapes;
using FarseerPhysics.Common;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Dynamics.Contacts;
using FarseerPhysics.Factories;
using FarseerPhysics.TestBed.Framework;
using Microsoft.Xna.Framework;

您是否在包含此类的项目中添加了对farseer assemby的引用。您是否将“ContactListener”的包含名称空间添加为类文件中的用法?我添加了对Farseer项目的引用,但找不到ContactListener类。在哪里可以找到此类?应该添加哪个命名空间?我已经添加了几个名称空间。我查看了Farseer的所有源代码,但在它的任何地方都找不到
ContactListener
,因为它不起作用。在这里询问stackoverflow问题之前,我已经添加了引用。如果我使用添加以下内容,我会收到此错误消息:using FarseerPhysics.TestBed.Framework;命名空间“FarseepPhysics”中不存在类型或命名空间名称“TestBed”(是否缺少程序集引用?)