InputPlugin.setCursor is a new method that will immediately set the CSS cursor to the given Interactive Objects cursor. Previously, this was hidden behind a private method in the Input Manager.

This commit is contained in:
Richard Davey 2024-08-07 19:14:54 +01:00
parent 934ba71810
commit 6102492c14

View file

@ -538,6 +538,27 @@ var InputPlugin = new Class({
return (this.manager && this.manager.enabled && this.enabled && this.scene.sys.canInput());
},
/**
* Sets a custom cursor on the parent canvas element of the game, based on the `cursor`
* setting of the given Interactive Object (i.e. a Sprite).
*
* See the CSS property `cursor` for more information on MDN:
*
* https://developer.mozilla.org/en-US/docs/Web/CSS/cursor
*
* @method Phaser.Input.InputPlugin#setCursor
* @since 3.85.0
*
* @param {Phaser.Types.Input.InteractiveObject} interactiveObject - The Interactive Object that will set the cursor on the canvas.
*/
setCursor: function (interactiveObject)
{
if (this.manager)
{
this.manager.setCursor(interactiveObject);
}
},
/**
* Forces the Input Manager to clear the custom or hand cursor, regardless of the
* interactive state of any Game Objects.