fixed offsets & rotation for animate atlases

This commit is contained in:
Yoshman29
2023-01-07 22:48:01 +01:00
parent 9064560065
commit fcc4f03936
4 changed files with 83 additions and 12 deletions
+10 -10
View File
@@ -1,14 +1,14 @@
<!DOCTYPE codename-engine-character>
<character isPlayer="false" flipX="false" isGF="true" x="100" y="275">
<anim name="cheer" anim="GF Cheer" fps="24" loop="false" />
<anim name="singUP" anim="GF Up Note" fps="24" loop="false" x="0" y="4" />
<anim name="singLEFT" anim="GF left note" fps="24" loop="false" x="0" y="-19" />
<anim name="singRIGHT" anim="GF Right Note" fps="24" loop="false" x="0" y="-20" />
<anim name="singDOWN" anim="GF Down Note" fps="24" loop="false" x="0" y="-20" />
<anim name="danceLeft" anim="GF Dancing Beat" fps="24" loop="false" x="0" y="-9" indices="30,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14" />
<anim name="danceRight" anim="GF Dancing Beat" fps="24" loop="false" x="0" y="-9" indices="15,16,17,18,19,20,21,22,23,24,25,26,27,28,29" />
<anim name="hairBlow" anim="GF Dancing Beat Hair blowing" fps="24" loop="false" x="45" y="-8" indices="0,1,2,3" />
<anim name="hairFall" anim="GF Dancing Beat Hair Landing" fps="24" loop="false" x="0" y="-9" indices="0,1,2,3,4,5,6,7,8,9,10,11" />
<anim name="scared" anim="GF FEAR" fps="24" loop="true" x="-2" y="-17" />
<anim name="sad" anim="gf sad" fps="24" loop="true" x="-2" y="-21" indices="0,1,2,3,4,5,6,7,8,9,10,11,12" />
<anim name="singUP" anim="GF Up Note" fps="24" loop="false" x="0" y="0" />
<anim name="singLEFT" anim="GF left note" fps="24" loop="false" x="0" y="0" />
<anim name="singRIGHT" anim="GF Right Note" fps="24" loop="false" x="0" y="0" />
<anim name="singDOWN" anim="GF Down Note" fps="24" loop="false" x="0" y="0" />
<anim name="danceLeft" anim="GF Dancing Beat" fps="24" loop="false" x="0" y="0" indices="30,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14" />
<anim name="danceRight" anim="GF Dancing Beat" fps="24" loop="false" x="0" y="0" indices="15,16,17,18,19,20,21,22,23,24,25,26,27,28,29" />
<anim name="hairBlow" anim="GF Dancing Beat Hair blowing" fps="24" loop="false" x="0" y="0" indices="0,1,2,3" />
<anim name="hairFall" anim="GF Dancing Beat Hair Landing" fps="24" loop="false" x="0" y="0" indices="0,1,2,3,4,5,6,7,8,9,10,11" />
<anim name="scared" anim="GF FEAR" fps="24" loop="true" x="0" y="0" />
<anim name="sad" anim="gf sad" fps="24" loop="true" x="0" y="0" indices="0,1,2,3,4,5,6,7,8,9,10,11,12" />
</character>
+1 -1
View File
@@ -1 +1 @@
1924
1926
+72
View File
@@ -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
}
}
-1
View File
@@ -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;