if (Momo.isMouseButtonPressed("left")) {
Momo.lockMouse();
}
Produces the following console message in Firefox 71.0:
Request for pointer lock was denied because Element.requestPointerLock() was not called from inside a short running user-generated event handler, and the document is not in full screen.
It works without issue in Chrome 79.
Using Momo.getCanvas().addEventListener("click", () => {Momo.lockMouse();}); works instead. The internals of Momo.lockMouse() should be changed to reflect this.
This can not be fixed. While Momo.lockMouse() can be called under any condition at any time in Chrome, it can only be called from within a custom event listener in Firefox. The latter is by design of Mozilla.
This code:
Produces the following console message in Firefox 71.0:
It works without issue in Chrome 79.
Using
Momo.getCanvas().addEventListener("click", () => {Momo.lockMouse();});
works instead. The internals ofMomo.lockMouse()
should be changed to reflect this.