Skip to content

Commit

Permalink
Added onScreen function to Container
Browse files Browse the repository at this point in the history
  • Loading branch information
ekelokorpi committed May 22, 2018
1 parent 8d2138f commit 52c3e48
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/engine/renderer/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,20 @@ game.createClass('Container', {
**/
mouseupoutside: function() {},

/**
Check if container is on the screen.
@method onScreen
@return {Boolean} Return true, if on the screen.
**/
onScreen: function() {
var bounds = this._getBounds();
if (bounds.x + bounds.width < 0) return false;
if (bounds.x > game.width) return false;
if (bounds.y + bounds.height < 0) return false;
if (bounds.y > game.height) return false;
return true;
},

/**
Remove this from it's parent.
@method remove
Expand Down

0 comments on commit 52c3e48

Please sign in to comment.