Sign in to follow this  
leosantana

How to do hitTest in pandajs

Recommended Posts

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);

Share this post


Link to post
Share on other sites

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;	}}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.