switch setup start [REAL]

This commit is contained in:
Brandon 2020-10-26 19:06:42 -04:00
parent 9a6ca041e7
commit ddd42ca004
3 changed files with 31 additions and 1 deletions

View File

@ -25,6 +25,9 @@
<!--Mobile-specific-->
<window if="mobile" orientation="landscape" fullscreen="true" width="0" height="0" />
<!--Switch-specific-->
<window if="switch" orientation="landscape" fullscreen="true" width="0" height="0" resizable="true" />
<!-- _____________________________ Path Settings ____________________________ -->
<set name="BUILD_DIR" value="export/debug" if="debug" />
@ -91,5 +94,6 @@
<!-- _________________________________ Custom _______________________________ -->
<!--Place custom nodes like icons here (higher priority to override the HaxeFlixel icon)-->
<icon path="art/icon.png"/>
<icon path="art/icon.png" unless="switch" />
<icon path="art/iconSwitch.png" if="switch" />
</project>

BIN
art/iconSwitch.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 KiB

View File

@ -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<String> = ["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);
}
}