PDA

View Full Version : Creating your own window in rgss.


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.

Peekimon
May 3rd, 2005, 08:48 AM
Although, I know most of it, it is a perfect tutorial for beginners. You make life easier for beginners... Good Job!

Mooshykris
May 18th, 2005, 02:26 PM
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.


Where do you type the code?

Peekimon
May 18th, 2005, 02:36 PM
Uh, basically, you create a new class above main

Mooshykris
May 18th, 2005, 03:04 PM
Uh, basically, you create a new class above main
??? What do you mean? In the Rgss editor?

Esai
May 18th, 2005, 03:49 PM
yes, all this RGSS will be used in the RGSS Editor

BlackCharizard
June 9th, 2005, 09:25 PM
Actually, virtual said to place it in window_base.

Blizzy
June 10th, 2005, 08:10 AM
Actually, virtual said to place it in window_base.
not really.
i said something similiar to this:
your window is a sub-class of window_base.
you need to paste the code in a new script:
right-click on main and insert

BlackCharizard
June 10th, 2005, 12:33 PM
OoOh. Sorry. I re=read it and you said to make the window to become part of window_base. Okay. I understand this now.

Hack_Slash_Scizor
July 9th, 2005, 02:55 AM
lol, so uh, how do i get this window to come up? :oops:

Blizzy
July 14th, 2005, 06:45 PM
lol, so uh, how do i get this window to come up? :oops:
in a call script do:
@window = My_Window.new

to change the x & y
@window.x = 20
@window.y = 20

to erase it:
@window.dispose

to update it:
@window.update

Hack_Slash_Scizor
July 15th, 2005, 10:25 AM
oh man i am sch a n00b, i still dont get it... i just wanna make it so in my menu, when i go to POKéNAV, it brings up this window?