From 4211bc7344f9bd84e2840a48a8e4c029b3b3d51a Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 4 Jun 2021 17:39:28 -0400 Subject: [PATCH] mouse movement for offset shit --- source/ui/animDebugShit/DebugBoundingState.hx | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/source/ui/animDebugShit/DebugBoundingState.hx b/source/ui/animDebugShit/DebugBoundingState.hx index 6c391a86c..491b90dd0 100644 --- a/source/ui/animDebugShit/DebugBoundingState.hx +++ b/source/ui/animDebugShit/DebugBoundingState.hx @@ -9,6 +9,7 @@ import flixel.addons.ui.FlxInputText; import flixel.addons.ui.FlxUIDropDownMenu; import flixel.graphics.frames.FlxAtlasFrames; import flixel.group.FlxGroup; +import flixel.math.FlxPoint; import flixel.text.FlxText; import flixel.util.FlxColor; import flixel.util.FlxSpriteUtil; @@ -30,10 +31,7 @@ class DebugBoundingState extends FlxState - Refactor the animation offset menu to be in this one instead - Cleaner UI - Easier to access, test, and export data from. - - Easier movement - - Onion skinning - - Mouse controls?? - - Load different characters on the fly + - Data to show offset positioning */ var bg:FlxSprite; @@ -141,6 +139,7 @@ class DebugBoundingState extends FlxState add(offsetView); onionSkinChar = new FlxSprite().makeGraphic(FlxG.width * 2, FlxG.height * 2, FlxColor.TRANSPARENT); + onionSkinChar.visible = false; offsetView.add(onionSkinChar); animDropDownMenu = new FlxUIDropDownMenu(370, 20, FlxUIDropDownMenu.makeStrIdLabelArray(['weed'], true)); @@ -159,6 +158,30 @@ class DebugBoundingState extends FlxState offsetView.add(charInput); } + public var mouseOffset:FlxPoint = FlxPoint.get(0, 0); + public var oldPos:FlxPoint = FlxPoint.get(0, 0); + + function mouseOffsetMovement() + { + if (swagChar != null) + { + if (FlxG.mouse.justPressed) + { + mouseOffset.set(FlxG.mouse.x - -swagChar.offset.x, FlxG.mouse.y - -swagChar.offset.y); + // oldPos.set(swagChar.offset.x, swagChar.offset.y); + // oldPos.set(FlxG.mouse.x, FlxG.mouse.y); + } + + if (FlxG.mouse.pressed) + { + swagChar.offset.x = (FlxG.mouse.x - mouseOffset.x) * -1; + swagChar.offset.y = (FlxG.mouse.y - mouseOffset.y) * -1; + + swagChar.animOffsets.set(animDropDownMenu.selectedLabel, [swagChar.offset.x, swagChar.offset.y]); + } + } + } + function addInfo(str:String, value:Dynamic) { var swagText:FlxText = new FlxText(10, 10 + (28 * txtGrp.length)); @@ -205,6 +228,7 @@ class DebugBoundingState extends FlxState offsetView.visible = true; offsetView.active = true; offsetControls(); + mouseOffsetMovement(); } if (FlxG.keys.justPressed.H)