animation fixing for FlxSymbol in progress

This commit is contained in:
Cameron Taylor 2021-06-17 01:42:31 -04:00
parent 4137687f26
commit 1927be79f8

View file

@ -16,6 +16,15 @@ class FlxSymbol extends FlxSprite
private var hasFrameByPass:Bool = false; private var hasFrameByPass:Bool = false;
// 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 firstFrame:Int = 0;
public var daLoopType:String = 'LP'; // LP by default, is set below!!!
public function new(x:Float, y:Float, coolParsed:Parsed) public function new(x:Float, y:Float, coolParsed:Parsed)
{ {
super(x, y); super(x, y);
@ -47,13 +56,33 @@ class FlxSymbol extends FlxSprite
trace(layer.LN); trace(layer.LN);
// layer.FR.reverse(); // layer.FR.reverse();
// var frame = layer.FR[0]
for (frame in layer.FR) // for (frame in layer.FR)
// {
var newFrameNum:Int = daFrame;
switch (daLoopType)
{ {
if (daFrame >= frame.I && daFrame < frame.I + frame.DU) case LOOP:
{ var tempFrame = layer.FR[newFrameNum + firstFrame % layer.FR.length];
for (element in frame.E) newFrameNum += 0; // temp, fix later for good looping
case PLAY_ONCE:
newFrameNum += 0;
case SINGLE_FRAME:
newFrameNum = firstFrame;
}
trace(daLoopType);
trace(newFrameNum);
trace(layer.FR.length);
trace(newFrameNum % layer.FR.length);
var swagFrame:Frame = layer.FR[newFrameNum % layer.FR.length]; // has modulo just in case????
// if (newFrameNum >= frame.I && newFrameNum < frame.I + frame.DU)
// {
for (element in swagFrame.E)
{ {
if (Reflect.hasField(element, 'ASI')) if (Reflect.hasField(element, 'ASI'))
{ {
@ -92,8 +121,8 @@ class FlxSymbol extends FlxSprite
var nestedShit:FlxSymbol = new FlxSymbol(0, 0, coolParse); var nestedShit:FlxSymbol = new FlxSymbol(0, 0, coolParse);
nestedShit.frames = frames; nestedShit.frames = frames;
var swagMatrix:FlxMatrix = new FlxMatrix(element.SI.M3D[0], element.SI.M3D[1], element.SI.M3D[4], element.SI.M3D[5], var swagMatrix:FlxMatrix = new FlxMatrix(element.SI.M3D[0], element.SI.M3D[1], element.SI.M3D[4], element.SI.M3D[5], element.SI.M3D[12],
element.SI.M3D[12], element.SI.M3D[13]); element.SI.M3D[13]);
swagMatrix.concat(_matrix); swagMatrix.concat(_matrix);
@ -115,11 +144,16 @@ class FlxSymbol extends FlxSprite
if (FlxG.keys.justPressed.ONE) if (FlxG.keys.justPressed.ONE)
{ {
trace("SI - " + layer.LN + ": " + element.SI.SN); trace("SI - " + layer.LN + ": " + element.SI.SN + " - LOOP TYPE: " + element.SI.LP);
} }
nestedShit.firstFrame = element.SI.FF;
// nestedShit.daFrame += nestedShit.firstFrame;
nestedSymbol.TL.L.reverse(); nestedSymbol.TL.L.reverse();
nestedShit.daLoopType = element.SI.LP;
nestedShit.daFrame = daFrame;
nestedShit.hasFrameByPass = true; nestedShit.hasFrameByPass = true;
nestedShit.nestDepth = nestDepth + 1; nestedShit.nestDepth = nestDepth + 1;
nestedShit.renderFrame(nestedSymbol.TL, coolParsed); nestedShit.renderFrame(nestedSymbol.TL, coolParsed);
@ -127,8 +161,8 @@ class FlxSymbol extends FlxSprite
// renderFrame(nestedSymbol.TL, coolParsed); // renderFrame(nestedSymbol.TL, coolParsed);
} }
} }
} // }
} // }
} }
} }
@ -311,6 +345,12 @@ typedef SymbolInstance =
/** SymbolType (Graphic, Movieclip, Button)*/ /** SymbolType (Graphic, Movieclip, Button)*/
var ST:String; var ST:String;
/** First frame*/
var FF:Int;
/** Loop type (Loop, play once, single frame)*/
var LP:String;
var TRP:TransformationPoint; var TRP:TransformationPoint;
var M3D:Array<Float>; var M3D:Array<Float>;
} }