phaserjs / phaserjs/phaser

Programatically update pointer position issues

Open
#7,153 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

⌨️ Input
Dominant language
JavaScript
Stars
40.3k
Forks
7.2k
PR merge metrics
No merged PRs in 30d

Description

Version

  • Phaser Version: 4.0.0 RC4
  • Operating system: Windows
  • Browser: Chrome

Description

I'm trying to implement pointer lock in my game. I followed this example: https://labs.phaser.io/edit.html?src=src\input\mouse\pointer%20lock.js.
I am then listening to pointerMove events from some other component and using pointers X, Y or WorldX and WorldY to do something there. But coordinates don't seem to change once pointer is locked.

I tried manually setting X and Y to activePointer and calling updateWorldPoint but it seems that changes "do not persist between game ticks".

Update: upon further investigation, it seems like this could be overriding my manual active-pointer position updates: https://github.com/phaserjs/phaser/blob/master/src/input/Pointer.js#L699

Example Test Code

https://phaser.io/sandbox/QyEhav55
Please see console logs - I'm manually assigning some constant "300" to x component, but it seems it's using the last-position before locking the pointer down

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/input/Pointer.js around line 699 and compare its update flow with the pointer-lock example at labs.phaser.io/edit.html?src=src\input\mouse\pointer%20lock.js. Reproduce the behavior using the linked Phaser sandbox and its console logs. Done means manually assigned pointer coordinates persist across game ticks while pointer lock is active and the reported X/Y and WorldX/WorldY values update as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.