From fcc4f03936ae5e57ee2ceb39803abe16563a2452 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Sat, 7 Jan 2023 22:48:01 +0100 Subject: [PATCH] fixed offsets & rotation for animate atlases --- assets/data/characters/gf.xml | 20 ++++---- buildnumber.txt | 2 +- source/funkin/system/FlxAnimate.hx | 72 ++++++++++++++++++++++++++++ source/funkin/system/FunkinSprite.hx | 1 - 4 files changed, 83 insertions(+), 12 deletions(-) create mode 100644 source/funkin/system/FlxAnimate.hx diff --git a/assets/data/characters/gf.xml b/assets/data/characters/gf.xml index 8012d5e7..444d5349 100644 --- a/assets/data/characters/gf.xml +++ b/assets/data/characters/gf.xml @@ -1,14 +1,14 @@ - - - - - - - - - - + + + + + + + + + + \ No newline at end of file diff --git a/buildnumber.txt b/buildnumber.txt index 23ffd4a1..28445ea6 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -1924 \ No newline at end of file +1926 \ No newline at end of file diff --git a/source/funkin/system/FlxAnimate.hx b/source/funkin/system/FlxAnimate.hx new file mode 100644 index 00000000..aa1de81d --- /dev/null +++ b/source/funkin/system/FlxAnimate.hx @@ -0,0 +1,72 @@ +package funkin.system; + +import openfl.geom.ColorTransform; +import flixel.math.FlxMatrix; +import flixel.math.FlxAngle; +import flixel.math.FlxRect; +import flixel.graphics.frames.FlxFrame; +import flixel.math.FlxPoint; + +class FlxAnimate extends flxanimate.FlxAnimate { + public override function drawLimb(limb:FlxFrame, _matrix:FlxMatrix, ?colorTransform:ColorTransform) + { + if (alpha == 0 || colorTransform != null && (colorTransform.alphaMultiplier == 0 || colorTransform.alphaOffset == -255) || limb == null || limb.type == EMPTY) + return; + var matrix = new FlxMatrix(); + matrix.concat(_matrix); + for (camera in cameras) + { + if (!camera.visible || !camera.exists || !limbOnScreen(limb, _matrix, camera)) + return; + + getScreenPosition(_point, camera).subtractPoint(offset); + matrix.translate(-origin.x, -origin.y); + if (limb.name != "pivot") { + if (rotOffsetAngle != null && rotOffsetAngle != angle) + { + var angleOff = (-angle + rotOffsetAngle) * FlxAngle.TO_RAD; + matrix.rotate(-angleOff); + if (useOffsetAsRotOffset) + matrix.translate(-offset.x, -offset.y); + else + matrix.translate(-rotOffset.x, -rotOffset.y); + matrix.rotate(angleOff); + } + else + { + if (useOffsetAsRotOffset) + matrix.translate(-offset.x, -offset.y); + else + matrix.translate(-rotOffset.x, -rotOffset.y); + } + matrix.scale(scale.x, scale.y); + + if (bakedRotationAngle <= 0) + { + updateTrig(); + + if (angle != 0) + matrix.rotateWithTrig(_cosAngle, _sinAngle); + } + } + else + matrix.a = matrix.d = 0.7 / camera.zoom; + _point.addPoint(origin); + if (isPixelPerfectRender(camera)) + { + _point.floor(); + } + + matrix.translate(_point.x, _point.y); + camera.drawPixels(limb, null, matrix, colorTransform, blend, antialiasing); + #if FLX_DEBUG + FlxBasic.visibleCount++; + #end + } + + #if FLX_DEBUG + if (FlxG.debugger.drawDebug) + drawDebug(); + #end + } +} \ No newline at end of file diff --git a/source/funkin/system/FunkinSprite.hx b/source/funkin/system/FunkinSprite.hx index 5c574ed1..d9472291 100644 --- a/source/funkin/system/FunkinSprite.hx +++ b/source/funkin/system/FunkinSprite.hx @@ -2,7 +2,6 @@ package funkin.system; import flixel.FlxG; import openfl.utils.Assets; -import flxanimate.FlxAnimate; import haxe.io.Path; import funkin.scripting.events.PlayAnimEvent.PlayAnimContext; import funkin.interfaces.IOffsetCompatible;