1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-11-26 14:16:00 +00:00

Port improved AtlasSprite from char-select-rebase

This commit is contained in:
EliteMasterEric 2024-02-14 03:27:34 -05:00
parent c299aa00b9
commit 9209bac02c

View file

@ -18,7 +18,7 @@ class FlxAtlasSprite extends FlxAnimate
// ?OnComplete:Void -> Void, // ?OnComplete:Void -> Void,
ShowPivot: #if debug false #else false #end, ShowPivot: #if debug false #else false #end,
Antialiasing: true, Antialiasing: true,
ScrollFactor: new FlxPoint(1, 1), ScrollFactor: null,
// Offset: new FlxPoint(0, 0), // This is just FlxSprite.offset // Offset: new FlxPoint(0, 0), // This is just FlxSprite.offset
}; };
@ -55,8 +55,8 @@ class FlxAtlasSprite extends FlxAnimate
*/ */
public function listAnimations():Array<String> public function listAnimations():Array<String>
{ {
// return this.anim.getFrameLabels(); return this.anim.getFrameLabels();
return [""]; // return [""];
} }
/** /**
@ -82,8 +82,10 @@ class FlxAtlasSprite extends FlxAnimate
* @param restart Whether to restart the animation if it is already playing. * @param restart Whether to restart the animation if it is already playing.
* @param ignoreOther Whether to ignore all other animation inputs, until this one is done playing * @param ignoreOther Whether to ignore all other animation inputs, until this one is done playing
*/ */
public function playAnimation(id:String, restart:Bool = false, ignoreOther:Bool = false):Void public function playAnimation(id:String, restart:Bool = false, ignoreOther:Bool = false, ?loop:Bool = false):Void
{ {
if (loop == null) loop = false;
// Skip if not allowed to play animations. // Skip if not allowed to play animations.
if ((!canPlayOtherAnims && !ignoreOther)) return; if ((!canPlayOtherAnims && !ignoreOther)) return;
@ -110,15 +112,14 @@ class FlxAtlasSprite extends FlxAnimate
return; return;
} }
// Stop the current animation if it is playing. anim.callback = function(_, frame:Int) {
// This includes removing existing frame callbacks. if (frame == (anim.getFrameLabel(id).duration - 1) + anim.getFrameLabel(id).index)
if (this.currentAnimation != null) this.stopAnimation(); {
if (loop) playAnimation(id, true, false, true);
// Add a callback to ensure `onAnimationFinish` is dispatched. else
addFrameCallback(getNextFrameLabel(id), function() { onAnimationFinish.dispatch(id);
trace('Animation finished: ' + id); }
onAnimationFinish.dispatch(id); };
});
// Prevent other animations from playing if `ignoreOther` is true. // Prevent other animations from playing if `ignoreOther` is true.
if (ignoreOther) canPlayOtherAnims = false; if (ignoreOther) canPlayOtherAnims = false;
@ -128,6 +129,11 @@ class FlxAtlasSprite extends FlxAnimate
this.currentAnimation = id; this.currentAnimation = id;
} }
override public function update(elapsed:Float)
{
super.update(elapsed);
}
/** /**
* Stops the current animation. * Stops the current animation.
*/ */