mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-27 10:05:41 -05:00
FlxAnimate drawing optimizations
This commit is contained in:
parent
a5ed25fc31
commit
f94f1d1d98
2 changed files with 51 additions and 27 deletions
|
@ -10,6 +10,7 @@ import flixel.FlxSprite;
|
||||||
import flixel.graphics.FlxGraphic;
|
import flixel.graphics.FlxGraphic;
|
||||||
import flixel.graphics.frames.FlxAtlasFrames;
|
import flixel.graphics.frames.FlxAtlasFrames;
|
||||||
import flixel.graphics.frames.FlxFrame.FlxFrameAngle;
|
import flixel.graphics.frames.FlxFrame.FlxFrameAngle;
|
||||||
|
import flixel.group.FlxGroup;
|
||||||
import flixel.math.FlxMatrix;
|
import flixel.math.FlxMatrix;
|
||||||
import flixel.math.FlxPoint;
|
import flixel.math.FlxPoint;
|
||||||
import flixel.math.FlxRect;
|
import flixel.math.FlxRect;
|
||||||
|
@ -25,10 +26,14 @@ class FlxAnimate extends FlxSymbol
|
||||||
// var animBitmap:BitmapData;
|
// var animBitmap:BitmapData;
|
||||||
var jsonAnim:AnimJson;
|
var jsonAnim:AnimJson;
|
||||||
|
|
||||||
|
var sprGrp:FlxTypedGroup<FlxSymbol>;
|
||||||
|
|
||||||
public function new(x:Float, y:Float)
|
public function new(x:Float, y:Float)
|
||||||
{
|
{
|
||||||
super(x, y);
|
super(x, y);
|
||||||
|
|
||||||
|
sprGrp = new FlxTypedGroup<FlxSymbol>();
|
||||||
|
|
||||||
var folder:String = "tightestBars";
|
var folder:String = "tightestBars";
|
||||||
|
|
||||||
frames = FlxAnimate.fromAnimate(Paths.file('images/' + folder + "/spritemap1.png"), Paths.file('images/$folder/spritemap1.json'));
|
frames = FlxAnimate.fromAnimate(Paths.file('images/' + folder + "/spritemap1.png"), Paths.file('images/$folder/spritemap1.json'));
|
||||||
|
@ -36,8 +41,11 @@ class FlxAnimate extends FlxSymbol
|
||||||
jsonAnim = cast CoolUtil.coolJSON(Assets.getText(Paths.file('images/$folder/Animation.json')));
|
jsonAnim = cast CoolUtil.coolJSON(Assets.getText(Paths.file('images/$folder/Animation.json')));
|
||||||
ParseAnimate.generateSymbolmap(jsonAnim.SD.S);
|
ParseAnimate.generateSymbolmap(jsonAnim.SD.S);
|
||||||
ParseAnimate.resetFrameList();
|
ParseAnimate.resetFrameList();
|
||||||
|
|
||||||
ParseAnimate.parseTimeline(jsonAnim.AN.TL, 0, 0);
|
ParseAnimate.parseTimeline(jsonAnim.AN.TL, 0, 0);
|
||||||
|
|
||||||
|
generateSpriteShit();
|
||||||
|
|
||||||
/* var folder:String = 'tightestBars';
|
/* var folder:String = 'tightestBars';
|
||||||
coolParse = cast Json.parse(Assets.getText(Paths.file('images/' + folder + '/Animation.json')));
|
coolParse = cast Json.parse(Assets.getText(Paths.file('images/' + folder + '/Animation.json')));
|
||||||
|
|
||||||
|
@ -62,23 +70,23 @@ class FlxAnimate extends FlxSymbol
|
||||||
actualFrameRender();
|
actualFrameRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
// fix render order of ALL layers!
|
function generateSpriteShit()
|
||||||
// seperate frameList into layers
|
|
||||||
// go thru animate file to see how it should all be ordered
|
|
||||||
// per frame symbol stuff to fix lip sync (in ParseAnimate?)
|
|
||||||
// definitely need to dig through Animate.json stuff
|
|
||||||
// something with TRP stuff, look through tighterBars (GF scene)
|
|
||||||
// redo map stuff incase there's multiple assets
|
|
||||||
// ONE CENTRAL THING FOR THIS DUMBASS BULLSHIT
|
|
||||||
// sorted framelist put it all in there, then make i actually mean something
|
|
||||||
|
|
||||||
function actualFrameRender()
|
|
||||||
{
|
{
|
||||||
for (frameSorted in ParseAnimate.frameList)
|
for (frameSorted in ParseAnimate.frameList)
|
||||||
{
|
{
|
||||||
|
if (FlxG.keys.justPressed.I)
|
||||||
|
{
|
||||||
|
trace("\n\n\n\n");
|
||||||
|
trace('NEW LAYER TYPE SHIT');
|
||||||
|
trace(frameSorted.length);
|
||||||
|
// trace(i.depthString);
|
||||||
|
// trace("random lol: " + i.randomLol);
|
||||||
|
}
|
||||||
|
|
||||||
for (i in frameSorted)
|
for (i in frameSorted)
|
||||||
{
|
{
|
||||||
var spr:FlxSymbol = new FlxSymbol(0, 0); // redo this to recycle from a list later
|
// instead of making them every frame, regenerate when needed?
|
||||||
|
var spr:FlxSymbol = sprGrp.recycle(FlxSymbol); // redo this to recycle from a list later
|
||||||
spr.frames = frames;
|
spr.frames = frames;
|
||||||
spr.frame = spr.frames.getByName(i.frameName); // this one is fine
|
spr.frame = spr.frames.getByName(i.frameName); // this one is fine
|
||||||
|
|
||||||
|
@ -99,8 +107,10 @@ class FlxAnimate extends FlxSymbol
|
||||||
// spr.alpha = 0.3;
|
// spr.alpha = 0.3;
|
||||||
spr.origin.set();
|
spr.origin.set();
|
||||||
spr.antialiasing = true;
|
spr.antialiasing = true;
|
||||||
|
sprGrp.add(spr);
|
||||||
|
// trace(sprGrp);
|
||||||
|
// trace(spr);
|
||||||
// spr.alpha = 0.5;
|
// spr.alpha = 0.5;
|
||||||
spr.draw();
|
|
||||||
|
|
||||||
/* if (i == "0225")
|
/* if (i == "0225")
|
||||||
{
|
{
|
||||||
|
@ -116,6 +126,23 @@ class FlxAnimate extends FlxSymbol
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// trace(sprGrp.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
// fix render order of ALL layers!
|
||||||
|
// seperate frameList into layers
|
||||||
|
// go thru animate file to see how it should all be ordered
|
||||||
|
// per frame symbol stuff to fix lip sync (in ParseAnimate?)
|
||||||
|
// definitely need to dig through Animate.json stuff
|
||||||
|
// something with TRP stuff, look through tighterBars (GF scene)
|
||||||
|
// redo map stuff incase there's multiple assets
|
||||||
|
// ONE CENTRAL THING FOR THIS DUMBASS BULLSHIT
|
||||||
|
// sorted framelist put it all in there, then make i actually mean something
|
||||||
|
|
||||||
|
function actualFrameRender()
|
||||||
|
{
|
||||||
|
sprGrp.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
// notes to self
|
// notes to self
|
||||||
|
@ -153,6 +180,8 @@ class FlxAnimate extends FlxSymbol
|
||||||
|
|
||||||
ParseAnimate.resetFrameList();
|
ParseAnimate.resetFrameList();
|
||||||
ParseAnimate.parseTimeline(jsonAnim.AN.TL, 0, daFrame);
|
ParseAnimate.parseTimeline(jsonAnim.AN.TL, 0, daFrame);
|
||||||
|
|
||||||
|
generateSpriteShit();
|
||||||
}
|
}
|
||||||
if (FlxG.keys.justPressed.LEFT)
|
if (FlxG.keys.justPressed.LEFT)
|
||||||
changeFrame(-1);
|
changeFrame(-1);
|
||||||
|
|
|
@ -95,10 +95,10 @@ class ParseAnimate
|
||||||
*/
|
*/
|
||||||
public static var depthTypeBeat:String = "";
|
public static var depthTypeBeat:String = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of bullshit that will eventually be RENDERED by whoever wanna use it!
|
||||||
|
*/
|
||||||
public static var frameList:Array<Array<VALIDFRAME>> = [];
|
public static var frameList:Array<Array<VALIDFRAME>> = [];
|
||||||
public static var matrixMap:Map<String, Array<Array<Float>>> = new Map();
|
|
||||||
public static var trpMap:Map<String, Array<Array<Float>>> = new Map();
|
|
||||||
public static var theRoots:Map<String, String> = new Map();
|
|
||||||
|
|
||||||
// for loop stuf
|
// for loop stuf
|
||||||
|
|
||||||
|
@ -113,15 +113,14 @@ class ParseAnimate
|
||||||
|
|
||||||
public static var loopedFrameShit:Int = 0;
|
public static var loopedFrameShit:Int = 0;
|
||||||
|
|
||||||
|
// clean up all the crazy ass arrays
|
||||||
|
|
||||||
public static function resetFrameList()
|
public static function resetFrameList()
|
||||||
{
|
{
|
||||||
frameList = [];
|
frameList = [];
|
||||||
frameList.push([]);
|
frameList.push([]);
|
||||||
matrixHelp = [];
|
matrixHelp = [];
|
||||||
matrixHelp.push([]);
|
matrixHelp.push([]);
|
||||||
matrixMap.clear();
|
|
||||||
theRoots.clear();
|
|
||||||
trpMap.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function parseTimeline(TL:Timeline, tabbed:Int = 0, ?frameInput:Int)
|
public static function parseTimeline(TL:Timeline, tabbed:Int = 0, ?frameInput:Int)
|
||||||
|
@ -185,25 +184,20 @@ class ParseAnimate
|
||||||
if (Reflect.hasField(element, "ASI"))
|
if (Reflect.hasField(element, "ASI"))
|
||||||
{
|
{
|
||||||
matrixHelp[matrixHelp.length - 1].push(element.ASI.M3D);
|
matrixHelp[matrixHelp.length - 1].push(element.ASI.M3D);
|
||||||
// matrixMap.set(element.ASI.N, matrixHelp);
|
|
||||||
|
|
||||||
frameList[frameList.length - 1].push({
|
frameList[frameList.length - 1].push({
|
||||||
frameName: element.ASI.N,
|
frameName: element.ASI.N,
|
||||||
M3D: element.ASI.M3D,
|
M3D: element.ASI.M3D,
|
||||||
depthString: depthTypeBeat,
|
depthString: depthTypeBeat,
|
||||||
matrixArray: matrixHelp[matrixHelp.length - 1]
|
matrixArray: matrixHelp[matrixHelp.length - 1],
|
||||||
|
trpArray: trpHelpIDK
|
||||||
});
|
});
|
||||||
|
|
||||||
trpMap.set(element.ASI.N, trpHelpIDK);
|
|
||||||
|
|
||||||
// flips the matrix once?? I cant remember exactly why it needs to be flipped
|
// flips the matrix once?? I cant remember exactly why it needs to be flipped
|
||||||
// matrixMap[matrixHelp.length - 1].reverse();
|
|
||||||
// matrixHelp[matrixHelp.length - 1].reverse();
|
// matrixHelp[matrixHelp.length - 1].reverse();
|
||||||
|
|
||||||
trpHelpIDK = [];
|
trpHelpIDK = [];
|
||||||
|
|
||||||
theRoots.set(element.ASI.N, depthTypeBeat);
|
|
||||||
|
|
||||||
depthTypeBeat = "";
|
depthTypeBeat = "";
|
||||||
curLoopType = "";
|
curLoopType = "";
|
||||||
loopedFrameShit = 0;
|
loopedFrameShit = 0;
|
||||||
|
@ -248,7 +242,8 @@ typedef VALIDFRAME =
|
||||||
frameName:String,
|
frameName:String,
|
||||||
M3D:Array<Float>,
|
M3D:Array<Float>,
|
||||||
depthString:String,
|
depthString:String,
|
||||||
matrixArray:Array<Array<Float>>
|
matrixArray:Array<Array<Float>>,
|
||||||
|
trpArray:Array<Array<Float>>
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef AnimJson =
|
typedef AnimJson =
|
||||||
|
|
Loading…
Reference in a new issue