2022-03-08 08:13:53 +00:00
|
|
|
package funkin.animate;
|
2021-04-14 15:31:52 +00:00
|
|
|
|
2022-03-08 08:13:53 +00:00
|
|
|
import funkin.animate.ParseAnimate.AnimJson;
|
|
|
|
import funkin.animate.ParseAnimate.Animation;
|
|
|
|
import funkin.animate.ParseAnimate.Frame;
|
|
|
|
import funkin.animate.ParseAnimate.Sprite;
|
|
|
|
import funkin.animate.ParseAnimate.Spritemap;
|
|
|
|
import funkin.animate.ParseAnimate.SymbolDictionary;
|
|
|
|
import funkin.animate.ParseAnimate.Timeline;
|
2021-04-16 03:13:52 +00:00
|
|
|
import flixel.FlxCamera;
|
2021-04-14 15:31:52 +00:00
|
|
|
import flixel.FlxSprite;
|
2021-04-16 03:13:52 +00:00
|
|
|
import flixel.graphics.frames.FlxFrame.FlxFrameAngle;
|
2021-04-14 15:31:52 +00:00
|
|
|
import flixel.math.FlxAngle;
|
2021-06-18 18:18:56 +00:00
|
|
|
import flixel.math.FlxMath;
|
2021-04-16 03:13:52 +00:00
|
|
|
import flixel.math.FlxMatrix;
|
|
|
|
import flixel.math.FlxPoint;
|
2021-06-22 19:41:15 +00:00
|
|
|
import lime.system.System;
|
2021-09-01 19:34:20 +00:00
|
|
|
import openfl.Assets;
|
2021-04-16 03:13:52 +00:00
|
|
|
import openfl.geom.Matrix;
|
2021-04-14 15:31:52 +00:00
|
|
|
|
|
|
|
class FlxSymbol extends FlxSprite
|
|
|
|
{
|
2021-06-17 05:42:31 +00:00
|
|
|
// Loop types shit
|
|
|
|
public static inline var LOOP:String = 'LP';
|
|
|
|
public static inline var PLAY_ONCE:String = 'PO';
|
|
|
|
public static inline var SINGLE_FRAME:String = 'SF';
|
|
|
|
|
2021-09-11 15:54:38 +00:00
|
|
|
public var transformMatrix:Matrix = new Matrix();
|
|
|
|
public var daLoopType:String = 'LP'; // LP by default, is set below!!!
|
|
|
|
|
2021-08-21 17:19:56 +00:00
|
|
|
/**
|
2021-09-11 15:54:38 +00:00
|
|
|
* Bool flag showing whether transformMatrix is used for rendering or not.
|
|
|
|
* False by default, which means that transformMatrix isn't used for rendering
|
2021-08-21 17:19:56 +00:00
|
|
|
*/
|
2021-09-11 15:54:38 +00:00
|
|
|
public var matrixExposed:Bool = true;
|
2021-06-17 05:42:31 +00:00
|
|
|
|
2021-09-01 19:34:20 +00:00
|
|
|
public function new(x:Float, y:Float)
|
2021-04-14 15:31:52 +00:00
|
|
|
{
|
|
|
|
super(x, y);
|
|
|
|
}
|
|
|
|
|
2021-04-15 01:52:43 +00:00
|
|
|
public var daFrame:Int = 0;
|
|
|
|
|
|
|
|
function changeFrame(frameChange:Int = 0):Void
|
|
|
|
{
|
|
|
|
daFrame += frameChange;
|
|
|
|
}
|
|
|
|
|
2021-09-01 19:34:20 +00:00
|
|
|
/**
|
2021-09-11 15:54:38 +00:00
|
|
|
* custom "homemade" (nabbed from FlxSkewSprite) draw function, to make having a matrix transform slightly
|
|
|
|
* less painful
|
|
|
|
*/
|
2021-04-16 03:13:52 +00:00
|
|
|
override function drawComplex(camera:FlxCamera):Void
|
|
|
|
{
|
|
|
|
_frame.prepareMatrix(_matrix, FlxFrameAngle.ANGLE_0, checkFlipX(), checkFlipY());
|
|
|
|
_matrix.translate(-origin.x, -origin.y);
|
|
|
|
_matrix.scale(scale.x, scale.y);
|
|
|
|
|
|
|
|
if (matrixExposed)
|
|
|
|
{
|
|
|
|
_matrix.concat(transformMatrix);
|
|
|
|
}
|
|
|
|
|
2021-09-11 13:37:04 +00:00
|
|
|
if (bakedRotationAngle <= 0)
|
|
|
|
{
|
|
|
|
updateTrig();
|
|
|
|
|
|
|
|
if (angle != 0)
|
|
|
|
_matrix.rotateWithTrig(_cosAngle, _sinAngle);
|
|
|
|
}
|
|
|
|
|
2021-04-16 03:13:52 +00:00
|
|
|
_point.addPoint(origin);
|
|
|
|
_matrix.translate(_point.x, _point.y);
|
2021-09-01 19:34:20 +00:00
|
|
|
|
|
|
|
if (isPixelPerfectRender(camera))
|
|
|
|
{
|
|
|
|
_matrix.tx = Math.floor(_matrix.tx);
|
|
|
|
_matrix.ty = Math.floor(_matrix.ty);
|
|
|
|
}
|
|
|
|
camera.drawPixels(_frame, framePixels, _matrix, colorTransform, blend, antialiasing, shader);
|
2021-04-16 03:13:52 +00:00
|
|
|
}
|
2021-04-14 15:31:52 +00:00
|
|
|
}
|