Class: Input

Input

A game specific Input manager that looks after the mouse, keyboard and touch objects. This is updated by the core game loop.

new Input(game)

Constructor for Phaser Input.

Parameters:
Name Type Description
game Phaser.Game

Current game instance.

Source:

Members

<static, constant> MOUSE_OVERRIDES_TOUCH :number

Type:
  • number
Source:

<static, constant> MOUSE_TOUCH_COMBINE :number

Type:
  • number
Source:

<static, constant> TOUCH_OVERRIDES_MOUSE :number

Type:
  • number
Source:

activePointer

The most recently active Pointer object. When you've limited max pointers to 1 this will accurately be either the first finger touched or mouse.

Properties:
Name Type Description
activePointer Phaser.Pointer
Default Value:
  • null
Source:

circle

A Circle object centered on the x/y screen coordinates of the Input. Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything.

Properties:
Name Type Description
circle Phaser.Circle
Default Value:
  • null
Source:

currentPointers

The current number of active Pointers.

Properties:
Name Type Description
currentPointers number
Default Value:
  • 0
Source:

disabled

You can disable all Input by setting Input.disabled: true. While set all new input related events will be ignored. If you need to disable just one type of input, for example mouse, use Input.mouse.disabled: true instead

Properties:
Name Type Description
disabled boolean
Default Value:
  • false
Source:

doubleTapRate

The number of milliseconds between taps of the same Pointer for it to be considered a double tap / click

Properties:
Name Type Description
doubleTapRate number
Default Value:
  • 300
Source:

game

Properties:
Name Type Description
game Phaser.Game

A reference to the currently running game.

Source:

game

Properties:
Name Type Description
game Phaser.Game
Source:

hitCanvas

Properties:
Name Type Description
hitCanvas Description

Description.

Default Value:
  • null
Source:

hitContext

Properties:
Name Type Description
hitContext Description

Description.

Default Value:
  • null
Source:

holdRate

The number of milliseconds that the Pointer has to be pressed down for it to fire a onHold event

Properties:
Name Type Description
holdRate number
Default Value:
  • 2000
Source:

interactiveItems

A linked list of interactive objects, the InputHandler components (belonging to Sprites) register themselves with this.

Properties:
Name Type Description
interactiveItems Phaser.LinkedList
Source:

justPressedRate

The number of milliseconds below which the Pointer is considered justPressed

Properties:
Name Type Description
justPressedRate number
Default Value:
  • 200
Source:

justReleasedRate

The number of milliseconds below which the Pointer is considered justReleased

Properties:
Name Type Description
justReleasedRate number
Default Value:
  • 200
Source:

keyboard

The Keyboard Input manager.

Properties:
Name Type Description
keyboard Phaser.Keyboard

The Keyboard Input manager.

Default Value:
  • null
Source:

maxPointers

The maximum number of Pointers allowed to be active at any one time. For lots of games it's useful to set this to 1.

Properties:
Name Type Description
maxPointers number
Default Value:
  • 10
Source:

mouse

The Mouse Input manager.

Properties:
Name Type Description
mouse Phaser.Mouse

The Mouse Input manager.

Default Value:
  • null
Source:

mousePointer

The mouse has its own unique Phaser.Pointer object which you can use if making a desktop specific game.

Properties:
Name Type Description
mousePointer Pointer
Default Value:
  • null
Source:

mspointer

The MSPointer Input manager.

Properties:
Name Type Description
mspointer Phaser.MSPointer

The MSPointer Input manager.

Default Value:
  • null
Source:

multiInputOverride

Controls the expected behaviour when using a mouse and touch together on a multi-input device.

Properties:
Name Type Description
multiInputOverride Description
Source:

onDown

A Signal that is dispatched each time a pointer is pressed down.

Properties:
Name Type Description
onDown Phaser.Signal
Default Value:
  • null
Source:

onHold

A Signal that is dispatched each time a pointer is held down.

Properties:
Name Type Description
onHold Phaser.Signal
Default Value:
  • null
Source:

onTap

A Signal that is dispatched each time a pointer is tapped.

Properties:
Name Type Description
onTap Phaser.Signal
Default Value:
  • null
Source:

onUp

A Signal that is dispatched each time a pointer is released.

Properties:
Name Type Description
onUp Phaser.Signal
Default Value:
  • null
Source:

pointer1

A Pointer object

Properties:
Name Type Description
pointer1 Phaser.Pointer
Source:

pointer2

A Pointer object

Properties:
Name Type Description
pointer2 Phaser.Pointer
Source:

pointer3

A Pointer object

Properties:
Name Type Description
pointer3 Phaser.Pointer
Source:

pointer4

A Pointer object

Properties:
Name Type Description
pointer4 Phaser.Pointer
Source:

pointer5

A Pointer object

Properties:
Name Type Description
pointer5 Phaser.Pointer
Source:

pointer6

A Pointer object

Properties:
Name Type Description
pointer6 Phaser.Pointer
Source:

pointer7

A Pointer object

Properties:
Name Type Description
pointer7 Phaser.Pointer
Source:

pointer8

A Pointer object

Properties:
Name Type Description
pointer8 Phaser.Pointer
Source:

pointer9

A Pointer object

Properties:
Name Type Description
pointer9 Phaser.Pointer
Source:

pointer10

A Pointer object.

Properties:
Name Type Description
pointer10 Phaser.Pointer
Source:

<readonly> pollLocked

Properties:
Name Type Description
pollLocked boolean

True if the Input is currently poll rate locked.

Source:

pollRate

How often should the input pointers be checked for updates? A value of 0 means every single frame (60fps), a value of 1 means every other frame (30fps) and so on.

Properties:
Name Type Description
pollRate number
Default Value:
  • 0
