Check for sprite destruction in onInputDown event.

This sprite might have been destroyed during the onInputDown event. Check to see if it was.

Also, set the pointer's dirty flag before the altered if-block just in case the function returns.
This commit is contained in:
zeterain 2016-03-22 15:54:41 -06:00
parent 268b13392b
commit a948dab895

View file

@ -954,13 +954,19 @@ Phaser.InputHandler.prototype = {
data.isUp = false;
data.timeDown = this.game.time.time;
// It's possible the onInputDown event creates a new Sprite that is on-top of this one, so we ought to force a Pointer update
pointer.dirty = true;
if (this.sprite && this.sprite.events)
{
this.sprite.events.onInputDown$dispatch(this.sprite, pointer);
// The onInputDown event might have destroyed this sprite.
if (this.sprite === null)
{
return;
}
}
// It's possible the onInputDown event created a new Sprite that is on-top of this one, so we ought to force a Pointer update
pointer.dirty = true;
// Start drag
if (this.draggable && this.isDragged === false)