Funkin/source/funkin/animate/FlxSymbol.hx

83 lines
2.1 KiB
Haxe
Raw Normal View History

package funkin.animate;
2021-04-14 11:31:52 -04: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-15 23:13:52 -04:00
import flixel.FlxCamera;
2021-04-14 11:31:52 -04:00
import flixel.FlxSprite;
2021-04-15 23:13:52 -04:00
import flixel.graphics.frames.FlxFrame.FlxFrameAngle;
2021-04-14 11:31:52 -04:00
import flixel.math.FlxAngle;
2021-06-18 14:18:56 -04:00
import flixel.math.FlxMath;
2021-04-15 23:13:52 -04:00
import flixel.math.FlxMatrix;
import flixel.math.FlxPoint;
2021-06-22 15:41:15 -04:00
import lime.system.System;
2021-09-01 15:34:20 -04:00
import openfl.Assets;
2021-04-15 23:13:52 -04:00
import openfl.geom.Matrix;
2021-04-14 11:31:52 -04:00
class FlxSymbol extends FlxSprite
{
// 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';
public var transformMatrix:Matrix = new Matrix();
public var daLoopType:String = 'LP'; // LP by default, is set below!!!
2021-08-21 13:19:56 -04: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 13:19:56 -04:00
*/
public var matrixExposed:Bool = true;
2021-09-01 15:34:20 -04:00
public function new(x:Float, y:Float)
2021-04-14 11:31:52 -04:00
{
super(x, y);
}
2021-04-14 21:52:43 -04:00
public var daFrame:Int = 0;
function changeFrame(frameChange:Int = 0):Void
{
daFrame += frameChange;
}
2021-09-01 15:34:20 -04:00
/**
* custom "homemade" (nabbed from FlxSkewSprite) draw function, to make having a matrix transform slightly
* less painful
*/
2021-04-15 23:13:52 -04: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);
}
if (bakedRotationAngle <= 0)
{
updateTrig();
if (angle != 0)
_matrix.rotateWithTrig(_cosAngle, _sinAngle);
}
2021-04-15 23:13:52 -04:00
_point.addPoint(origin);
_matrix.translate(_point.x, _point.y);
2021-09-01 15:34:20 -04: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-15 23:13:52 -04:00
}
2021-04-14 11:31:52 -04:00
}