mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-27 01:55:52 -05:00
Port improved AtlasSprite from char-select-rebase
This commit is contained in:
parent
c299aa00b9
commit
9209bac02c
1 changed files with 19 additions and 13 deletions
|
@ -18,7 +18,7 @@ class FlxAtlasSprite extends FlxAnimate
|
|||
// ?OnComplete:Void -> Void,
|
||||
ShowPivot: #if debug false #else false #end,
|
||||
Antialiasing: true,
|
||||
ScrollFactor: new FlxPoint(1, 1),
|
||||
ScrollFactor: null,
|
||||
// Offset: new FlxPoint(0, 0), // This is just FlxSprite.offset
|
||||
};
|
||||
|
||||
|
@ -55,8 +55,8 @@ class FlxAtlasSprite extends FlxAnimate
|
|||
*/
|
||||
public function listAnimations():Array<String>
|
||||
{
|
||||
// return this.anim.getFrameLabels();
|
||||
return [""];
|
||||
return this.anim.getFrameLabels();
|
||||
// return [""];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,8 +82,10 @@ class FlxAtlasSprite extends FlxAnimate
|
|||
* @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
|
||||
*/
|
||||
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.
|
||||
if ((!canPlayOtherAnims && !ignoreOther)) return;
|
||||
|
||||
|
@ -110,15 +112,14 @@ class FlxAtlasSprite extends FlxAnimate
|
|||
return;
|
||||
}
|
||||
|
||||
// Stop the current animation if it is playing.
|
||||
// This includes removing existing frame callbacks.
|
||||
if (this.currentAnimation != null) this.stopAnimation();
|
||||
|
||||
// Add a callback to ensure `onAnimationFinish` is dispatched.
|
||||
addFrameCallback(getNextFrameLabel(id), function() {
|
||||
trace('Animation finished: ' + id);
|
||||
onAnimationFinish.dispatch(id);
|
||||
});
|
||||
anim.callback = function(_, frame:Int) {
|
||||
if (frame == (anim.getFrameLabel(id).duration - 1) + anim.getFrameLabel(id).index)
|
||||
{
|
||||
if (loop) playAnimation(id, true, false, true);
|
||||
else
|
||||
onAnimationFinish.dispatch(id);
|
||||
}
|
||||
};
|
||||
|
||||
// Prevent other animations from playing if `ignoreOther` is true.
|
||||
if (ignoreOther) canPlayOtherAnims = false;
|
||||
|
@ -128,6 +129,11 @@ class FlxAtlasSprite extends FlxAnimate
|
|||
this.currentAnimation = id;
|
||||
}
|
||||
|
||||
override public function update(elapsed:Float)
|
||||
{
|
||||
super.update(elapsed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the current animation.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue