Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js check collision


if (rect1.x < rect2.x + rect2.w &&
        rect1.x + rect1.w > rect2.x &&
        rect1.y < rect2.y + rect2.h &&
        rect1.h + rect1.y > rect2.y) {
        // collision detected!
        }
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #js #check #collision
ADD COMMENT
Topic
Name
4+4 =