Hello.
I am currently working on a game with a feature of displaying current game time in player's menu. It should be shown in a window, right above gold. I have wrote this script and called it Window_Time:
CODE
#==============================================================================
# ** Window_Time
#------------------------------------------------------------------------------
# This window displays playtime on the menu screen.
#==============================================================================
class Window_Time < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 160, WLH * 3)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@time = Graphics.frame_count / Graphics.frame_rate
hour = @time / 60 / 60
min = @time / 60 % 60
sec = @time % 60
text = sprintf("Game time: %dh:%dmin", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(0, 0, 120, self.height / 2, text, 1)
end
end
# ** Window_Time
#------------------------------------------------------------------------------
# This window displays playtime on the menu screen.
#==============================================================================
class Window_Time < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 160, WLH * 3)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@time = Graphics.frame_count / Graphics.frame_rate
hour = @time / 60 / 60
min = @time / 60 % 60
sec = @time % 60
text = sprintf("Game time: %dh:%dmin", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(0, 0, 120, self.height / 2, text, 1)
end
end
Next, I've added this line in Scene_Menu:
CODE
@time_window = Window_Time.new(0, 248)
Now when I press ESC in game, the window with text 'Game time: 0h:0min" is shown for a second and then it just disappears... How to make it work? Thanks in advance for any answers!