Jump to content

checkWorldBounds issue


druphoria
 Share

Recommended Posts

I think there may be an issue with the checkWorldBounds logic in Phaser.Sprite.prototype.preUpdate, specifically the part where the game world bounds intersection is checked against the sprite bounds:

if (this._cache[5] === 1 && this.game.world.bounds.intersects(this._bounds))        {            this._cache[5] = 0;            this.events.onEnterBounds.dispatch(this);        }        else if (this._cache[5] === 0 && !this.game.world.bounds.intersects(this._bounds))        {            //  The Sprite WAS in the screen, but has now left.            this._cache[5] = 1;            this.events.onOutOfBounds.dispatch(this);            if (this.outOfBoundsKill)            {                this.kill();                return false;            }        }

I noticed that my sprite was falling for a good while after falling past the bottom edge of the map before the onOutOfBounds event was dispatched, the result being that it takes way too long for my killPlayer function to be executed. I believe that the "this._bounds" being checked in the code snippet above, which is calculated using Pixi.Sprite's getBounds() method, uses some kind of coordinate system that is localized to the visible game window (I realized this by checking sprite.getBounds() while moving my sprite around the screen). Because my map is taller than the height of my game, my sprite has to fall for that difference in height before the game registers it as being out of place. Just wondering if this is the intended behavior, or if I am simply misunderstanding something here.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...