Merge pull request #381 from FunkinCrew/bugfix/story-menu-fast-bop

Fix an issue where story menu characters bop too fast
This commit is contained in:
Cameron Taylor 2024-03-10 13:28:01 -04:00 committed by GitHub
commit dab80f4f60
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
{
if (hasAnimation('danceLeft'))
{
this.shouldAlternate = true;
}
this.shouldAlternate = hasAnimation('danceLeft');
}
/**
@ -228,10 +225,11 @@ class Bopper extends StageProp implements IPlayStateScriptedClass
/**
* 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.
* @param name
* Will gracefully check for name, then name with stripped suffixes, then fail to play.
* @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 (hasAnimation(name)) return name;
@ -247,14 +245,22 @@ class Bopper extends StageProp implements IPlayStateScriptedClass
}
else
{
if (name != 'idle')
if (fallback != null)
{
FlxG.log.warn('Bopper tried to play animation "$name" that does not exist, fallback to idle...');
return correctAnimationName('idle');
if (fallback == name)
{
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
{
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;
}
}

View file

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