Pointer
The Pointer API deals with locking and unlocking pointers. This is beneficial for first person games that control the player using the mouse pointer. By locking the pointer, it will not be rendered anymore and all pointer events will now only return relative movement on X and Y axis. The pointer can not leave the render view anymore and will be invisibly held where it was when the lock occurred.
Usage
To use this module, add the following require at the top of your script:
Reference
__init
getState
Get the current state of the pointer.
Returns
table: table that contains x, y and a buttons array
isButtonPressed
Return the button press state of the specified button
Parameters
button(number): The index of the button
Returns
boolean: if pressed, otherwise false
getPosition
Return the position of the pointer
Returns
Vector2: pointer position
lock
Lock the pointer This will cause the pointer to disappear and be locked in the render view. Pointer events will now have static x/y position and only the movementX/movementY values will change. There is no guarantee the lock will happen as the browser will decide on this. In case the lock did not happen you will have an error in the log and the isLocked() function will return false. Also note that locking is an async operation so the result may not be available right after the call
unlock
Unlock the pointer in case it is locked. Will have no effect in case there was no lock
isLocked
Check if the pointer is locked
Returns
boolean: in case the pointer is locked, otherwise false