Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlxGamepad: add getAnalogAxes() #2064

Merged
merged 3 commits into from May 9, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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