new GamepadPlugin(sceneInputPlugin)
Parameters:
Name | Type | Description |
---|---|---|
sceneInputPlugin |
Phaser.Input.InputPlugin | A reference to the Scene Input Plugin that the KeyboardPlugin belongs to. |
- Since: 3.10.0
- Source: src/input/gamepad/GamepadPlugin.js (Line 15)
Extends
Members
-
enabled :boolean
-
A boolean that controls if the Gamepad Manager is enabled or not. Can be toggled on the fly.
Type:
- boolean
- Since: 3.10.0
- Default Value:
-
- true
- Source: src/input/gamepad/GamepadPlugin.js (Line 98)
-
gamepads :Array.<Phaser.Input.Gamepad.Gamepad>
-
An array of the connected Gamepads.
Type:
- Array.<Phaser.Input.Gamepad.Gamepad>
- Since: 3.10.0
- Default Value:
-
- []
- Source: src/input/gamepad/GamepadPlugin.js (Line 119)
-
pad1 :Phaser.Input.Gamepad.Gamepad
-
A reference to the first connected Gamepad.
This will be undefined if either no pads are connected, or the browser has not yet issued a gamepadconnect, which can happen even if a Gamepad is plugged in, but hasn't yet had any buttons pressed on it.
Type:
- Since: 3.10.0
- Source: src/input/gamepad/GamepadPlugin.js (Line 548)
-
pad2 :Phaser.Input.Gamepad.Gamepad
-
A reference to the second connected Gamepad.
This will be undefined if either no pads are connected, or the browser has not yet issued a gamepadconnect, which can happen even if a Gamepad is plugged in, but hasn't yet had any buttons pressed on it.
Type:
- Since: 3.10.0
- Source: src/input/gamepad/GamepadPlugin.js (Line 568)
-
pad3 :Phaser.Input.Gamepad.Gamepad
-
A reference to the third connected Gamepad.
This will be undefined if either no pads are connected, or the browser has not yet issued a gamepadconnect, which can happen even if a Gamepad is plugged in, but hasn't yet had any buttons pressed on it.
Type:
- Since: 3.10.0
- Source: src/input/gamepad/GamepadPlugin.js (Line 588)
-
pad4 :Phaser.Input.Gamepad.Gamepad
-
A reference to the fourth connected Gamepad.
This will be undefined if either no pads are connected, or the browser has not yet issued a gamepadconnect, which can happen even if a Gamepad is plugged in, but hasn't yet had any buttons pressed on it.
Type:
- Since: 3.10.0
- Source: src/input/gamepad/GamepadPlugin.js (Line 608)
-
scene :Phaser.Scene
-
A reference to the Scene that this Input Plugin is responsible for.
Type:
- Since: 3.10.0
- Source: src/input/gamepad/GamepadPlugin.js (Line 71)
-
sceneInputPlugin :Phaser.Input.InputPlugin
-
A reference to the Scene Input Plugin that created this Keyboard Plugin.
Type:
- Since: 3.10.0
- Source: src/input/gamepad/GamepadPlugin.js (Line 89)
-
settings :Phaser.Types.Scenes.SettingsObject
-
A reference to the Scene Systems Settings.
Type:
- Since: 3.10.0
- Source: src/input/gamepad/GamepadPlugin.js (Line 80)
-
target :any
-
The Gamepad Event target, as defined in the Game Config. Typically the browser window, but can be any interactive DOM element.
Type:
- any
- Since: 3.10.0
- Source: src/input/gamepad/GamepadPlugin.js (Line 109)
-
total :number
-
The total number of connected game pads.
Type:
- number
- Since: 3.10.0
- Source: src/input/gamepad/GamepadPlugin.js (Line 532)
Methods
-
addListener(event, fn [, context])
-
Add a listener for a given event.
Parameters:
Name Type Argument Default Description event
string | symbol The event name.
fn
function The listener function.
context
* <optional>
this The context to invoke the listener with.
- Since: 3.0.0
- Inherited From:
- Source: src/events/EventEmitter.js (Line 111)
Returns:
this
. -
disconnectAll()
-
Disconnects all current Gamepads.
- Since: 3.10.0
- Source: src/input/gamepad/GamepadPlugin.js (Line 307)
-
emit(event [, args])
-
Calls each of the listeners registered for a given event.
Parameters:
Name Type Argument Description event
string | symbol The event name.
args
* <optional>
<repeatable>
Additional arguments that will be passed to the event handler.
- Since: 3.0.0
- Inherited From:
- Source: src/events/EventEmitter.js (Line 86)
Returns:
true
if the event had listeners, elsefalse
.- Type
- boolean
-
eventNames()
-
Return an array listing the events for which the emitter has registered listeners.
- Since: 3.0.0
- Inherited From:
- Source: src/events/EventEmitter.js (Line 55)
Returns:
- Type
- Array.<(string|symbol)>
-
getAll()
-
Returns an array of all currently connected Gamepads.
- Since: 3.10.0
- Source: src/input/gamepad/GamepadPlugin.js (Line 397)
Returns:
An array of all currently connected Gamepads.
- Type
- Array.<Phaser.Input.Gamepad.Gamepad>
-
getPad(index)
-
Looks-up a single Gamepad based on the given index value.
Parameters:
Name Type Description index
number The index of the Gamepad to get.
- Since: 3.10.0
- Source: src/input/gamepad/GamepadPlugin.js (Line 421)
Returns:
The Gamepad matching the given index, or undefined if none were found.
-
isActive()
-
Checks to see if both this plugin and the Scene to which it belongs is active.
- Since: 3.10.0
- Source: src/input/gamepad/GamepadPlugin.js (Line 234)
Returns:
true
if the plugin and the Scene it belongs to is active.- Type
- boolean
-
listenerCount(event)
-
Return the number of listeners listening to a given event.
Parameters:
Name Type Description event
string | symbol The event name.
- Since: 3.0.0
- Inherited From:
- Source: src/events/EventEmitter.js (Line 75)
Returns:
The number of listeners.
- Type
- number
-
listeners(event)
-
Return the listeners registered for a given event.
Parameters:
Name Type Description event
string | symbol The event name.
- Since: 3.0.0
- Inherited From:
- Source: src/events/EventEmitter.js (Line 64)
Returns:
The registered listeners.
- Type
- Array.<function()>
-
off(event [, fn] [, context] [, once])
-
Remove the listeners of a given event.
Parameters:
Name Type Argument Description event
string | symbol The event name.
fn
function <optional>
Only remove the listeners that match this function.
context
* <optional>
Only remove the listeners that have this context.
once
boolean <optional>
Only remove one-time listeners.
- Since: 3.0.0
- Inherited From:
- Source: src/events/EventEmitter.js (Line 151)
Returns:
this
. -
on(event, fn [, context])
-
Add a listener for a given event.
Parameters:
Name Type Argument Default Description event
string | symbol The event name.
fn
function The listener function.
context
* <optional>
this The context to invoke the listener with.
- Since: 3.0.0
- Inherited From:
- Source: src/events/EventEmitter.js (Line 98)
Returns:
this
. -
once(event, fn [, context])
-
Add a one-time listener for a given event.
Parameters:
Name Type Argument Default Description event
string | symbol The event name.
fn
function The listener function.
context
* <optional>
this The context to invoke the listener with.
- Since: 3.0.0
- Inherited From:
- Source: src/events/EventEmitter.js (Line 124)
Returns:
this
. -
removeAllListeners( [event])
-
Remove all listeners, or those of the specified event.
Parameters:
Name Type Argument Description event
string | symbol <optional>
The event name.
- Since: 3.0.0
- Inherited From:
- Source: src/events/EventEmitter.js (Line 165)
Returns:
this
. -
removeListener(event [, fn] [, context] [, once])
-
Remove the listeners of a given event.
Parameters:
Name Type Argument Description event
string | symbol The event name.
fn
function <optional>
Only remove the listeners that match this function.
context
* <optional>
Only remove the listeners that have this context.
once
boolean <optional>
Only remove one-time listeners.
- Since: 3.0.0
- Inherited From:
- Source: src/events/EventEmitter.js (Line 137)
Returns:
this
.