The Mouse class is responsible for handling all aspects of mouse interaction with the browser.
It captures and processes mouse events that happen on the game canvas object.
It also adds a single mouseup
listener to window
which is used to capture the mouse being released
when not over the game.
You should not normally access this class directly, but instead use a Phaser.Pointer object
which normalises all game input for you, including accurate button handling.
Name | Type | Description |
---|---|---|
game | Phaser.Game | A reference to the currently running game. |
This property was removed in Phaser 2.4 and should no longer be used.
Instead please see the Pointer button properties such as Pointer.leftButton
, Pointer.rightButton
and so on.
Or Pointer.button holds the DOM event button value if you require that.
The context under which callbacks are called.
If true the DOM mouse events will have event.preventDefault applied to them, if false they will propagate fully.
Mouse input will only be processed if enabled.
The browser mouse DOM event. Will be null if no mouse event has ever been received.
Access this property only inside a Mouse event handler and do not keep references to it.
A reference to the currently running game.
A reference to the Phaser Input Manager.
If the mouse has been Pointer Locked successfully this will be set to true.
A callback that can be fired when the mouse is pressed down.
A callback that can be fired when the mouse is no longer over the game canvas.
A callback that can be fired when the mouse enters the game canvas (usually after a mouseout).
A callback that can be fired when the mouse is released from a pressed down state.
A callback that can be fired when the mousewheel is used.
This event is dispatched when the browser enters or leaves pointer lock state.
If true Pointer.stop will be called if the mouse leaves the game canvas.
The direction of the last mousewheel usage 1 for up -1 for down.
The internal method that handles the mouse down event from the browser.
Name | Type | Description |
---|---|---|
event | MouseEvent | The native event from the browser. This gets stored in Mouse.event. |
The internal method that handles the mouse move event from the browser.
Name | Type | Description |
---|---|---|
event | MouseEvent | The native event from the browser. This gets stored in Mouse.event. |
The internal method that handles the mouse out event from the browser.
Name | Type | Description |
---|---|---|
event | MouseEvent | The native event from the browser. This gets stored in Mouse.event. |
The internal method that handles the mouse out event from the window.
Name | Type | Description |
---|---|---|
event | MouseEvent | The native event from the browser. This gets stored in Mouse.event. |
The internal method that handles the mouse over event from the browser.
Name | Type | Description |
---|---|---|
event | MouseEvent | The native event from the browser. This gets stored in Mouse.event. |
The internal method that handles the mouse up event from the browser.
Name | Type | Description |
---|---|---|
event | MouseEvent | The native event from the browser. This gets stored in Mouse.event. |
The internal method that handles the mouse up event from the window.
Name | Type | Description |
---|---|---|
event | MouseEvent | The native event from the browser. This gets stored in Mouse.event. |
The internal method that handles the mouse wheel event from the browser.
Name | Type | Description |
---|---|---|
event | MouseEvent | The native event from the browser. |
Internal pointerLockChange handler.
Name | Type | Description |
---|---|---|
event | Event | The native event from the browser. This gets stored in Mouse.event. |
Internal release pointer lock handler.
If the browser supports it you can request that the pointer be locked to the browser window.
This is classically known as 'FPS controls', where the pointer can't leave the browser until the user presses an exit key.
If the browser successfully enters a locked state the event Phaser.Mouse.pointerLock will be dispatched and the first parameter will be 'true'.
Starts the event listeners running.
Stop the event listeners.
© 2016 Richard Davey, Photon Storm Ltd.
Licensed under the MIT License.
http://phaser.io/docs/2.6.2/Phaser.Mouse.html