Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Mouse events propagation


d3mi3n
 Share

Recommended Posts

I'm kinda new to phaser I'm having a very annoying issue.

 

I have a DOM HUD over my phaser canvas.

<body>  <div id="hud">/* hud elements here, z-index: 20; */</div>  <div id="phaser">/* phaser elements here, z-index: 10; */</div></body>

All events that trigger on the hud elements are also triggered in phaser.

Is there any way to prevent that without going into Phaser.Mouse:111-113 and changing:

document.addEventListener('mousedown', this._onMouseDown, true);document.addEventListener('mousemove', this._onMouseMove, true);document.addEventListener('mouseup', this._onMouseUp, true);

to:

this.game.canvas.addEventListener('mousedown', this._onMouseDown, true);this.game.canvas.addEventListener('mousemove', this._onMouseMove, true);this.game.canvas.addEventListener('mouseup', this._onMouseUp, true);
Link to comment
Share on other sites

I would edit the Mouse class personally, it will solve the problem much quicker than any other hack or function redirect could - it's open source for a reason!

 

You're welcome to open this as an issue on github too, as a feature request for us to change where event listeners are bound.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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