diff --git a/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx b/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx index fefb224eb..30ee20068 100644 --- a/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx +++ b/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx @@ -95,7 +95,7 @@ class FlxAtlasSprite extends FlxAnimate */ public function hasAnimation(id:String):Bool { - return getLabelIndex(id) != -1; + return getLabelIndex(id) != -1 || anim.symbolDictionary.exists(id); } /** @@ -112,6 +112,8 @@ class FlxAtlasSprite extends FlxAnimate var looping:Bool = false; + public var ignoreExclusionPref:Array = []; + /** * Plays an animation. * @param id A string ID of the animation to play. @@ -124,7 +126,25 @@ class FlxAtlasSprite extends FlxAnimate public function playAnimation(id:String, restart:Bool = false, ignoreOther:Bool = false, loop:Bool = false, startFrame:Int = 0):Void { // Skip if not allowed to play animations. - if ((!canPlayOtherAnims && !ignoreOther)) return; + if ((!canPlayOtherAnims)) + { + if (this.currentAnimation == id && restart) {} + else if (ignoreExclusionPref != null && ignoreExclusionPref.length > 0) + { + var detected:Bool = false; + for (entry in ignoreExclusionPref) + { + if (StringTools.startsWith(id, entry)) + { + detected = true; + break; + } + } + if (!detected) return; + } + else + return; + } if (anim == null) return; @@ -132,16 +152,12 @@ class FlxAtlasSprite extends FlxAnimate if (this.currentAnimation == id && !restart) { - if (anim.isPlaying) - { - // Skip if animation is already playing. - return; - } - else + if (!anim.isPlaying) { // Resume animation if it's paused. anim.play('', restart, false, startFrame); } + return; } else { @@ -174,18 +190,19 @@ class FlxAtlasSprite extends FlxAnimate // Move to the first frame of the animation. // goToFrameLabel(id); trace('Playing animation $id'); - if (this.anim.symbolDictionary.exists(id) || (this.anim.getByName(id) != null)) - { - this.anim.play(id, restart, false, startFrame); - } // Only call goToFrameLabel if there is a frame label with that name. This prevents annoying warnings! if (getFrameLabelNames().indexOf(id) != -1) { goToFrameLabel(id); fr = anim.getFrameLabel(id); + anim.curFrame += startFrame; + } + else + { + this.anim.play(id, restart, false, startFrame); + fr = null; } - anim.curFrame += startFrame; this.currentAnimation = id; } diff --git a/source/funkin/play/character/AnimateAtlasCharacter.hx b/source/funkin/play/character/AnimateAtlasCharacter.hx index f432d08a0..b78aed983 100644 --- a/source/funkin/play/character/AnimateAtlasCharacter.hx +++ b/source/funkin/play/character/AnimateAtlasCharacter.hx @@ -166,6 +166,8 @@ class AnimateAtlasCharacter extends BaseCharacter this.mainSprite = sprite; + mainSprite.ignoreExclusionPref = ["sing"]; + // This forces the atlas to recalcuate its width and height this.mainSprite.alpha = 0.0001; this.mainSprite.draw();