11package funkin .backend ;
22
3+ import animate .FlxAnimate ;
4+ import animate .FlxAnimateController .FlxAnimateAnimation ;
35import flixel .addons .effects .FlxSkewedSprite ;
46import flixel .animation .FlxAnimation ;
57import flixel .math .FlxMatrix ;
@@ -43,7 +45,7 @@ enum abstract XMLAnimType(Int)
4345 }
4446}
4547
46- class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements IOffsetCompatible implements IXMLEvents
48+ class FunkinSprite extends FlxAnimate implements IBeatReceiver implements IOffsetCompatible implements IXMLEvents
4749{
4850 public var extra : Map <String , Dynamic > = [];
4951
@@ -66,10 +68,6 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
6668 public var beatOffset : Int = 0 ;
6769 public var skipNegativeBeats : Bool = false ;
6870
69- public var animateAtlas : FlxAnimate ;
70- @:noCompletion public var atlasPlayingAnim : String ;
71- @:noCompletion public var atlasPath : String ;
72-
7371 var _rect2 : FlxRect ;
7472
7573 public function new (? X : Float = 0 , ? Y : Float = 0 , ? SimpleGraphic : FlxGraphicAsset )
@@ -85,6 +83,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
8583 }
8684
8785 moves = false ;
86+ applyStageMatrix = true ;
8887 }
8988
9089 /**
@@ -100,8 +99,6 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
10099 @:privateAccess {
101100 spr .setPosition (source .x , source .y );
102101 spr .frames = source .frames ;
103- if (casted != null && casted .animateAtlas != null && casted .atlasPath != null )
104- spr .loadSprite (casted .atlasPath );
105102 spr .animation .copyFrom (source .animation );
106103 spr .visible = source .visible ;
107104 spr .alpha = source .alpha ;
@@ -111,8 +108,6 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
111108
112109 if (casted != null ) {
113110 spr .skew .set (casted .skew .x , casted .skew .y );
114- spr .transformMatrix = casted .transformMatrix ;
115- spr .matrixExposed = casted .matrixExposed ;
116111 spr .animOffsets = casted .animOffsets .copy ();
117112 spr .zoomFactor = casted .zoomFactor ;
118113 }
@@ -123,8 +118,6 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
123118 public override function update (elapsed : Float )
124119 {
125120 super .update (elapsed );
126- if (animateAtlas != null )
127- animateAtlas .update (elapsed );
128121
129122 // hate how it looks like but hey at least its optimized and fast - Nex
130123 if (! debugMode && isAnimFinished ()) {
@@ -142,15 +135,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
142135 public function loadSprite (path : String , Unique : Bool = false , Key : String = null )
143136 {
144137 var noExt = Path .withoutExtension (path );
145- if (Assets .exists (' $noExt /Animation.json' ))
146- {
147- atlasPath = noExt ;
148- animateAtlas = new FlxAnimate (x , y , noExt );
149- }
150- else
151- {
152- frames = Paths .getFrames (path , true );
153- }
138+ frames = Paths .getFrames (path , true );
154139 return this ;
155140 }
156141
@@ -182,48 +167,9 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
182167
183168 // ANIMATE ATLAS DRAWING
184169 #if REGION
185- public override function draw ()
186- {
187- if (animateAtlas != null )
188- {
189- copyAtlasValues ();
190- animateAtlas .draw ();
191- }
192- else
193- {
194- super .draw ();
195- }
196- }
197-
198- public function copyAtlasValues ()
199- {
200- @:privateAccess {
201- animateAtlas .cameras = cameras ; // investigate if we can use _cameras
202- animateAtlas .scrollFactor = scrollFactor ;
203- animateAtlas .scale = scale ;
204- animateAtlas .offset = offset ;
205- animateAtlas .frameOffset = frameOffset ;
206- animateAtlas .x = x ;
207- animateAtlas .y = y ;
208- animateAtlas .angle = angle ;
209- animateAtlas .alpha = alpha ;
210- animateAtlas .visible = visible ;
211- animateAtlas .flipX = flipX ;
212- animateAtlas .flipY = flipY ;
213- animateAtlas .shader = shader ;
214- animateAtlas .shaderEnabled = shaderEnabled ;
215- animateAtlas .antialiasing = antialiasing ;
216- animateAtlas .skew = skew ;
217- animateAtlas .transformMatrix = transformMatrix ;
218- animateAtlas .matrixExposed = matrixExposed ;
219- animateAtlas .colorTransform = colorTransform ;
220- }
221- }
222170
223171 public override function destroy ()
224172 {
225- animateAtlas = FlxDestroyUtil .destroy (animateAtlas );
226-
227173 if (animOffsets != null ) {
228174 for (key in animOffsets .keys ()) {
229175 final point = animOffsets [key ];
@@ -340,13 +286,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
340286 Force = anim != null && anim .forced ;
341287 }
342288
343- if (animateAtlas != null )
344- {
345- @:privateAccess
346- animateAtlas .anim .play (AnimName , Force , Reversed , Frame );
347- atlasPlayingAnim = AnimName ;
348- }
349- else animation .play (AnimName , Force , Reversed , Frame );
289+ animation .play (AnimName , Force , Reversed , Frame );
350290
351291 var daOffset = getAnimOffset (AnimName );
352292 frameOffset .set (daOffset .x , daOffset .y );
@@ -370,18 +310,11 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
370310 });
371311 }
372312
373- public inline function removeAnim (name : String )
374- {
375- if (animateAtlas != null )
376- @:privateAccess animateAtlas .anim .animsMap .remove (name );
377- else
378- animation .remove (name );
313+ public inline function removeAnim (name : String ) {
314+ animation .remove (name );
379315 }
380316
381- public function getAnim (name : String ): OneOfTwo <FlxAnimation , FlxSymbolAnimation >
382- {
383- if (animateAtlas != null )
384- return animateAtlas .anim .getByName (name );
317+ public function getAnim (name : String ): OneOfTwo <FlxAnimation , FlxAnimateAnimation > {
385318 return animation .getByName (name );
386319 }
387320
@@ -392,40 +325,26 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
392325 return FlxPoint .weak (0 , 0 );
393326 }
394327
395- public inline function hasAnim (AnimName : String ): Bool @:privateAccess
396- return animateAtlas != null ? (animateAtlas .anim .animsMap .exists (AnimName )
397- || animateAtlas .anim .symbolDictionary .exists (AnimName )) : animation .exists (AnimName );
328+ public inline function hasAnim (AnimName : String ): Bool
329+ return animation .exists (AnimName );
398330
399- public inline function getAnimName () {
400- return (animateAtlas != null ) ? atlasPlayingAnim : animation .name ;
401- }
331+ public inline function getAnimName ()
332+ return animation .name ;
402333
403- public inline function isAnimReversed (): Bool {
404- return animateAtlas != null ? animateAtlas .anim .reversed : animation .curAnim != null ? animation .curAnim .reversed : false ;
405- }
334+ public inline function isAnimReversed (): Bool
335+ return animation .curAnim ?. reversed ?? false ;
406336
407- public inline function getNameList (): Array <String > {
408- if (animateAtlas != null )
409- return [for (name in @:privateAccess animateAtlas .anim .animsMap .keys ()) name ];
410- else
411- return animation .getNameList ();
412- }
337+ public inline function getNameList (): Array <String >
338+ return animation .getNameList ();
413339
414340 public inline function stopAnim ()
415- {
416- if (animateAtlas != null )
417- animateAtlas .anim .pause ();
418- else
419- animation .stop ();
420- }
341+ animation .stop ();
421342
422- public inline function isAnimFinished () {
423- return animateAtlas != null ? animateAtlas .anim .finished : (animation .curAnim != null ? animation .curAnim .finished : true );
424- }
343+ public inline function isAnimFinished ()
344+ return animation .curAnim ?. finished ?? true ;
425345
426- public inline function isAnimAtEnd () {
427- return animateAtlas != null ? animateAtlas .anim .isAtEnd : (animation .curAnim != null ? animation .curAnim .isAtEnd : false );
428- }
346+ public inline function isAnimAtEnd ()
347+ return animation .curAnim ?. isAtEnd ?? false ;
429348
430349 override function updateAnimation (elapsed : Float ) {
431350 if (animEnabled )
@@ -447,10 +366,9 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
447366 return beatInterval = v ;
448367 }
449368
450- @:noCompletion private inline function get_globalCurFrame () {
451- return animateAtlas != null ? (animateAtlas .anim .curFrame ) : (animation .curAnim != null ? animation .curAnim .curFrame : 0 );
452- }
453- @:noCompletion private inline function set_globalCurFrame (val : Int ) {
454- return animateAtlas != null ? (animateAtlas .anim .curFrame = val ) : (animation .curAnim != null ? animation .curAnim .curFrame = val : val );
455- }
369+ @:noCompletion private inline function get_globalCurFrame ()
370+ return animation .curAnim ?. curFrame ?? 0 ;
371+
372+ @:noCompletion private inline function set_globalCurFrame (val : Int )
373+ return animation .curAnim ?. curFrame ?? 0 ;
456374}
0 commit comments