tighten main menu security to prevent weird crashes during transitions

This commit is contained in:
MtH 2021-03-30 20:52:24 +02:00
parent 4c301801c5
commit 554dfbf60b
2 changed files with 7 additions and 2 deletions

View File

@ -218,6 +218,7 @@ class MainMenuState extends MusicBeatState
function startExitState(state:FlxState)
{
menuItems.enabled = false; // disable for exit
var duration = 0.4;
menuItems.forEach(function(item)
{
@ -241,7 +242,10 @@ class MainMenuState extends MusicBeatState
FlxG.sound.music.volume += 0.5 * FlxG.elapsed;
}
if (menuItems.enabled && controls.BACK)
if (_exiting)
menuItems.enabled = false;
if (controls.BACK && menuItems.enabled && !menuItems.busy)
FlxG.switchState(new TitleState());
super.update(elapsed);

View File

@ -24,7 +24,8 @@ class MenuTypedList<T:MenuItem> extends FlxTypedGroup<T>
var byName = new Map<String, T>();
/** Set to true, internally to disable controls, without affecting vars like `enabled` */
var busy:Bool = false;
public var busy(default, null):Bool = false;
// bit awkward because BACK is also a menu control and this doesn't affect that
public function new (navControls:NavControls = Vertical, ?wrapMode:WrapMode)
{