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.
Parameters:
Name | Type | Description |
---|---|---|
game |
Phaser.Game | A reference to the currently running game. |
- Source - input/Mouse.js, line 17
Members
-
<static, constant> LEFT_BUTTON :number
-
- Source - input/Mouse.js, line 163
-
<static, constant> MIDDLE_BUTTON :number
-
- Source - input/Mouse.js, line 169
-
<static, constant> NO_BUTTON :number
-
- Source - input/Mouse.js, line 157
-
<static, constant> RIGHT_BUTTON :number
-
- Source - input/Mouse.js, line 175
-
<static, constant> WHEEL_DOWN :number
-
- Source - input/Mouse.js, line 187
-
<static, constant> WHEEL_UP :number
-
- Source - input/Mouse.js, line 181
-
button
-
- Source - input/Mouse.js, line 68
Properties:
Name Type Description button-
number The type of click, either: Phaser.Mouse.NO_BUTTON, Phaser.Mouse.LEFT_BUTTON, Phaser.Mouse.MIDDLE_BUTTON or Phaser.Mouse.RIGHT_BUTTON.
-
callbackContext :Object
-
The context under which callbacks are called.
- Source - input/Mouse.js, line 27
-
capture :boolean
-
If true the DOM mouse events will have event.preventDefault applied to them, if false they will propogate fully.
- Source - input/Mouse.js, line 62
-
enabled :boolean
-
Mouse input will only be processed if enabled.
- Default Value:
- true
- Source - input/Mouse.js, line 80
-
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:
- MouseEvent | null
- Default Value:
- null
- Source - input/Mouse.js, line 106
-
game :Phaser.Game
-
A reference to the currently running game.
- Source - input/Mouse.js, line 22
-
locked :boolean
-
If the mouse has been Pointer Locked successfully this will be set to true.
- Default Value:
- false
- Source - input/Mouse.js, line 86
-
mouseDownCallback :function
-
A callback that can be fired when the mouse is pressed down.
- Source - input/Mouse.js, line 32
-
mouseMoveCallback :function
-
A callback that can be fired when the mouse is moved while pressed down.
- Source - input/Mouse.js, line 37
-
mouseOutCallback :function
-
A callback that can be fired when the mouse is no longer over the game canvas.
- Source - input/Mouse.js, line 47
-
mouseOverCallback :function
-
A callback that can be fired when the mouse enters the game canvas (usually after a mouseout).
- Source - input/Mouse.js, line 52
-
mouseUpCallback :function
-
A callback that can be fired when the mouse is released from a pressed down state.
- Source - input/Mouse.js, line 42
-
mouseWheelCallback :function
-
A callback that can be fired when the mousewheel is used.
- Source - input/Mouse.js, line 57
-
pointerLock :Phaser.Signal
-
This event is dispatched when the browser enters or leaves pointer lock state.
- Source - input/Mouse.js, line 98
-
stopOnGameOut :boolean
-
If true Pointer.stop will be called if the mouse leaves the game canvas.
- Default Value:
- false
- Source - input/Mouse.js, line 92
-
wheelDelta :number
-
The direction of the last mousewheel usage 1 for up -1 for down
- Source - input/Mouse.js, line 73
Methods
-
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.
- Source - input/Mouse.js, line 267
-
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.
- Source - input/Mouse.js, line 299
-
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.
- Source - input/Mouse.js, line 385
-
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.
- Source - input/Mouse.js, line 450
-
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.
- Source - input/Mouse.js, line 329
-
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.
- Source - input/Mouse.js, line 361
-
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.
- Source - input/Mouse.js, line 421
-
pointerLockChange(event)
-
Internal pointerLockChange handler.
Parameters:
Name Type Description event
Event The native event from the browser. This gets stored in Mouse.event.
- Source - input/Mouse.js, line 508
-
releasePointerLock()
-
Internal release pointer lock handler.
- Source - input/Mouse.js, line 533
-
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'.
- Source - input/Mouse.js, line 479
-
start()
-
Starts the event listeners running.
- Source - input/Mouse.js, line 191
-
stop()
-
Stop the event listeners.
- Source - input/Mouse.js, line 549