phaserjs / phaserjs/phaser

Curosr does not change even after scene sleep

Open
#6,986 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

⌨️ Input
Dominant language
JavaScript
Stars
40.3k
Forks
7.2k
PR merge metrics
No merged PRs in 30d

Description

Version

  • Phaser Version: 3.80.1
  • Operating system: Windows

Description

I am using a scene as an inventory window, so it is above another scene.
I have a image object that acts as a button, with setInteractive({ useHandCursor: true }); attached.
When I try to close the scene with scene.sleep() by clicking the button, the cursor remains as 'pointer'.
I expected the cursor to be 'default' when the scene is not active anymore.

Example Test Code

class Test1 extends Phaser.Scene {
constructor() { super('test1')} 
create() {

scene.launch('test2');
}
}

class Test2 extends Phaser.Scene {
constructor() { super('test2')} 
create() {

 const closeButton = this.add.rectangle(0, 0, 200, 200);
  closeButton.setInteractive({ useHandCursor: true });
  closeButton.on('pointerdown', () => {
      this.scale.canvas.style.cursor = 'default'; // I had to manually change the cursor.
      this.scene.sleep();
  });
}
}

const game = new Phaser.Game({
    type: Phaser.AUTO,
    width: 800,
    height: 800,
    backgroundColor: '#111111',
    scale: {
        mode: Phaser.Scale.FIT,
        autoCenter: Phaser.Scale.CENTER_BOTH
    },
    scene: [  Test1, Test2 ]
})

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the provided Test1/Test2 example and start by tracing the interactive closeButton, pointerdown handler, and scene.sleep() behavior. Inspect how the active scene manages the canvas cursor after sleeping. Done means the cursor returns to the default state when the inventory scene sleeps, without requiring the manual style change.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.