From 1ee38acc583dc097938071416bb00e64c05d1994 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Mon, 22 Jul 2024 12:43:13 -0700 Subject: [PATCH] fix dragging "bug" --- .../editors/character/CharacterEditor.hx | 42 +++++++++---------- .../editors/character/CharacterGhost.hx | 4 +- source/funkin/game/Character.hx | 4 +- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/source/funkin/editors/character/CharacterEditor.hx b/source/funkin/editors/character/CharacterEditor.hx index fb907472..0a3974e9 100644 --- a/source/funkin/editors/character/CharacterEditor.hx +++ b/source/funkin/editors/character/CharacterEditor.hx @@ -359,27 +359,6 @@ class CharacterEditor extends UIState { } inline function handleMouseOffsets() { - var point = FlxG.mouse.getWorldPosition(charCamera, _point); - if(character.animateAtlas == null) { - StageEditor.calcSpriteBounds(character); - var bounds:FlxRect = cast character.extra.get(StageEditor.exID("bounds")); - - // my poor attempt at fixing the global offset flip hitbox bug - /* - if (character.isPlayer != character.playerOffsets) { - bounds.x = character.globalOffset.x + character.animOffsets[character.getAnimName()].x; - if (stage != null && stage.characterPoses.exists(stagePosition)) - bounds.x += stage.characterPoses.get(stagePosition).x; - } - */ - - if (bounds.containsPoint(point)) { - cameraHoverDummy.cursor = #if (mac) DRAG_OPEN; #elseif (linux) CLICK; #else MOVE; #end - if (FlxG.mouse.justPressed) - draggingCharacter = true; - } - } - if (draggingCharacter) { cameraHoverDummy.cursor = #if (mac) DRAG; #elseif (linux) DRAG; #else MOVE; #end @@ -395,6 +374,27 @@ class CharacterEditor extends UIState { draggingOffset.x += FlxG.mouse.deltaScreenX; draggingOffset.y += FlxG.mouse.deltaScreenY; character.extraOffset = draggingOffset; } + } else { + var point = FlxG.mouse.getWorldPosition(charCamera, _point); + if(character.animateAtlas == null) { + StageEditor.calcSpriteBounds(character); + var bounds:FlxRect = cast character.extra.get(StageEditor.exID("bounds")); + + // my poor attempt at fixing the global offset flip hitbox bug + /* + if (character.isPlayer != character.playerOffsets) { + bounds.x = character.globalOffset.x + character.animOffsets[character.getAnimName()].x; + if (stage != null && stage.characterPoses.exists(stagePosition)) + bounds.x += stage.characterPoses.get(stagePosition).x; + } + */ + + if (bounds.containsPoint(point)) { + cameraHoverDummy.cursor = #if (mac) DRAG_OPEN; #elseif (linux) CLICK; #else MOVE; #end + if (FlxG.mouse.justPressed) + draggingCharacter = true; + } + } } } diff --git a/source/funkin/editors/character/CharacterGhost.hx b/source/funkin/editors/character/CharacterGhost.hx index 1fb8efaa..dda10294 100644 --- a/source/funkin/editors/character/CharacterGhost.hx +++ b/source/funkin/editors/character/CharacterGhost.hx @@ -26,7 +26,9 @@ class CharacterGhost extends Character { setAnimOffset(animation.name); alpha = 1; color = 0xFFFFFFFF; - ghostDraw = false; super.draw(); + ghostDraw = false; + + super.draw(); } public function setAnimOffset(anim:String) { diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index 6c1dcfc1..87d51a48 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -219,8 +219,8 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset } if (!ghostDraw) { - x += extraOffset.x; - y += extraOffset.y; + x -= extraOffset.x; + y -= extraOffset.y; } }