A single Phaser Gamepad
Name | Type | Description |
---|---|---|
game | Phaser.Game | Current game instance. |
padParent | object | The parent Phaser.Gamepad object (all gamepads reside under this) |
The context under which the callbacks are run.
Whether or not this particular gamepad is connected or not.
Dead zone for axis feedback - within this value you won't trigger updates.
Local reference to game.
The gamepad index as per browsers data
This callback is invoked every time an axis is changed.
This callback is invoked every time this gamepad is connected
This callback is invoked every time this gamepad is disconnected
This callback is invoked every time a button is pressed down.
This callback is invoked every time a button is changed to a value where value > 0 and value < 1.
This callback is invoked every time a gamepad button is released.
Add callbacks to this Gamepad to handle connect / disconnect / button down / button up / axis change / float value buttons.
Name | Type | Description |
---|---|---|
context | object | The context under which the callbacks are run. |
callbacks | object | Object that takes six different callbak methods: |
Returns value of requested axis.
Name | Type | Description |
---|---|---|
axisCode | number | The index of the axis to check |
Axis value if available otherwise false
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.
Name | Type | Description |
---|---|---|
buttonCode | number | The buttonCode of the button to check. |
Button value if available otherwise null. Be careful as this can incorrectly evaluate to 0.
Gamepad connect function, should be called by Phaser.Gamepad.
Name | Type | Description |
---|---|---|
rawPad | object | The raw gamepad object |
Destroys this object and associated callback references.
Gamepad disconnect function, should be called by Phaser.Gamepad.
Gets a DeviceButton object from this controller to be stored and referenced locally.
The DeviceButton object can then be polled, have events attached to it, etc.
Name | Type | Description |
---|---|---|
buttonCode | number | The buttonCode of the button, i.e. Phaser.Gamepad.BUTTON_0, Phaser.Gamepad.XBOX360_A, etc. |
The DeviceButton object which you can store locally and reference directly.
Returns true if the button is pressed down.
Name | Type | Description |
---|---|---|
buttonCode | number | The buttonCode of the button to check. |
True if the button is pressed down.
Returns true if the button is not currently pressed.
Name | Type | Description |
---|---|---|
buttonCode | number | The buttonCode of the button to check. |
True if the button is not currently pressed down.
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).
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. |
True if the button is just pressed otherwise false.
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).
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. |
True if the button is just released otherwise false.
Main update function called by Phaser.Gamepad.
Handles changes in axis.
Name | Type | Description |
---|---|---|
axisState | object | State of the relevant axis |
Handles button down press.
Name | Type | Description |
---|---|---|
buttonCode | number | Which buttonCode of this button |
value | object | Button value |
Handles buttons with floating values (like analog buttons that acts almost like an axis but still registers like a button)
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. |
Handles button release.
Name | Type | Description |
---|---|---|
buttonCode | number | Which buttonCode of this button |
value | object | Button value |
Reset all buttons/axes of this gamepad.
© 2016 Richard Davey, Photon Storm Ltd.
Licensed under the MIT License.
http://phaser.io/docs/2.6.2/Phaser.SinglePad.html