Skip to content

Instantly share code, notes, and snippets.

@netgfx
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save netgfx/77dba7df624446a3add4 to your computer and use it in GitHub Desktop.

Select an option

Save netgfx/77dba7df624446a3add4 to your computer and use it in GitHub Desktop.
KineticJS CoD
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