From 784c2c4f625138eaf69eddc84a9a0327b7ad8d31 Mon Sep 17 00:00:00 2001 From: Rain Clark Date: Wed, 5 Oct 2016 08:06:11 -0400 Subject: [PATCH] Added Gamepad support :video_game: --- source/HUD.hx | 11 +++++++---- source/MenuState.hx | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/source/HUD.hx b/source/HUD.hx index 571055c..cf582f4 100644 --- a/source/HUD.hx +++ b/source/HUD.hx @@ -6,6 +6,7 @@ import flixel.group.FlxGroup; import flixel.system.FlxSound; import flixel.text.FlxText; import flixel.util.FlxColor; +import flixel.input.gamepad.FlxGamepad; using flixel.util.FlxSpriteUtil; @@ -159,14 +160,15 @@ class HUD extends FlxTypedGroup { super.update(elapsed); - if (FlxG.keys.justPressed.RIGHT) + // TODO: Add WASD support? + // TODO: Add vertical menu movent + if (FlxG.keys.justPressed.RIGHT || FlxG.gamepads.anyJustPressed(DPAD_RIGHT)) nextOption(true); - else if (FlxG.keys.justPressed.LEFT) + else if (FlxG.keys.justPressed.LEFT || FlxG.gamepads.anyJustPressed(DPAD_LEFT)) nextOption(false); - else if (FlxG.keys.justPressed.X) + else if (FlxG.keys.justPressed.X || FlxG.gamepads.anyJustPressed(B)) makeOption(_menuOption); - _gel.update(elapsed); if (_gel.CurrentMood == Gel.Mood.NEUTRAL) @@ -189,6 +191,7 @@ class HUD extends FlxTypedGroup private function nextOption(increment:Bool):Void { + // TODO: Add vertical menu movent if (increment) { if (_menuOption >= 7) diff --git a/source/MenuState.hx b/source/MenuState.hx index b865e0f..12c14d6 100644 --- a/source/MenuState.hx +++ b/source/MenuState.hx @@ -50,7 +50,7 @@ class MenuState extends FlxState override public function update(elapsed:Float):Void { - if(FlxG.keys.pressed.ENTER) + if(FlxG.keys.pressed.ENTER || FlxG.gamepads.anyJustPressed(START)) pressStart(); super.update(elapsed);