.show
one window at a time.
class Launcher < Gosu::Window
def initialize
super(200, 500, false)
self.caption = "test"
end
def button_down(id)
if id == Gosu::KbF12
Window.new.show
exit
end
end
end
if id == Gosu::KbF12
close
Window.new.show
end
button_down
is called in the main loop that Launcher#show
starts. So basically the launcher window will be stuck forever in its loop, waiting for the whole main Window#show
loop to finish. The call stack will be (among others) main > Launcher#show > Launcher#button_down > Window.show.Launcher.new.show # stores settings in global $settings_from_launcher
# .show returns at some point because .close was called
Window.new($settings_from_launcher).show
Window#show
looks like this (pseudocode):def show
show_OS_window_on_screen()
while not self.closed?
self.button_down(x) for each x that the OS reports
self.update()
self.draw()
sleep(16ms)
end
hide_OS_window()
end
.show
on it from within button_down
, you will have two nested while
loops, one for each window, and the outer loop will be stuck until the inner while
loop completes. So the first window never has a chance to clean up and hide itself.Window#show
to return (doesn't matter if you've manually called close
or if the user clicks the X), and only then show
the second window. So, more like:Launcher.new.show
puts "the first window has been closed now"
GameWindow.new.show
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill