kaplayjs / kaplay

🦖 A JavaScript/TypeScript Game Library that feels like a game. Make games fast, fun and fanstastic.
https://kaplayjs.com
MIT License
394 stars 31 forks source link

feat: make "fake cursor" still trigger hover events #359

Closed lajbel closed 2 weeks ago

lajbel commented 3 weeks ago

Discussed in https://github.com/kaplayjs/kaplay/discussions/330

Originally posted by **dragoncoder047** August 6, 2024 So I decided that my game would not force people to use their mouse. To do that I requested pointer lock (i.e. `setCursorLocked(true)`), added a game object with a custom cursor sprite and a z-index of infinity, and programmed it to move when the mouse moves, but also move according to the right gamepad stick. Unfortunately with pointer lock turned on Kaplay no longer knows where the pointer is and so the area component can't fire its `onHover` event. How do I tell Kaplay that my synthesized pointer should be used for the hover events and/or feed the synthesized pointer's position into the mouse-hover logic?