Blizzy
May 3rd, 2005, 05:12 AM
Creating your own Window.
to create a simple window, you need to have this:
class My_Window < Window_Base
def initialize
super(80,80,480,320)
end
end
this is a standart window.
now for explaining the lines
class My_Window < Window_Base
make the window to be come a part of Window_Base.
def initialize
initializes the window.
super(80,80,480,320)
this creates the window
x, 80
y, 80
width, 480
height, 320.
this is a empty window.
let's put some text in it.
class My_Window < Window_Base
def initialize
super(80,80,480,320)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.contents.font.color = normal_color
refresh
end #method
def refresh
self.contents.draw_text(4,4,120,32,"Look! Text")
end #method
end #class
now for explaining the new lines:
self.contents = bitmap.new(width - 32, height - 32)
this needs to be in every def initialize.
without this, text wouldn't appear.
self.contents.font.name = $fontface
this "grabs" the font.
self.contents.font.size = $fontsize
this is the size of the font.
self.contents.font.color = normal_color
this is the color of the text that will be displayed
refresh
this means it goes to the method "refresh".
def refresh
this is a method, which is called by "refresh"
self.contents.draw_text(4,4,120,32,"Look! Text")
this draws the text on screen. at (4,4,120,32)
This is a small window, with text.
which is boring
so, let's display the hero graphic.
class My_Window < Window_Base
def initialize
super(80,80,480,320)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.contents.font.color = normal_color
refresh
end #method
def refresh
self.contents.draw_text(4,4,120,32,"Look! Text")
for i in 0...$game_party.actors.size
x = i * 32 + 4
y = 32
actor = $game_party.actors[i]
draw_actor_graphic(actor,x)
end #for
end #method
end #class
for i in 0...$game_party.actors.size
this puts the number of hero's in the letter "i"
x = i * 32 + 16
this is the x coordinate.
i is the number of hero's that will multiply with 32, and then + 16.
the higher the 32, the more space between the actors.
y = 96
this is the y coordinate of the actor.
actor = $game_party.actors[i]
this sets actor equal to $game_party.actors[i]
which are the "heros" in the game.
to call this Window, put the following in a call script:
My_Window.new
this is it.
now you guys can start working on your own trainercard.
which is basicly the way.
to create a simple window, you need to have this:
class My_Window < Window_Base
def initialize
super(80,80,480,320)
end
end
this is a standart window.
now for explaining the lines
class My_Window < Window_Base
make the window to be come a part of Window_Base.
def initialize
initializes the window.
super(80,80,480,320)
this creates the window
x, 80
y, 80
width, 480
height, 320.
this is a empty window.
let's put some text in it.
class My_Window < Window_Base
def initialize
super(80,80,480,320)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.contents.font.color = normal_color
refresh
end #method
def refresh
self.contents.draw_text(4,4,120,32,"Look! Text")
end #method
end #class
now for explaining the new lines:
self.contents = bitmap.new(width - 32, height - 32)
this needs to be in every def initialize.
without this, text wouldn't appear.
self.contents.font.name = $fontface
this "grabs" the font.
self.contents.font.size = $fontsize
this is the size of the font.
self.contents.font.color = normal_color
this is the color of the text that will be displayed
refresh
this means it goes to the method "refresh".
def refresh
this is a method, which is called by "refresh"
self.contents.draw_text(4,4,120,32,"Look! Text")
this draws the text on screen. at (4,4,120,32)
This is a small window, with text.
which is boring
so, let's display the hero graphic.
class My_Window < Window_Base
def initialize
super(80,80,480,320)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.contents.font.color = normal_color
refresh
end #method
def refresh
self.contents.draw_text(4,4,120,32,"Look! Text")
for i in 0...$game_party.actors.size
x = i * 32 + 4
y = 32
actor = $game_party.actors[i]
draw_actor_graphic(actor,x)
end #for
end #method
end #class
for i in 0...$game_party.actors.size
this puts the number of hero's in the letter "i"
x = i * 32 + 16
this is the x coordinate.
i is the number of hero's that will multiply with 32, and then + 16.
the higher the 32, the more space between the actors.
y = 96
this is the y coordinate of the actor.
actor = $game_party.actors[i]
this sets actor equal to $game_party.actors[i]
which are the "heros" in the game.
to call this Window, put the following in a call script:
My_Window.new
this is it.
now you guys can start working on your own trainercard.
which is basicly the way.