Sign in to follow this  
sChupin

Phaser.events.onInputOut not dispatched

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;
  }
}

 

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.