I'm using Farseer in my XNA project, but I have some trouble with the ContactListener. I created a class for my ContactListener but I always get these two error messages and I don't know how to fix the problems.
The type or namespace name 'ContactListener' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'ContactImpulse' could not be found (are you missing a using directive or an assembly reference?)
What is wrong with my ContactListener class?
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 */ }
}
Try this:
Solution Explorer
windowReferences
and right click itAdd Reference...
And try adding these in code:
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;