Fix an issue where story menu characters bop too fast

This commit is contained in:
EliteMasterEric 2024-03-08 21:33:06 -05:00
parent 7c99905312
commit 09029718aa
2 changed files with 20 additions and 11 deletions

View file

@ -167,10 +167,7 @@ class Bopper extends StageProp implements IPlayStateScriptedClass
function update_shouldAlternate():Void function update_shouldAlternate():Void
{ {
if (hasAnimation('danceLeft')) this.shouldAlternate = hasAnimation('danceLeft');
{
this.shouldAlternate = true;
}
} }
/** /**
@ -228,10 +225,11 @@ class Bopper extends StageProp implements IPlayStateScriptedClass
/** /**
* Ensure that a given animation exists before playing it. * Ensure that a given animation exists before playing it.
* Will gracefully check for name, then name with stripped suffixes, then 'idle', then fail to play. * Will gracefully check for name, then name with stripped suffixes, then fail to play.
* @param name * @param name The animation name to attempt to correct.
* @param fallback Instead of failing to play, try to play this animation instead.
*/ */
function correctAnimationName(name:String):String function correctAnimationName(name:String, ?fallback:String):String
{ {
// If the animation exists, we're good. // If the animation exists, we're good.
if (hasAnimation(name)) return name; if (hasAnimation(name)) return name;
@ -247,14 +245,22 @@ class Bopper extends StageProp implements IPlayStateScriptedClass
} }
else else
{ {
if (name != 'idle') if (fallback != null)
{ {
FlxG.log.warn('Bopper tried to play animation "$name" that does not exist, fallback to idle...'); if (fallback == name)
return correctAnimationName('idle'); {
FlxG.log.error('Bopper tried to play animation "$name" that does not exist! This is bad!');
return null;
}
else
{
FlxG.log.warn('Bopper tried to play animation "$name" that does not exist, fallback to idle...');
return correctAnimationName('idle');
}
} }
else else
{ {
FlxG.log.error('Bopper tried to play animation "idle" that does not exist! This is bad!'); FlxG.log.error('Bopper tried to play animation "$name" that does not exist! This is bad!');
return null; return null;
} }
} }

View file

@ -45,6 +45,9 @@ class LevelProp extends Bopper
this.visible = true; this.visible = true;
} }
// Reset animation state.
this.shouldAlternate = null;
var isAnimated:Bool = propData.animations.length > 0; var isAnimated:Bool = propData.animations.length > 0;
if (isAnimated) if (isAnimated)
{ {