Why are you using global variables if those variables are tied to the object they are made in anyway? Use instant variables.
Global variables are only needed if you have something that should be accessible from all classes (or close to all). Well, it's not really necessary even than, but that's at least a valid reason to use them.
Once you draw something on a bitmap, it stays there for good unless you clear or dispose (and change, optionally) that same bitmap.
This renders your whole attempt of adding that condition check there kinda useless.
Even if you would clear it before and redraw it later over and over again when it's needed to show up, it would be extremely inefficient and needless.
The only thing you need to do is show and hide the window itself (or it's content, if you still want to have the window graphics shown), since the only thing it contains is that one liner text you draw on it.
But all that aside, why would you remove the default update method and replace it with something that's already being updated in another class?
The update method of a window will always run if you made that window object in a scene class and if it's stored in it's own variable (meaning not in an array or hash, or in another object, etc).
If it's not, you can still call the update method every frame in whichever class you made it, and place your show/hide logic there, you don't have to use any kind of loops for it (actually, you shouldn't).
Draw that text right on object creation, just like you have now.
Initialize an instant variable for the timer. The window already has some built-in variables for different show flags/opacity values, so you don't need anything else.
Finally, make the window appear and disappear based on that timer in the update method.
You should end up with something like this:
Spoiler
Code:class Some_Window < Window_Base
def initialize(x,y,w,h)
@timer = 120
super(x,y,w,h)
draw_stuff
end
def draw_stuff()
# Your text drawing here...
end
def update
super
update_vis
end
def update_vis
if @timer > 0
@timer -= 1
else
@timer = 120
self.visible = !self.visible
end
end
end
If you want to make the text disappear only while still showing the window graphics, you can change the
contents_opacity value of the window instead of the
visible flag. That opacity can be set to 0 to 255, 0 being fully transparent.
And that's it. Assuming you create this window in a scene class, you don't even have to do anything else, just make it there and forget about it.
Note that I assumed you use VX Ace. This might work differently in VX or XP, so if you use those, you should let us know.
From the looks of it, you wanted to do something else here when the player press a key too (but no idea what 11 is, you probably use a custom input script?), right?
Depending on what you want to happen on that key press, the solution is different, so I won't go there now unless you ask about that later.
Btw... This part:
Code:"Insert Coin".length * 42
Is probably one of the most unnecessary code bit I ever saw in my coding history.
:D
Not trying to be rude, so I hope you won't get offended by this, just trying to point out a bad habit you may have picked up from somewhere (I saw something like this in other scripts already, sadly).
You know what that text will be, you used a static string there. This makes it pointless to make the system count the length of that string and multiply it by 42, you can easily do it yourself within less than 2 seconds. Don't make your code do unnecessary things, that's the number 1 rule everyone should learn when trying to learn coding. Even if that particular code bit won't really affect performance since it's only called once, it is still unnecessary.
What you did here could be justified if that string would be a dynamically changing string, but it's not, so help your code and replace that with the real number instead (462).
:p
There goes my coffee break!
:D