Accelerometer - detecting it - using tilt to control players

Porting an older game I previously created for IOS.
This made use of the accelerometer for controlling the main player.
Build a phaser 3 app and used the
window.addEventListener(“deviceorientation”, handleOrientation, true);
to detect tilt and move the player.
Not very clean. Is there a recommended way to do this?

Also is there a way to detect if a device even has an accelerometer?
Also is there a way to set the device;s orientation and freeze it.
Such as making it horizontal.

Should a separate framework be used for this such as gyro.js or should phaser 3 suffice?

Thanks for any feedback, pointers, etc.

Hi,
Phaser 3 doesn’t seems to handle this for you.
So you can use native js eventListener, or any lib that can help you.

As mentioned above, you have to handle this yourself. Check out this MDN tutorial on how to use Device Orientation with Phaser 2: https://developer.mozilla.org/en-US/docs/Games/Tutorials/HTML5_Gamedev_Phaser_Device_Orientation

The tutorial is quite old, but showcases this particular case quite well.

Thanks but I did look at this prior and the problem is that it just does not work very well.
And there are items missing, like locking the devices orientation.