#==============================================================================
# ** Scene_HelloWorld
#------------------------------------------------------------------------------
# A test scene class.
#==============================================================================
class Scene_HelloWorld < Scene_Base
#==============================================================================
# ** Window_HelloWorld
#------------------------------------------------------------------------------
# Window class where we show "Hello World".
#==============================================================================
class Window_HelloWorld < Window_Base
TEXT_ALIGNMENT = 1 # 1 means text will be centre to it's rectangle
#--------------------------------------------------------------------------
# * Construction: called with Window_HelloWorld.new( x, y, width, height )
#--------------------------------------------------------------------------
def initialize( x, y, width, height )
super( x, y, width, height ) # Window_Base.initialize( x, y, width, height )
refresh # Draw contents
end
#--------------------------------------------------------------------------
# * Where all the drawing is done, call this when contents change
#--------------------------------------------------------------------------
def refresh
contents.clear # Clear graphics in the window
# Size of text box is x,y,width,heigth
# Text to draw "Hello World"
# With out constant TEXT_ALIGNMENT
draw_text( 0, 0, contents.width, contents.height, "Hello World", TEXT_ALIGNMENT )
end
end
#--------------------------------------------------------------------------
# * Called when the scene is first pushed onto the SceneManager
#--------------------------------------------------------------------------
def start
super # Scene_Base.start
create_window( 160, 80 )
end
#--------------------------------------------------------------------------
# * Called on the RGSS update thread every cycle
#--------------------------------------------------------------------------
def update
super # Scene_Base.update
# When the B button is pressed (Esc key, X key default)
if Input.trigger?( :B )
return_scene # SceneManager will return to the last scene viewed
end
end
#--------------------------------------------------------------------------
# * Creates a new Window_HelloWorld in the middle of the screen
#--------------------------------------------------------------------------
def create_window( width, height )
# Calculate where our window's upper left corner is
middleX = ( Graphics.width / 2 ) - ( width / 2 )
middleY = ( Graphics.height / 2 ) - ( height / 2 )
# Create Window_HelloWorld at left,top with width,height
@window = Window_HelloWorld.new( middleX, middleY, width, height )
end
end