1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-15 11:22:55 +00:00

readd FlxAtlasSprite from char unlock branch

This commit is contained in:
CheemsAndFriends 2024-09-11 20:47:45 +02:00
parent c81f041695
commit bea23c37a8
2 changed files with 30 additions and 34 deletions

View file

@ -95,7 +95,7 @@ class FlxAtlasSprite extends FlxAnimate
*/ */
public function hasAnimation(id:String):Bool public function hasAnimation(id:String):Bool
{ {
return getLabelIndex(id) != -1 || anim.symbolDictionary.exists(id) || anim.getByName(id) != null; return getLabelIndex(id) != -1 || anim.symbolDictionary.exists(id);
} }
/** /**
@ -155,19 +155,23 @@ class FlxAtlasSprite extends FlxAnimate
if (!anim.isPlaying) if (!anim.isPlaying)
{ {
// Resume animation if it's paused. // Resume animation if it's paused.
anim.play('', restart, false, startFrame); anim.resume();
} }
return; return;
} }
else else if (!hasAnimation(id))
{ {
// Skip if the animation doesn't exist // Skip if the animation doesn't exist
if (!hasAnimation(id))
{
trace('Animation ' + id + ' not found'); trace('Animation ' + id + ' not found');
return; return;
} }
}
this.currentAnimation = id;
anim.onComplete.removeAll();
anim.onComplete.add(function() {
_onAnimationComplete();
});
looping = loop; looping = loop;
@ -177,20 +181,18 @@ class FlxAtlasSprite extends FlxAnimate
// Move to the first frame of the animation. // Move to the first frame of the animation.
// goToFrameLabel(id); // goToFrameLabel(id);
trace('Playing animation $id'); trace('Playing animation $id');
if (this.anim.symbolDictionary.exists(id) || (this.anim.getByName(id) != null))
{
this.anim.play(id, true, false, startFrame);
fr = null;
}
// Only call goToFrameLabel if there is a frame label with that name. This prevents annoying warnings! // Only call goToFrameLabel if there is a frame label with that name. This prevents annoying warnings!
if (getLabelIndex(id) != -1) if (getFrameLabelNames().indexOf(id) != -1)
{ {
goToFrameLabel(id); goToFrameLabel(id);
fr = anim.getFrameLabel(id); fr = anim.getFrameLabel(id);
anim.curFrame += startFrame; anim.curFrame += startFrame;
} }
else
{
this.anim.play(id, restart, false, startFrame);
fr = null;
}
this.currentAnimation = id;
} }
override public function update(elapsed:Float) override public function update(elapsed:Float)
@ -288,12 +290,13 @@ class FlxAtlasSprite extends FlxAnimate
{ {
anim.pause(); anim.pause();
_onAnimationComplete(); _onAnimationComplete();
if (looping) if (looping)
{ {
anim.curFrame = (fr != null) ? fr.index : 0; anim.curFrame = (fr != null) ? fr.index : 0;
anim.resume(); anim.resume();
} }
else else if (fr != null)
{ {
anim.curFrame--; anim.curFrame--;
} }

View file

@ -116,24 +116,17 @@ class IntroSubState extends MusicBeatSubState
*/ */
function onAttractEnd():Void function onAttractEnd():Void
{ {
#if html5
if (vid != null)
{
remove(vid);
}
#end
#if hxCodec
if (vid != null)
{
vid.stop();
remove(vid);
}
#end
#if (html5 || hxCodec) #if (html5 || hxCodec)
if (vid != null)
{
#if hxCodec
vid.stop();
#end
remove(vid);
vid.destroy(); vid.destroy();
vid = null; vid = null;
}
#end #end
close(); close();