Skip to content

Commit

Permalink
FlxGamepad: add getAnalogAxes() (#2064)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nihal Talur authored and Gama11 committed May 9, 2017
1 parent e812b1b commit 92efe1b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion flixel/input/gamepad/FlxGamepad.hx
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ class FlxGamepad implements IFlxDestroyable

/**
* Given a ButtonID for an analog stick, gets the value of its y axis
* @param AxesButtonID an analog stick FlxGamepadButtonID.LEFT_STICK
* @param AxesButtonID an analog stick like FlxGamepadButtonID.LEFT_STICK
*/
public inline function getYAxis(AxesButtonID:FlxGamepadInputID):Float
{
Expand All @@ -614,6 +614,17 @@ class FlxGamepad implements IFlxDestroyable
{
return getAnalogYAxisValue(Stick);
}

/**
* Convenience method that wraps `getXAxis()` and `getYAxis()` into a `FlxVector`.
*
* @param AxesButtonID an analog stick like `FlxGamepadButtonID.LEFT_STICK`
* @since 4.3.0
*/
public function getAnalogAxes(AxesButtonID:FlxGamepadInputID):FlxVector
{
return FlxVector.get(getXAxis(AxesButtonID), getYAxis(AxesButtonID));
}

/**
* Whether any buttons have the specified input state.
Expand Down

0 comments on commit 92efe1b

Please sign in to comment.