new SinglePad(game, padParent)
Parameters:
Name | Type | Description |
---|---|---|
game |
Phaser.Game | Current game instance. |
padParent |
Object | The parent Phaser.Gamepad object (all gamepads reside under this) |
- Source:
Members
-
_index
-
- Default Value:
- null
- Source:
Properties:
Name Type Description index
number The gamepad index as per browsers data
-
_padParent
-
- Source:
Properties:
Name Type Description padParent
Phaser.Gamepad Main Phaser Gamepad object
-
callbackContext
-
- Source:
Properties:
Name Type Description callbackContext
Object The context under which the callbacks are run.
-
<readonly> connected
-
Whether or not this particular gamepad is connected or not.
- Source:
Properties:
Name Type Description connected
boolean Whether or not this particular gamepad is connected or not.
-
deadZone
-
- Source:
Properties:
Name Type Description deadZone
number Dead zone for axis feedback - within this value you won't trigger updates.
-
game
-
- Source:
Properties:
Name Type Description game
Phaser.Game Local reference to game.
-
<readonly> index
-
Gamepad index as per browser data
- Source:
Properties:
Name Type Description index
number The gamepad index, used to identify specific gamepads in the browser
-
onAxisCallback
-
- Source:
Properties:
Name Type Description onAxisCallback
function This callback is invoked every time an axis is changed.
-
onConnectCallback
-
- Source:
Properties:
Name Type Description onConnectCallback
function This callback is invoked every time this gamepad is connected
-
onDisconnectCallback
-
- Source:
Properties:
Name Type Description onDisconnectCallback
function This callback is invoked every time this gamepad is disconnected
-
onDownCallback
-
- Source:
Properties:
Name Type Description onDownCallback
function This callback is invoked every time a button is pressed down.
-
onFloatCallback
-
- Source:
Properties:
Name Type Description onFloatCallback
function This callback is invoked every time a button is changed to a value where value > 0 and value < 1.
-
onUpCallback
-
- Source:
Properties:
Name Type Description onUpCallback
function This callback is invoked every time a gamepad button is released.
Methods
-
addButton(buttonCode) → {Phaser.GamepadButton}
-
If you need more fine-grained control over a Key you can create a new Phaser.Key object via this method. The Key object can then be polled, have events attached to it, etc.
Parameters:
Name Type Description buttonCode
number The buttonCode of the button, i.e. Phaser.Gamepad.BUTTON_0 or Phaser.Gamepad.BUTTON_1
- Source:
Returns:
The GamepadButton object which you can store locally and reference directly.
- Type
- Phaser.GamepadButton
-
buttonValue(buttonCode) → {boolean}
-
Returns the value of a gamepad button. Intended mainly for cases when you have floating button values, for example analog trigger buttons on the XBOX 360 controller
Parameters:
Name Type Description buttonCode
number The buttonCode of the button to check.
- Source:
Returns:
Button value if available otherwise false.
- Type
- boolean
-
connect(rawPad)
-
Gamepad connect function, should be called by Phaser.Gamepad
Parameters:
Name Type Description rawPad
Object The raw gamepad object
- Source:
-
disconnect()
-
Gamepad disconnect function, should be called by Phaser.Gamepad
- Source:
-
isDown(axisCode) → {number}
-
Returns value of requested axis
Parameters:
Name Type Description axisCode
number The index of the axis to check
- Source:
Returns:
Axis value if available otherwise false
- Type
- number
-
isDown(buttonCode) → {boolean}
-
Returns true if the button is currently pressed down.
Parameters:
Name Type Description buttonCode
number The buttonCode of the key to check.
- Source:
Returns:
True if the key is currently down.
- Type
- boolean
-
justPressed(buttonCode, duration) → {boolean}
-
Returns the "just released" state of a button from this gamepad. Just released is considered as being true if the button was released within the duration given (default 250ms).
Parameters:
Name Type Argument Default Description buttonCode
number The buttonCode of the button to check for.
duration
number <optional>
250 The duration below which the button is considered as being just released.
- Source:
Returns:
True if the button is just released otherwise false.
- Type
- boolean
-
justPressed(buttonCode, duration) → {boolean}
-
Returns the "just pressed" state of a button from this gamepad. Just pressed is considered true if the button was pressed down within the duration given (default 250ms).
Parameters:
Name Type Argument Default Description buttonCode
number The buttonCode of the button to check for.
duration
number <optional>
250 The duration below which the button is considered as being just pressed.
- Source:
Returns:
True if the button is just pressed otherwise false.
- Type
- boolean
-
pollStatus()
-
Main update function, should be called by Phaser.Gamepad
- Source:
-
processAxisChange(axisState)
-
Handles changes in axis
Parameters:
Name Type Description axisState
Object State of the relevant axis
- Source:
-
processButtonDown(buttonCode, value)
-
Handles button down press
Parameters:
Name Type Description buttonCode
number Which buttonCode of this button
value
Object Button value
- Source:
-
processButtonFloat(buttonCode, value)
-
Handles buttons with floating values (like analog buttons that acts almost like an axis but still registers like a button)
Parameters:
Name Type Description buttonCode
number Which buttonCode of this button
value
Object Button value (will range somewhere between 0 and 1, but not specifically 0 or 1.
- Source:
-
processButtonUp(buttonCode, value)
-
Handles button release
Parameters:
Name Type Description buttonCode
number Which buttonCode of this button
value
Object Button value
- Source:
-
reset()
-
Reset all buttons/axes of this gamepad
- Source: