Need Help With Colision PLZ

Oct 9, 2008 at 2:49 AM
Hi I am making a 2d side scrolling game and I wanted to know if someone can tell me how to tell if one object colided with another. So If my Character hits an enemy It trips an event. Can someone please explain this to me thx. Also how do U develop water?
Oct 9, 2008 at 7:25 AM
The Geom class has a collision delegate that you can subscribe to.

Note: This is from 2.0 source code and might be different to yours:

In your LoadContent method:

_circleGeom.OnCollision += OnCollision;

And the method that handles the collision. If you return true, the collision will happen, if false, it will not.

bool OnCollision(Geom geom1, Geom geom2, ContactList contactList)
return true;

To create water you will need to use the WaveController and FluidDragController. Example on how to use them will be released together with Farseer Physics 2.0  


Oct 9, 2008 at 3:03 PM
Thank You very much Genbox but Does Private Bool always have to be bool or can it be private void?
Oct 9, 2008 at 4:25 PM
It needs to have the same signature as the delegate that you subscribe to. So yes, it needs to be a bool. (You can make it public, protected or something else if you like).

If you don't want to change whether the collision should happen or not, just always return true. We put the boolean in place so that you have the posibility of canceling the collision if some condition is met.

I hope this is of use to you. We are working hard on a manual that covers all about this and more.