Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setPollRate() no longer working in Phaser 3.8? #6754

Closed
orcomarcio opened this issue Feb 29, 2024 · 7 comments
Closed

setPollRate() no longer working in Phaser 3.8? #6754

orcomarcio opened this issue Feb 29, 2024 · 7 comments
Assignees

Comments

@orcomarcio
Copy link

orcomarcio commented Feb 29, 2024

Version

  • Phaser Version: 3.80.1 "Nino
  • Operating system: Windows 11
  • Browser: Chrome

Description

I was testing 3.80 on my project and found out that a fix I made is no longer working. I dind't want to keep pollRate on, but i wanted my cursor to refresh if it was hovering on a button that got disabled. this was my inelegant solution:
image

In 3.80 this no longer works, but in 3.7 it does. I compared the codes and I found the "culprit". In the method Phaser.Input.InputPlugin#disable, manager.resetCursor(input) is no longer called.
image

I tried manually putting it back in and with that my fix works again. I'm not sure what I'm tampering with though so I wouldn't call this a solution. I'm just wondering if setPollRate broke.
Side Note: I tried to leave poll rate on for longer (600 instead of 60ms) to make sure it needed more time now to kick in, but this fix didn't work.

@photonstorm
Copy link
Collaborator

Can you confirm you mean v3.80 please? As v3.8 was released years and years ago.

@orcomarcio
Copy link
Author

orcomarcio commented Mar 1, 2024

Yes my bad, it's the most recent version, I edited the post. I googled 3.8 to check the nickname of version and didn't realize there was a different 3.8 out there.

@photonstorm
Copy link
Collaborator

Just to clarify, our version numbers are sequential, you don't drop the zero - so 3.8 means 'version 8' and 3.80 means 'version 80', hence much more recent! Even so, thanks for reporting this. We'll look into it for v3.90 (not 3.9 :) )

@zekeatchan
Copy link
Collaborator

zekeatchan commented Jul 12, 2024

@orcomarcio, from your description here's what it sounds like:

  1. You have an interactive button with a custom rollOver cursor
  2. When the button is clicked, it will be disabled
  3. The custom rollOver cursor still shows despite being over the disabled button and there's no way to reset it

If the above is correct, here's a possible solution to try out without altering the InputPlugin code:

        const sprite = this.add.sprite(400, 300, 'eye').setInteractive({ cursor: 'pointer' });

        sprite.on('pointerdown', function (pointer)
        {
            this.input.disable(sprite);
            this.input.manager.resetCursor(sprite.input);
        }, this);

@orcomarcio
Copy link
Author

orcomarcio commented Jul 12, 2024

@zekeatchan , it's mostly the opposed problem, I need to refresh the cursor when a button gets reenabled

Without fix, if my cursor is overing a disabled button, when the button becomes enabled the cursor won't turn into an hand.

My workaround was to force it to refresh using the setPollRate, as i couldn't find a more direct way to do so.
In 3.80 this doesn't work anymore. I'm not sure if there's a different call I can do instead.

@photonstorm
Copy link
Collaborator

You can now re-create this by using the new resetCursor argument in InputPlugin#disable in v3.85. Or you can directly force it via the new InputPlugin.resetCursor() or setCursor methods. Both of these give you more control over the cursor handling during input events. Simply setting just the poll rate won't be enough, but calling one of these will.

@orcomarcio
Copy link
Author

orcomarcio commented Oct 8, 2024

I finally got around to try Phaser v8.85.2 and what you suggested doesn't properly work.
With resetCursor() (or by using disableInteractive(true) on a button) it succesfully changes the cursor from 'pointer' to the default one, but there are some flaws, even if you pair it with setPollRate(0):

Just using resetCursor():

  • if a button becomes enabled while hovering it, the cursor doesn't become 'pointer'
  • if you disable a button that you're not hovering, the cursor still resets to default

Using just setPollRate(0):

  • if a button becomes disabled while hovering it, the cursor remains 'pointer'

Using resetCursor() and setPollRate(0) together:

  • if you disable a button you are not hovering, if you don't want your cursor to reset you need a custom solution to check if you are over that button before resetting. This doesn't take into account if there would be another interactive object below the disabled button (ex. i click on a popup and when it disappears (resetting my cursors), but my mouse coincidentally was placed on an interactive button previously covered by the popup).
  • if by any chance i reset the cursor while on an interactive object, it doesn't change the cursor even with moving it, I'm force to go out and over again.

I'm not sure if I'm missing something, but it feels like there is no solution to this problem unless I create something myself that handles the cursor appearence.
I feel like the framework needs a refresh() function that checks if the cursor is over any interactive element and change it's appearence accordingly, or have the pollRate detecting again when to reset the cursor but that wouldn't sove some of the edge cases.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants