java - EndContact of ContactListner(Box2d) not called everytime in LibGDX -


i new in box2d , trying implement in libgdx game. want detect collision between various bodies. so,i made class collisiondetection , implement contactlistener in gives me 4 overridden methods i.e. begincontact() , endcontact() have deal with. passing object of collisiondetection class in world.setcontactlistner(collisiondet) overridden methods of collisiondetection class called when bodies in world class collide each other. problem occuring when bodies collide begincontact() method called everytime endcontact() method not called everytime when bodies lost contact.so, possible ways can detect endcontact() everytime.

the code of collisiondetection class follow:

public class collisiondetection implements contactlistener { static fixture fixturea; static fixture fixtureb; public static boolean colliding=false; world world;   protected collisiondetection(world world, long addr) {     this.world = world;     // todo auto-generated constructor stub }  @override public void begincontact(contact contact) {     // todo auto-generated method stub     fixturea = contact.getfixturea();     fixtureb = contact.getfixtureb();      colliding=true;  }  @override public void endcontact(contact contact) {     // todo auto-generated method stub           colliding=false;  }  @override public void presolve(contact contact, manifold oldmanifold) {     // todo auto-generated method stub  }  @override public void postsolve(contact contact, contactimpulse impulse) {     // todo auto-generated method stub   } 

and world class

collisiondet = new collisiondetection(worldbox, 0);
worldbox.setcontactlistener(collisiondet);

thanks

you might using settranform() moving object... box2d doesn't give callback when use set transform


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -