Mouse
Class: Phaser.Mouse
Constructor
new Mouse(game)
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.
Parameters
Name | Type | Description |
---|---|---|
game | Phaser.Game | A reference to the currently running game. |
- Source code: input/Mouse.js (Line 21)
Public Properties
- Source code: input/Mouse.js (Line 190)
- Source code: input/Mouse.js (Line 196)
- Source code: input/Mouse.js (Line 172)
- Source code: input/Mouse.js (Line 178)
- Source code: input/Mouse.js (Line 166)
- Source code: input/Mouse.js (Line 184)
- Source code: input/Mouse.js (Line 208)
- Source code: input/Mouse.js (Line 202)
- Source code: input/Mouse.js (Line 76)
- Source code: input/Mouse.js (Line 37)
- Source code: input/Mouse.js (Line 67)
- Default Value
- true
- Source code: input/Mouse.js (Line 89)
- MouseEvent | null
- Source code: input/Mouse.js (Line 115)
- Source code: input/Mouse.js (Line 26)
- Internal:
- This member is internal (protected) and may be modified or removed in the future.
- Source code: input/Mouse.js (Line 32)
- Source code: input/Mouse.js (Line 95)
- Source code: input/Mouse.js (Line 42)
- Source code: input/Mouse.js (Line 52)
- Source code: input/Mouse.js (Line 57)
- Source code: input/Mouse.js (Line 47)
- Source code: input/Mouse.js (Line 62)
- Source code: input/Mouse.js (Line 107)
- Source code: input/Mouse.js (Line 101)
- Source code: input/Mouse.js (Line 82)
[static] BACK_BUTTON : number
[static] FORWARD_BUTTON : number
[static] LEFT_BUTTON : number
[static] MIDDLE_BUTTON : number
[static] NO_BUTTON : number
[static] RIGHT_BUTTON : number
[static] WHEEL_DOWN : number
[static] WHEEL_UP : number
button : number
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.
callbackContext : Object
The context under which callbacks are called.
capture : boolean
If true the DOM mouse events will have event.preventDefault applied to them, if false they will propagate fully.
enabled : boolean
Mouse input will only be processed if enabled.
event :MouseEvent | null
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.
Type
game : Phaser.Game
A reference to the currently running game.
<internal> input : Phaser.Input
A reference to the Phaser Input Manager.
locked : boolean
If the mouse has been Pointer Locked successfully this will be set to true.
mouseDownCallback : Function
A callback that can be fired when the mouse is pressed down.
mouseOutCallback : Function
A callback that can be fired when the mouse is no longer over the game canvas.
mouseOverCallback : Function
A callback that can be fired when the mouse enters the game canvas (usually after a mouseout).
mouseUpCallback : Function
A callback that can be fired when the mouse is released from a pressed down state.
mouseWheelCallback : Function
A callback that can be fired when the mousewheel is used.
pointerLock : Phaser.Signal
This event is dispatched when the browser enters or leaves pointer lock state.
stopOnGameOut : boolean
If true Pointer.stop will be called if the mouse leaves the game canvas.
wheelDelta : number
The direction of the last mousewheel usage 1 for up -1 for down.
Public Methods
- Source code: input/Mouse.js (Line 296)
- Source code: input/Mouse.js (Line 326)
- Source code: input/Mouse.js (Line 444)
- Source code: input/Mouse.js (Line 408)
- Source code: input/Mouse.js (Line 480)
- Source code: input/Mouse.js (Line 356)
- Source code: input/Mouse.js (Line 386)
- Source code: input/Mouse.js (Line 504)
- Source code: input/Mouse.js (Line 562)
- Source code: input/Mouse.js (Line 587)
- Source code: input/Mouse.js (Line 533)
- Source code: input/Mouse.js (Line 212)
- Source code: input/Mouse.js (Line 603)
onMouseDown(event)
The internal method that handles the mouse down event from the browser.
Parameters
Name | Type | Description |
---|---|---|
event | MouseEvent | The native event from the browser. This gets stored in Mouse.event. |
onMouseMove(event)
The internal method that handles the mouse move event from the browser.
Parameters
Name | Type | Description |
---|---|---|
event | MouseEvent | The native event from the browser. This gets stored in Mouse.event. |
onMouseOut(event)
The internal method that handles the mouse out event from the browser.
Parameters
Name | Type | Description |
---|---|---|
event | MouseEvent | The native event from the browser. This gets stored in Mouse.event. |
onMouseOutGlobal(event)
The internal method that handles the mouse out event from the window.
Parameters
Name | Type | Description |
---|---|---|
event | MouseEvent | The native event from the browser. This gets stored in Mouse.event. |
onMouseOver(event)
The internal method that handles the mouse over event from the browser.
Parameters
Name | Type | Description |
---|---|---|
event | MouseEvent | The native event from the browser. This gets stored in Mouse.event. |
onMouseUp(event)
The internal method that handles the mouse up event from the browser.
Parameters
Name | Type | Description |
---|---|---|
event | MouseEvent | The native event from the browser. This gets stored in Mouse.event. |
onMouseUpGlobal(event)
The internal method that handles the mouse up event from the window.
Parameters
Name | Type | Description |
---|---|---|
event | MouseEvent | The native event from the browser. This gets stored in Mouse.event. |
onMouseWheel(event)
The internal method that handles the mouse wheel event from the browser.
Parameters
Name | Type | Description |
---|---|---|
event | MouseEvent | The native event from the browser. |
pointerLockChange(event)
Internal pointerLockChange handler.
Parameters
Name | Type | Description |
---|---|---|
event | Event | The native event from the browser. This gets stored in Mouse.event. |
releasePointerLock()
Internal release pointer lock handler.
requestPointerLock()
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'.
start()
Starts the event listeners running.
stop()
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