Jump to content

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);
Link to comment
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;	}}
Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...