WASD controls for animation

This commit is contained in:
Cameron Taylor 2021-06-04 12:53:53 -04:00
parent 2a2fd39d1c
commit 1301cf3ab6
2 changed files with 53 additions and 18 deletions

View file

@ -160,7 +160,7 @@ class TitleState extends MusicBeatState
#elseif STAGEBUILD #elseif STAGEBUILD
FlxG.switchState(new StageBuilderState()); FlxG.switchState(new StageBuilderState());
#elseif ANIMDEBUG #elseif ANIMDEBUG
FlxG.switchState(new DebugBoundingState()); FlxG.switchState(new ui.animDebugShit.DebugBoundingState());
#else #else
new FlxTimer().start(1, function(tmr:FlxTimer) new FlxTimer().start(1, function(tmr:FlxTimer)
{ {

View file

@ -1,4 +1,4 @@
package; package ui.animDebugShit;
import flixel.FlxCamera; import flixel.FlxCamera;
import flixel.FlxG; import flixel.FlxG;
@ -47,6 +47,7 @@ class DebugBoundingState extends FlxState
var curView:ANIMDEBUGVIEW = SPRITESHEET; var curView:ANIMDEBUGVIEW = SPRITESHEET;
var spriteSheetView:FlxGroup; var spriteSheetView:FlxGroup;
var offsetView:FlxGroup;
var animDropDownMenu:FlxUIDropDownMenu; var animDropDownMenu:FlxUIDropDownMenu;
var dropDownSetup:Bool = false; var dropDownSetup:Bool = false;
@ -65,27 +66,13 @@ class DebugBoundingState extends FlxState
add(bg); add(bg);
initSpritesheetView(); initSpritesheetView();
initOffsetView();
// charInput = new FlxInputText(300, 10, 150, "bf", 16); // charInput = new FlxInputText(300, 10, 150, "bf", 16);
// charInput.focusCam = hudCam; // charInput.focusCam = hudCam;
// charInput.cameras = [hudCam]; // charInput.cameras = [hudCam];
// charInput.scrollFactor.set(); // charInput.scrollFactor.set();
animDropDownMenu = new FlxUIDropDownMenu(370, 20, FlxUIDropDownMenu.makeStrIdLabelArray(['weed'], true));
animDropDownMenu.cameras = [hudCam];
add(animDropDownMenu);
var characters:Array<String> = CoolUtil.coolTextFile(Paths.txt('characterList'));
charInput = new FlxUIDropDownMenu(200, 20, FlxUIDropDownMenu.makeStrIdLabelArray(characters, true), function(str:String)
{
loadAnimShit(characters[Std.parseInt(str)]);
// trace();
});
// charInput.
charInput.cameras = [hudCam];
add(charInput);
super.create(); super.create();
} }
@ -145,6 +132,27 @@ class DebugBoundingState extends FlxState
}); });
} }
function initOffsetView():Void
{
offsetView = new FlxGroup();
add(offsetView);
animDropDownMenu = new FlxUIDropDownMenu(370, 20, FlxUIDropDownMenu.makeStrIdLabelArray(['weed'], true));
animDropDownMenu.cameras = [hudCam];
offsetView.add(animDropDownMenu);
var characters:Array<String> = CoolUtil.coolTextFile(Paths.txt('characterList'));
charInput = new FlxUIDropDownMenu(200, 20, FlxUIDropDownMenu.makeStrIdLabelArray(characters, true), function(str:String)
{
loadAnimShit(characters[Std.parseInt(str)]);
// trace();
});
// charInput.
charInput.cameras = [hudCam];
offsetView.add(charInput);
}
function addInfo(str:String, value:Dynamic) function addInfo(str:String, value:Dynamic)
{ {
var swagText:FlxText = new FlxText(10, 10 + (28 * txtGrp.length)); var swagText:FlxText = new FlxText(10, 10 + (28 * txtGrp.length));
@ -184,8 +192,12 @@ class DebugBoundingState extends FlxState
{ {
case SPRITESHEET: case SPRITESHEET:
spriteSheetView.visible = true; spriteSheetView.visible = true;
offsetView.visible = false;
offsetView.active = false;
case OFFSETSHIT: case OFFSETSHIT:
spriteSheetView.visible = false; spriteSheetView.visible = false;
offsetView.visible = true;
offsetView.active = true;
offsetControls(); offsetControls();
} }
@ -209,14 +221,37 @@ class DebugBoundingState extends FlxState
{ {
if (FlxG.keys.justPressed.RBRACKET) if (FlxG.keys.justPressed.RBRACKET)
{ {
if (Std.parseInt(animDropDownMenu.selectedId) + 1 < animDropDownMenu.length) if (Std.parseInt(animDropDownMenu.selectedId) + 1 <= animDropDownMenu.length)
animDropDownMenu.selectedId = Std.string(Std.parseInt(animDropDownMenu.selectedId) + 1); animDropDownMenu.selectedId = Std.string(Std.parseInt(animDropDownMenu.selectedId) + 1);
else
animDropDownMenu.selectedId = Std.string(0);
animDropDownMenu.callback(animDropDownMenu.selectedId); animDropDownMenu.callback(animDropDownMenu.selectedId);
} }
if (FlxG.keys.justPressed.LBRACKET) if (FlxG.keys.justPressed.LBRACKET)
{ {
if (Std.parseInt(animDropDownMenu.selectedId) - 1 >= 0) if (Std.parseInt(animDropDownMenu.selectedId) - 1 >= 0)
animDropDownMenu.selectedId = Std.string(Std.parseInt(animDropDownMenu.selectedId) - 1); animDropDownMenu.selectedId = Std.string(Std.parseInt(animDropDownMenu.selectedId) - 1);
else
animDropDownMenu.selectedId = Std.string(animDropDownMenu.length - 1);
animDropDownMenu.callback(animDropDownMenu.selectedId);
}
if (FlxG.keys.justPressed.W || FlxG.keys.justPressed.S || FlxG.keys.justPressed.D || FlxG.keys.justPressed.A)
{
var missShit:String = '';
if (FlxG.keys.pressed.SHIFT)
missShit = 'miss';
if (FlxG.keys.justPressed.W)
animDropDownMenu.selectedLabel = 'singUP' + missShit;
if (FlxG.keys.justPressed.S)
animDropDownMenu.selectedLabel = 'singDOWN' + missShit;
if (FlxG.keys.justPressed.A)
animDropDownMenu.selectedLabel = 'singLEFT' + missShit;
if (FlxG.keys.justPressed.D)
animDropDownMenu.selectedLabel = 'singRIGHT' + missShit;
animDropDownMenu.callback(animDropDownMenu.selectedId); animDropDownMenu.callback(animDropDownMenu.selectedId);
} }