I'm trying to make a status window in my game that pops up when the player press TAB.
My code is as follows:
It works mostly fine, but there are a few problems: When I first press tab, it doesn't show anything. If I hold tab, it takes a second to show at first. If I alt tab to another window then back again, both problems happen again.
Anyone has any guesses as to why?
My code is as follows:
Code:
var $tab=undefined
var keyconfig_alias = Scene_Map.prototype.updateScene;
Scene_Map.prototype.updateScene = function() {
keyconfig_alias.call(this);
if((Input.isTriggered('tab') || Input.isPressed('tab')) && !$tab){
$tab = new Bitmap(250, 200);
$tab.fillAll("black")
$tabs = new Sprite($tab);
$tabs.x=5
$tabs.y=5
$tabs.alpha=0.5
$tab.fontSize=22
$tab.drawText("Name:"+localStorage.myname+" ID:"+(playerid-100),9,140,200,0.5,"left")
$tab.drawText("Enemies Killed:"+$enemieskilled,9,165,200,0.5,"left")
SceneManager._scene.addChild($tabs);
}else if(!Input.isPressed('tab') && !Input.isTriggered('tab') && $tab){
$tab.clear()
$tab=undefined
}
}
It works mostly fine, but there are a few problems: When I first press tab, it doesn't show anything. If I hold tab, it takes a second to show at first. If I alt tab to another window then back again, both problems happen again.
Anyone has any guesses as to why?