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.

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 164

<static, constant> MIDDLE_BUTTON :number

Source - input/Mouse.js, line 170

<static, constant> NO_BUTTON :number

Source - input/Mouse.js, line 158

<static, constant> RIGHT_BUTTON :number

Source - input/Mouse.js, line 176

<static, constant> WHEEL_DOWN :number

Source - input/Mouse.js, line 188

<static, constant> WHEEL_UP :number

Source - input/Mouse.js, line 182

button

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.

Source - input/Mouse.js, line 69

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 propagate fully.

Source - input/Mouse.js, line 63

enabled :boolean

Mouse input will only be processed if enabled.

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

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 107

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 87

mouseDownCallback :function

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

Source - input/Mouse.js, line 32

mouseMoveCallback :function

This method is deprecated and should not be used. It may be removed in the future.

A callback that can be fired when the mouse is moved.

Deprecated:
  • Will be removed soon. Please use `Input.addMoveCallback` instead.
Source - input/Mouse.js, line 38

mouseOutCallback :function

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

Source - input/Mouse.js, line 48

mouseOverCallback :function

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

Source - input/Mouse.js, line 53

mouseUpCallback :function

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

Source - input/Mouse.js, line 43

mouseWheelCallback :function

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

Source - input/Mouse.js, line 58

pointerLock :Phaser.Signal

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

Source - input/Mouse.js, line 99

stopOnGameOut :boolean

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

Default Value:
  • false
Source - input/Mouse.js, line 93

wheelDelta :number

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

Source - input/Mouse.js, line 74

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 269

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 301

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 387

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 452

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 331

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 363

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 423

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 510

releasePointerLock()

Internal release pointer lock handler.

Source - input/Mouse.js, line 535

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 481

start()

Starts the event listeners running.

Source - input/Mouse.js, line 192

stop()

Stop the event listeners.

Source - input/Mouse.js, line 551
Phaser Copyright © 2012-2015 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.0-alpha10 on Thu Mar 26 2015 02:53:53 GMT+0000 (GMT Standard Time) using the DocStrap template.