leosantana Posted March 18, 2014 Share Posted March 18, 2014 Hi guys,I'm working in a project and emerged a matter about how to do hitTest?Who can help? thanks! Quote Link to comment Share on other sites More sharing options...
enpu Posted March 19, 2014 Share Posted March 19, 2014 Use game.CollisionSolver's hitTest method: var solver = new game.CollisionSolver();var hitTest = solver.hitTest(bodyA, bodyB);There is also instance of game.CollisionSolver on game.World:this.world = new game.World();var hitTest = this.world.solver.hitTest(bodyA, bodyB); Quote Link to comment Share on other sites More sharing options...
leosantana Posted March 19, 2014 Author Share Posted March 19, 2014 Thanks empu! How I didn't know, I did something that it resolved.take a look: function hitTestPoint(a, { var dx = b.x - a.position.x; var dy = b.y - (b.height-a.position.y); var dist = Math.sqrt(dx*dx+dy*dy); if (dist <= a.width / 2 + b.width/2) { return true; } else { return false; }} Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.