Last active
August 29, 2015 14:00
-
-
Save netgfx/77dba7df624446a3add4 to your computer and use it in GitHub Desktop.
KineticJS CoD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function doObjectsCollide(a, b) { // a and b are your objects | |
| return !( | |
| ((a.getY() + a.getHeight()) < (b.getY())) || | |
| (a.getY() > (b.y + b.getHeight())) || | |
| ((a.getX() + a.getWidth()) < b.getX()) || | |
| (a.getX() > (b.getX() + b.getWidth())) | |
| ); | |
| } | |
| // for kinetic version > 5.1 | |
| function doObjectsCollide(a, b) { // a and b are your objects | |
| return !( | |
| ((a.y() + a.height()) < (b.y())) || | |
| (a.y() > (b.y() + b.height())) || | |
| ((a.x() + a.width()) < b.x()) || | |
| (a.x() > (b.x() + b.width())) | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment