Class: Mouse

Phaser. Mouse

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:
src/input/Mouse.js line 21

Members

<static, constant> BACK_BUTTON : number

Type:
  • number
Source:
src/input/Mouse.js line 156

<static, constant> FORWARD_BUTTON : number

Type:
  • number
Source:
src/input/Mouse.js line 162

<static, constant> LEFT_BUTTON : number

Type:
  • number
Source:
src/input/Mouse.js line 138

<static, constant> MIDDLE_BUTTON : number

Type:
  • number
Source:
src/input/Mouse.js line 144

<static, constant> NO_BUTTON : number

Type:
  • number
Source:
src/input/Mouse.js line 132

<static, constant> RIGHT_BUTTON : number

Type:
  • number
Source:
src/input/Mouse.js line 150

<static, constant> WHEEL_DOWN : number deprecated

Type:
  • number
Deprecated:
  • Yes
Source:
src/input/Mouse.js line 178
See:

<static, constant> WHEEL_UP : number deprecated

Type:
  • number
Deprecated:
  • Yes
Source:
src/input/Mouse.js line 170
See:

<readonly> active

Properties:
Type Description
boolean

Whether the handler has started.

Source:
src/input/Mouse.js line 71
See:

callbackContext : object

The context under which callbacks are called.

Type:
  • object
Source:
src/input/Mouse.js line 38

capture : boolean

If true the DOM mouse events will have event.preventDefault applied to them.

Type:
  • boolean
Source:
src/input/Mouse.js line 63

enabled : boolean

Whether mouse input is passed to the Input Manager and Mouse Pointer. When enabled is false, game.input and game.input.mousePointer are not updated by this handler. The handler is still running and will call any added callbacks and apply Phaser.Mouse#capture.

Type:
  • boolean
Default Value:
  • true
Source:
src/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
Source:
src/input/Mouse.js line 94

game : Phaser.Game

A reference to the currently running game.

Type:
Source:
src/input/Mouse.js line 27

<protected> input : Phaser.Input

A reference to the Phaser Input Manager.

Type:
Source:
src/input/Mouse.js line 33

locked : boolean deprecated

If the mouse has been Pointer Locked successfully this will be set to true.

Type:
  • boolean
Deprecated:
  • Yes
Source:
src/input/Mouse.js line 548
See:

mouseDownCallback : function

A callback that can be fired when the mouse is pressed down.

Type:
  • function
Source:
src/input/Mouse.js line 43

mouseOutCallback : function

A callback that can be fired when the mouse is no longer over the game canvas.

Type:
  • function
Source:
src/input/Mouse.js line 53

mouseOverCallback : function

A callback that can be fired when the mouse enters the game canvas (usually after a mouseout).

Type:
  • function
Source:
src/input/Mouse.js line 58

mouseUpCallback : function

A callback that can be fired when the mouse is released from a pressed down state.

Type:
  • function
Source:
src/input/Mouse.js line 48

pointerLock : Phaser.Signal deprecated

This event is dispatched when the browser enters or leaves pointer lock state.

Type:
Deprecated:
  • Yes
Source:
src/input/Mouse.js line 566
See:

stopOnGameOut : boolean

If true Pointer.stop will be called if the mouse leaves the game canvas.

Type:
  • boolean
Source:
src/input/Mouse.js line 86

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:
src/input/Mouse.js line 261

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:
src/input/Mouse.js line 292

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:
src/input/Mouse.js line 415

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.

Source:
src/input/Mouse.js line 377

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:
src/input/Mouse.js line 465

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:
src/input/Mouse.js line 323

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:
src/input/Mouse.js line 354

releasePointerLock() deprecated

Exit a pointer-locked state.

Deprecated:
  • Yes
Source:
src/input/Mouse.js line 490
See:

requestPointerLock() deprecated

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'.

Deprecated:
  • Yes
Source:
src/input/Mouse.js line 505
See:

start()

Starts the event listeners running.

Source:
src/input/Mouse.js line 182
Returns:
  • Whether the handler was started.
Type
boolean

stop()

Stop the event listeners.

Source:
src/input/Mouse.js line 522

phaser-ce@2.11.0 is on GitHub and NPM

Documentation generated by JSDoc 3.5.4 on 2018-06-26 using Tomorrow.