deepnight / gameBase

Base structure for my games, using Heaps framework and Haxe language.
https://deepnight.net
MIT License
614 stars 152 forks source link

Fix ESCAPE key triggering exit when console is active #49

Closed deepnight closed 3 years ago

Sookhaal commented 3 years ago

From the advancedBase branch: The console hides before the !App.ME.anyInputHasFocus() check and is therefore always true when ESC is pressed. https://github.com/deepnight/gameBase/blob/2af1d7fc678c2dbd3567736cf425b622c24fbb1e/src/game/gm/Game.hx#L212 A quick and simple fix would be to hide the console after a 1 frame delay by overriding the hide() function:

// Inside gameBase/src/ui/Console.hx
override function hide() {
    App.ME.delayer.addF(() -> {
        bg.visible = false;
        tf.text = "";
        hintTxt.text = "";
        tf.cursorIndex = -1;
    }, 1);
}

I'm quite new to Haxe so that may not be the best solution at all, but I hope it can still be useful!