Author Topic: Collision Listener not working  (Read 2102 times)

Offline fireside

  • double
  • *****
  • Posts: 605
    • View Profile
Collision Listener not working
« on: March 15, 2008, 12:28:14 am »
I'm not sure if I'm way off base trying to use the Collison Listener, but I have this class as follows:
Code: [Select]
public class Mouse extends Base implements CollisionListener {

public Mouse(Object3D obj) {
super(obj);
// TODO Auto-generated constructor stub
}

private Object3D colObj;

@Override
public void collision(CollisionEvent event) {
colObj = event.getObject();
// TODO Auto-generated method stub

}

@Override
public boolean requiresPolygonIDs() {
// TODO Auto-generated method stub
return false;
}
public void update()
{  if(colObj != null)System.out.println(colObj.getID());
colObj = null;
}

}



In the loop, I have mouse.update();

I walk the mouse around, he collides with things, but the println() command never gets called.
« Last Edit: March 15, 2008, 12:34:13 am by fireside »
click here->Fireside 7 Games<-

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Collision Listener not working
« Reply #1 on: March 15, 2008, 10:34:25 am »
Maybe you should add a debug output in the collision-method too...just to be sure. Apart from that: Has the listener been added correctly to the object in question?

Offline fireside

  • double
  • *****
  • Posts: 605
    • View Profile
Re: Collision Listener not working
« Reply #2 on: March 15, 2008, 05:06:53 pm »
Is there an example of a collision listener being used anywhere?  I can't quite understand how it was meant to work.

edit: Oh, the car demo has one.  I'll study that for a while.



« Last Edit: March 15, 2008, 05:10:46 pm by fireside »
click here->Fireside 7 Games<-