Jump to content

Phaser.events.onInputOut not dispatched


sChupin
 Share

Recommended Posts

Hi everyone,

I'm trying to make a sprite moving when the mouse is over it and I'd like it to stop when the mouse is not over it anymore.

Here is my code:

mySprite.events.onInputOver.add(() => touchMouse = true);
mySprite.events.onInputOut.add(() => touchMouse = false);

and

update() {
  if (touchMouse) {
    mySprite.x += 5;
  }
}

My sprite is correctly moving but the onInputOut signal is not dispatched if I don't move the pointer out of the initial position of the sprite !! This result in my sprite moving out of my pointer and continuing its journey until I move my mouse...

Is it a phaser bug? Has anyone a solution to make this work?

 

Thank you very much and have a good day,

Simon

 

Edit:

I just tried to use the Phaser.InputHandler object instead but I got the same kind of bug. Here is the code:
 

update() {
  if (mySprite.input.pointerOver()) {
    mySprite.x += 5;
  }
}

 

Link to comment
Share on other sites

Thank you very much for your answer !

I'm just not sure where to set the dirty variable to true. I tried to set it on inputOver but then it's immediately back to false and the bug still occurs.

I fixed the bug by setting pointer.dirty = true in the update loop, but then it will be always reset to true. Is it the correct way to do?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...