This project has moved. For the latest updates, please go here.

Collision Basics

Nov 12, 2010 at 4:12 PM

Hi again,

Another back to basics post, and thanks for the help so far, I'm progressing slowly with great help from this forum.

Ok so I've been looking through the discussions, looking at posts about collisions. If possible a simple explaination of how it works and a sample.

I want my ball fixture to delete on hitting the floor.

So far I've got very little, I think its something to do with the balls OnCollision event

Thanks for the help

Gerard Downes

Nov 26, 2010 at 10:05 PM

I saw that you didn't get a response so I will try to give one.

You first need to attach to the collision event and you do this like this:

fixture.OnCollision += OnCollision;

then you need to do something when the event happens

 private bool OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
     Body body1 = fixtureA.Body;
     Body body2 = fixtureB.Body;

     //Do something     

     return true;