Collision detection

Started by abhi13feb, April 23, 2008, 07:41:22 AM

Previous topic - Next topic

abhi13feb

How sphere polygon collission detection has been carried out in jPCtDemo example.Can someone plz explain it briefly..thanks

JavaMan

Basically on the objects you want to test for a collision you call

object1.setCollisionMode(...); I suggest using the or operator for Collision detect self and others
object2.setCollisionMode(...); same thing.

Then you need to implement the collision listener interface, and call

object1.addCollisionListener(new YourCollisionListener());

Then when you want to test if a movement will create a collision you call
object1.checkForCollisionSpherical(...);
If you object collides with another object the collision method will be called in your listener.

Its pretty much how the Swing event system works. Hope this helps!
Jman