fishenal Posted February 12, 2014 Share Posted February 12, 2014 Hello everyone, I am new in game develop. I want to detect if two sprits are hit each other, collision detection . Is there any method in pixi.js can do that? My thought is finding edge (x,y) of one sprit and to compare the other (x,y),but I think that too complicated.Is there some simple way to do that? Thank you! Quote Link to comment Share on other sites More sharing options...
xerver Posted February 12, 2014 Share Posted February 12, 2014 Although pixi has no built-in methods to detect collisions between sprites, it does have everything you need to do it on your own. All sprites have a position, anchor, width, and height. You can use those dimensions to do bounding-box collision detection. Quote Link to comment Share on other sites More sharing options...
bubamara Posted February 13, 2014 Share Posted February 13, 2014 Bounding-box collision detection is pretty easy and fast. isIntersecting = function(r1, r2) { return !(r2.x > (r1.x + r1.width) || (r2.x + r2.width) < r1.x || r2.y > (r1.y + r1.height) || (r2.y + r2.height) < r1.y); } 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.