mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 21:53:59 +00:00
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:
parent
268b13392b
commit
a948dab895
1 changed files with 8 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue