Skip to content

Commit

Permalink
[#943] fix a regression with nested containers and floating objects
Browse files Browse the repository at this point in the history
  • Loading branch information
obiot committed Oct 28, 2018
1 parent 4b84b1c commit d57fee8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/camera/camera2d.js
Expand Up @@ -575,10 +575,11 @@
* @memberOf me.Camera2d
* @function
* @param {me.Renderable} object
* @param {Boolean} [floating===object.floating] if visibility check should be done against screen coordinates
* @return {Boolean}
*/
isVisible : function (obj) {
if (obj.floating === true) {
isVisible : function (obj, floating) {
if (floating === true || obj.floating === true) {
// check against screen coordinates
return me.video.renderer.overlaps(obj.getBounds());
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/particles/particlecontainer.js
Expand Up @@ -68,7 +68,7 @@
var viewport = me.game.viewport;
for (var i = this.children.length - 1; i >= 0; --i) {
var particle = this.children[i];
particle.inViewport = viewport.isVisible(particle);
particle.inViewport = viewport.isVisible(particle, this.floating);
if (!particle.update(dt)) {
this.removeChildNow(particle);
}
Expand Down
4 changes: 2 additions & 2 deletions src/renderable/container.js
Expand Up @@ -314,7 +314,7 @@
},

/**
* Returns the next child within the container or undefined if none
* Returns the next child within the container or undefined if none
* @name getNextChild
* @memberOf me.Container
* @function
Expand Down Expand Up @@ -811,7 +811,7 @@
obj.inViewport = false;
// iterate through all cameras
me.state.current().cameras.forEach(function(camera) {
obj.inViewport |= camera.isVisible(obj);
obj.inViewport |= camera.isVisible(obj, isFloating);
});

// update our object
Expand Down
6 changes: 3 additions & 3 deletions src/video/renderer.js
Expand Up @@ -239,10 +239,10 @@
* @param {me.Rect} rect
* @return {boolean} true if overlaps
*/
overlaps : function (rect) {
overlaps : function (rect) {
return (
rect.left < this.getWidth() && rect.right >= 0 &&
rect.top < this.getHeight() && rect.bottom >= 0
rect.left < this.getWidth() && rect.right > 0 &&
rect.top < this.getHeight() && rect.bottom > 0
);
},

Expand Down

0 comments on commit d57fee8

Please sign in to comment.