phaserjs / phaser-ce-examples

Contains hundreds of source code examples and related media for the Phaser HTML5 Game Framework.
http://phaser.io/examples
1.76k stars 1.15k forks source link

Modified Pointer Lock example to not move sprite with click events #164

Closed burntcustard closed 7 years ago

burntcustard commented 7 years ago

Relating to this seemingly Firefox-related issue: https://github.com/photonstorm/phaser-examples/issues/163

Rather than using game.input.mouse.event.type like in the issue I raised, this uses an extra parameter of Phaser's addMoveCallback to check if the event was fired by a click event.

This "feels a bit weird" because addMoveCallback sounds like it shouldn't deal with mousedown (etc.) events... but reading through Phaser's source explained it quite well. I've tried to convey that a bit with my extra comment in the example.

I also think this needs some further investigating, because what if you want to have the pointer locked to the game, but only update it's movement when the user clicks? This might only be possible in Chrome right now, with the Firefox implementation of pointer lock giving garbage movement values with mousedown events - or maybe it's Phaser that calculates something incorrectly?