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

Members

<static, constant> BACK_BUTTON :number

Source - input/Mouse.js, line 190

<static, constant> FORWARD_BUTTON :number

Source - input/Mouse.js, line 196

<static, constant> LEFT_BUTTON :number

Source - input/Mouse.js, line 172

<static, constant> MIDDLE_BUTTON :number

Source - input/Mouse.js, line 178

<static, constant> NO_BUTTON :number

Source - input/Mouse.js, line 166

<static, constant> RIGHT_BUTTON :number

Source - input/Mouse.js, line 184

<static, constant> WHEEL_DOWN :number

Source - input/Mouse.js, line 208

<static, constant> WHEEL_UP :number

Source - input/Mouse.js, line 202

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.

Source - input/Mouse.js, line 76

callbackContext :object

The context under which callbacks are called.

Source - input/Mouse.js, line 37

capture :boolean

If true the DOM mouse events will have event.preventDefault applied to them, if false they will propagate fully.

Source - input/Mouse.js, line 67

enabled :boolean

Mouse input will only be processed if enabled.

Default Value:
  • true
Source - input/Mouse.js, line 89

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 - input/Mouse.js, line 115

game :Phaser.Game

A reference to the currently running game.

Source - input/Mouse.js, line 26

<internal> input :Phaser.Input

A reference to the Phaser Input Manager.

Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - input/Mouse.js, line 32

locked :boolean

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

Source - input/Mouse.js, line 95

mouseDownCallback :function

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

Source - input/Mouse.js, line 42

mouseOutCallback :function

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

Source - input/Mouse.js, line 52

mouseOverCallback :function

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

Source - input/Mouse.js, line 57

mouseUpCallback :function

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

Source - input/Mouse.js, line 47

mouseWheelCallback :function

A callback that can be fired when the mousewheel is used.

Source - input/Mouse.js, line 62

pointerLock :Phaser.Signal

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

Source - input/Mouse.js, line 107

stopOnGameOut :boolean

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

Source - input/Mouse.js, line 101

wheelDelta :number

The direction of the last mousewheel usage 1 for up -1 for down.

Source - input/Mouse.js, line 82

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 296

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 326

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 444

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 - input/Mouse.js, line 408

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 480

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 356

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 386

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 504

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 562

releasePointerLock()

Internal release pointer lock handler.

Source - input/Mouse.js, line 587

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 533

start()

Starts the event listeners running.

Source - input/Mouse.js, line 212

stop()

Stop the event listeners.

Source - input/Mouse.js, line 603
Phaser Copyright © 2012-2016 Photon Storm Ltd.
Documentation generated by JSDoc 3.4.0 on Fri Aug 26 2016 01:16:14 GMT+0100 (BST) using the DocStrap template.