Source:

position

A vector object representing the current position of the Pointer.

Properties:
Name Type Description
position Phaser.Point
Default Value:
  • null
Source:

recordLimit

The total number of entries that can be recorded into the Pointer objects tracking history. If the Pointer is tracking one event every 100ms, then a trackLimit of 100 would store the last 10 seconds worth of history.

Properties:
Name Type Description
recordLimit number
Default Value:
  • 100
Source:

recordPointerHistory

Sets if the Pointer objects should record a history of x/y coordinates they have passed through. The history is cleared each time the Pointer is pressed down. The history is updated at the rate specified in Input.pollRate

Properties:
Name Type Description
recordPointerHistory boolean
Default Value:
  • false
Source:

recordRate

The rate in milliseconds at which the Pointer objects should update their tracking history

Properties:
Name Type Description
recordRate number
Default Value:
  • 100
Source:

scale

The scale by which all input coordinates are multiplied, calculated by the StageScaleMode. In an un-scaled game the values will be x: 1 and y: 1.

Properties:
Name Type Description
scale Phaser.Point
Default Value:
  • null
Source:

speed

A vector object representing the speed of the Pointer. Only really useful in single Pointer games, otherwise see the Pointer objects directly.

Properties:
Name Type Description
speed Phaser.Point
Default Value:
  • null
Source:

tapRate

The number of milliseconds that the Pointer has to be pressed down and then released to be considered a tap or clicke

Properties:
Name Type Description
tapRate number
Default Value:
  • 200
Source:

<readonly> totalActivePointers

The total number of active Pointers

Properties:
Name Type Description
totalActivePointers number

The total number of active Pointers.

Source:

<readonly> totalInactivePointers

The total number of inactive Pointers

Properties:
Name Type Description
totalInactivePointers number

The total number of inactive Pointers.

Source:

touch

The Touch Input manager.

Properties:
Name Type Description
touch Phaser.Touch

the Touch Input manager.

Default Value:
  • null
Source:

worldX

The world X coordinate of the most recently active pointer.

Properties:
Name Type Description
worldX number

The world X coordinate of the most recently active pointer.

Source:

worldY

The world Y coordinate of the most recently active pointer.

Properties:
Name Type Description
worldY number

The world Y coordinate of the most recently active pointer.

Source:

x

The X coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values.

Properties:
Name Type Description
x number

The X coordinate of the most recently active pointer.

Source:

y

The Y coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenY/clientY for source values.

Properties:
Name Type Description
y number

The Y coordinate of the most recently active pointer.

Source:

Methods

addPointer() → {Phaser.Pointer}

Add a new Pointer object to the Input Manager. By default Input creates 3 pointer objects: mousePointer, pointer1 and pointer2. If you need more then use this to create a new one, up to a maximum of 10.

Source:
Returns:

A reference to the new Pointer object that was created.

Type
Phaser.Pointer

<protected> boot()

Starts the Input Manager running.

Source:

getAngle(pointer1, pointer2) → {Description}

Get the angle between two Pointer objects.

Parameters:
Name Type Description
pointer1 Pointer
pointer2 Pointer
Source:
Returns:

Description.

Type
Description

getDistance(pointer1, pointer2) → {Description}

Get the distance between two Pointer objects.

Parameters:
Name Type Description
pointer1 Pointer
pointer2 Pointer
Source:
Returns:

Description.

Type
Description

getPointer(state) → {Phaser.Pointer}

Get the next Pointer object whos active property matches the given state

Parameters:
Name Type Description
state boolean

The state the Pointer should be in (false for inactive, true for active).

Source:
Returns:

A Pointer object or null if no Pointer object matches the requested state.

Type
Phaser.Pointer

getPointerFromIdentifier(identifier) → {Phaser.Pointer}

Get the Pointer object whos identified property matches the given identifier value.

Parameters:
Name Type Description
identifier number

The Pointer.identifier value to search for.

Source:
Returns:

A Pointer object or null if no Pointer object matches the requested identifier.

Type
Phaser.Pointer

reset(hard)

Reset all of the Pointers and Input states

Parameters:
Name Type Description
hard boolean

A soft reset (hard = false) won't reset any Signals that might be bound. A hard reset will.

Source:

resetSpeed(x, y)

Resets the speed and old position properties.

Parameters:
Name Type Description
x number

Sets the oldPosition.x value.

y number

Sets the oldPosition.y value.

Source:

startPointer(event) → {Phaser.Pointer}

Find the first free Pointer object and start it, passing in the event data. This is called automatically by Phaser.Touch and Phaser.MSPointer.

Parameters:
Name Type Description
event Any

The event data from the Touch event.

Source:
Returns:

The Pointer object that was started or null if no Pointer object is available.

Type
Phaser.Pointer

stopPointer(event) → {Phaser.Pointer}

Stops the matching Pointer object, passing in the event data.

Parameters:
Name Type Description
event Any

The event data from the Touch event.

Source:
Returns:

The Pointer object that was stopped or null if no Pointer object is available.

Type
Phaser.Pointer

<protected> update()

Updates the Input Manager. Called by the core Game loop.

Source:

updatePointer(event) → {Phaser.Pointer}

Updates the matching Pointer object, passing in the event data. This is called automatically and should not normally need to be invoked.

Parameters:
Name Type Description
event Any

The event data from the Touch event.

Source:
Returns:

The Pointer object that was updated or null if no Pointer object is available.

Type
Phaser.Pointer
Phaser Copyright © 2012-2013 Photon Storm Ltd.
Documentation generated by JSDoc 3.2.0-dev on Wed Oct 02 2013 16:05:23 GMT+0100 (BST) using the DocStrap template.