Collision detection without impecting in Box2d Javascript -
i creating car race game, need in car on rough surface area box2d javascript.
- i created car game following link http://www.codekites.com/make-racing-car-box2d-javascript/
- also created obstacles.
question:
- now want such obstacles, should not collide car. when car goes on shape, car become slow.
so please me, how go that. found issensor, not working. please let me know, how go this.
aahhhh... got solution stackoverflow itself. here is.
how detect collision not collide in box2d?
i using wrong keyword.
fixturedef.issensor = true; thats ;) , detect collision have write listener this
world.setcontactlistener(listener); var listener = new box2d.dynamics.b2contactlistener; listener.begincontact = function(contact) { // console.log(contact.getfixturea().getbody().getuserdata()); div = document.getelementbyid("textui"); div.innerhtml = "come "+contact.getfixturea().getbody(); defaultcarspeed = defaultcarspeed/2; } listener.endcontact = function(contact) { // console.log(contact.getfixturea().getbody().getuserdata()); div = document.getelementbyid("textui"); div.innerhtml = "go "+contact.getfixturea().getbody(); defaultcarspeed = defaultcarspeed*2; }
Comments
Post a Comment