From 32df13aedfe41c04c699646d09567b0a3b08e3b3 Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 26 Oct 2020 19:06:42 -0400 Subject: [PATCH] switch setup start [REAL] --- Project.xml | 6 +++++- source/FreeplayState.hx | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Project.xml b/Project.xml index dcde8dc16..5d0c0ee71 100644 --- a/Project.xml +++ b/Project.xml @@ -25,6 +25,9 @@ + + + @@ -91,5 +94,6 @@ - + + diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx index f745d5da6..7474830a8 100644 --- a/source/FreeplayState.hx +++ b/source/FreeplayState.hx @@ -5,6 +5,13 @@ import flixel.FlxSprite; import flixel.addons.display.FlxGridOverlay; import flixel.text.FlxText; +#if switch + import openfl.events.GameInputEvent; + import openfl.ui.GameInput; + import openfl.ui.GameInputDevice; + import openfl.ui.GameInputControl; +#end + class FreeplayState extends MusicBeatState { var songs:Array = ["Bopeebo", "Dadbattle", "Fresh", "Tutorial\nlol"]; @@ -48,6 +55,17 @@ class FreeplayState extends MusicBeatState curSelected += 1; } + #if switch + if (gamepad.anyJustPressed(["UP", "DPAD_UP", "LEFT_STICK_DIGITAL_UP"])) + { + curSelected -= 1; + } + if (gamepad.anyJustPressed(["DOWN", "DPAD_DOWN", "LEFT_STICK_DIGITAL_DOWN"])) + { + curSelected += 1; + } + #end + if (curSelected < 0) curSelected = songs.length - 1; if (curSelected >= songs.length) @@ -61,6 +79,14 @@ class FreeplayState extends MusicBeatState FlxG.switchState(new PlayState()); } + #if switch + if (gamepad.anyJustPressed(["B"])) //"B" is swapped with "A" on Switch + { + PlayState.SONG = Song.loadFromJson(songs[curSelected].toLowerCase()); + FlxG.switchState(new PlayState()); + } + #end + super.update(elapsed); } }