java - BeginContact not being executed -


i'm trying detect collision between dynamic , static body. code wrote executes without errors collision not being detected. dynamic body movable. when touches other bodies in physicsworld collision not being detected. here's code:

public class mainactivity extends basegameactivity implements contactlistener {     body body, bodyr1, bodyr2, bodyr3;     physicsworld pw;      @override     public void oncreatescene(oncreatescenecallback poncreatescenecallback)         throws exception {         scene = new scene();         final float centerx = (camera_width - back.getwidth()) / 2;         final float centery = (camera_height - this.back.getheight()) / 2;          sprite backgr = new sprite(centerx, centery, back,             this.getvertexbufferobjectmanager());         sprite rcs1 = new sprite(85, 250, rc1,             this.getvertexbufferobjectmanager());         sprite rcs2 = new sprite(195, 240, rc2,             this.getvertexbufferobjectmanager());         sprite rcs3 = new sprite(295, 250, rc3,             this.getvertexbufferobjectmanager());          ans = new animatedsprite(86, 245, ttr,             this.getvertexbufferobjectmanager()) {                 @override                 protected void onmanagedupdate(float psecondselapsed) {                     this.setposition(px, py);                     super.onmanagedupdate(psecondselapsed);                 }             };          this.mphysicshandler = new physicshandler(ans);         pw = new physicsworld(new vector2(0, sensormanager.gravity_earth),             false);         final fixturedef objectfixturedef = physicsfactory.createfixturedef(2f,0f, 0.9f);         body = physicsfactory.createboxbody(pw, ans, bodytype.dynamicbody,             objectfixturedef);         bodyr1 = physicsfactory.createboxbody(pw, rcs1, bodytype.staticbody,             objectfixturedef);         bodyr2 = physicsfactory.createboxbody(pw, rcs2, bodytype.staticbody,             objectfixturedef);         bodyr3 = physicsfactory.createboxbody(pw, rcs3, bodytype.staticbody,             objectfixturedef);          pw.registerphysicsconnector(new physicsconnector(ans, body, true, true));          scene.attachchild(backgr);         scene.attachchild(rcs1);         scene.attachchild(rcs2);         scene.attachchild(rcs3);         scene.attachchild(ans);         body.setuserdata("player");         bodyr2.setuserdata("3");         pw.setcontactlistener(this);         scene.registerupdatehandler(this.mphysicshandler);         poncreatescenecallback.oncreatescenefinished(scene);     }      @override     public void begincontact(contact contact) {         // fixture x1= contact.getfixturea();         // fixture x2=contact.getfixtureb();         log.i("contacted","asdasdads");     }      @override     public void endcontact(contact contact) {         // todo auto-generated method stub     }      @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     } } 

why collision not being detected? please help

i didnot found contact listener in class.i think have add following link:

mphysicsworld.setcontactlistener(mainactivity.this); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -