G@MeF@Ce
![]() | ||
CD3DF5

Here you will learn to create a basic window with a simple text message to be displayed.
Each line of code will be commented to explain it's purpose.
Start by copy and paste this script into the RMXP script data base (F11)
- Code:
class My_First_Window < Window_Base #1
def initialize #2
super(0, 0, 350, 150) #3
self.contents = Bitmap.new (width - 32, height - 32) #4
#this shows what is in the window with a 32pixel margin#5
refresh # run the variable named "refresh"#6
end # end the initialization process#7
def refresh #8 define what refresh does
self.contents.clear #9 clear content of the variable Bitmap
self.contents.draw_text(0, 0, 300, 32,"This is my first window")#10
end #11 end the refresh process
end #12end the window class
Now let's take a look at each line of code...
#1 = class sub-window under the Window Base class.
- Code:
class My_First_Window < Window_Base
#2 = define start process
- Code:
def initialize
#3 = instruct window size and location
- Code:
super(0, 0, 350, 150)
"super" calls the Class to start
(arguments) = from left to right
0= x window position
0 = y window position
350= x window width
150 = y window height
#4 = like the body to a web page, this creates the viewable content inside the window with a 32 pixel margin or inner frame
- Code:
self.contents = Bitmap.new (width - 32, height - 32)
#5 = is just a comment line beginning with a #
- Code:
#this shows what is in the window with a 32pixel margin#5
*in case you missed the first lesson...
RGSS+RMXP Comments
#6 = this calls the method named refresh which is defined later in the script
- Code:
refresh # run the variable named "refresh"#6
#7 = end method
just like HTML tags in where you have to start and end a link, or div,
RGSS is pretty much the same in regards to starting a class, def (method) to 'if statements.
- Code:
end #to close/end the defined method 'initialize'#7
*note, when running a script, the system looks for the 'initialize' method first if not then 'main'
or it will crash*
#8 = just like defining the initialize method, this will define a method call 'refresh'
*remember we are calling this method 0n line #6 which is called inside the initialize method ~ still with me?
- Code:
def refresh #8 define what refresh does
#9 = this basically clears the window's contents so that there is a clean slate every time you call your window
- Code:
self.contents.clear #9 clear content of the variable Bitmap
#10 = now this writes the test message on the clean slate
- Code:
self.contents.draw_text(0, 0, 300, 32,"This is my first window")#10
self.(this window)contents.(what's inside)draw_text(0,0,300,32,"YOUR TEXT")
(arguments) = from left to right
0= text horizontal position
0= text vertical position
300 = width of text field
32 = height of text field
"YOUR TEXT" = keep in between " "
11 = close the defined method named refresh
- Code:
end #11 end/close the refresh process
12 = close the defined class named
My First Window - which is being used under the Window_Base class.
- Code:
end #12end the window class
Now to display this window you may use an event with the following call script in the list of event commands
(RMXP - third tab, bottom right option)
- Code:
My_First_Window.new
your window will look just like this!
- Spoiler:

simple but not easy...
the level of difficulty will increase as we continue our adventures in RGSS for RMXP
*remember I'm only sharing what I'm learning = 101

























































could it be the enemy mini hud script got bug (where sometimes doesnt show its hud) because of the refresh problem? or not enough of it?









