Skip to content

Commit 76deec0

Browse files
committed
When destroying an interactive Game Object that had useHandCursor enabled, it would reset the CSS cursor to default, even if the cursor wasn't over that Game Object. It will now only reset the cursor if it's over the Game Object being destroyed. Fix phaserjs#5321
The `InputPlugin.shutdown` method will now reset the CSS cursor, in case it was set by any Game Objects in the Scene that have since been destroyed.
1 parent 76b8452 commit 76deec0

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/input/InputPlugin.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -796,8 +796,6 @@ var InputPlugin = new Class({
796796
input.hitAreaCallback = undefined;
797797
input.callbackContext = undefined;
798798

799-
this.manager.resetCursor(input);
800-
801799
gameObject.input = null;
802800

803801
// Clear from _draggable, _drag and _over
@@ -820,6 +818,8 @@ var InputPlugin = new Class({
820818
if (index > -1)
821819
{
822820
this._over[0].splice(index, 1);
821+
822+
this.manager.resetCursor(input);
823823
}
824824

825825
return gameObject;
@@ -2859,15 +2859,19 @@ var InputPlugin = new Class({
28592859

28602860
this.removeAllListeners();
28612861

2862+
var manager = this.manager;
2863+
2864+
manager.canvas.style.cursor = manager.defaultCursor;
2865+
28622866
var eventEmitter = this.systems.events;
28632867

28642868
eventEmitter.off(SceneEvents.TRANSITION_START, this.transitionIn, this);
28652869
eventEmitter.off(SceneEvents.TRANSITION_OUT, this.transitionOut, this);
28662870
eventEmitter.off(SceneEvents.TRANSITION_COMPLETE, this.transitionComplete, this);
28672871
eventEmitter.off(SceneEvents.PRE_UPDATE, this.preUpdate, this);
28682872

2869-
this.manager.events.off(Events.GAME_OUT, this.onGameOut, this);
2870-
this.manager.events.off(Events.GAME_OVER, this.onGameOver, this);
2873+
manager.events.off(Events.GAME_OUT, this.onGameOut, this);
2874+
manager.events.off(Events.GAME_OVER, this.onGameOver, this);
28712875

28722876
eventEmitter.off(SceneEvents.SHUTDOWN, this.shutdown, this);
28732877
},

0 commit comments

Comments
 (0)