Help - Search - Members - Calendar
Full Version: [Scripting]Window Properties
RPG RPG Revolution Forums > Scripting > Script Tutorials > RGSS
woratana
[Basic RGSS/2] Window Properties

By: Woratana
Date: 10/04/2008
Exclusive Article @ RPG RPG Revolution

Hi, this is my first article about RGSS. The basic properties of Window in RGSS and RGSS2 are pretty much the same, so you can use read this article for both RGSS and RGSS2.

Window is the hidden class in RGSS. You can't see the code about how it's made, but you can you use, control it, and make it easier to use by use Window_Base, Window_Selectable, Window_Command etc. Don't worry if you don't understand about Window_Base or Window_Selectable, this article will not focus on those things yet. tongue.gif

This article will help you to learn more about Window's properties. I will just focus on important properties that I usually use. Because I will be able to give good enough description about it. smile.gif

The properties will write on this template:
QUOTE
(Property Name)
Description: (Description from RMVX Help File)
Additional: (My description & Sample Image)
Script: (How to use/change it in script)


[Basic RGSS/2] Window Properties


X
Description: The window's X-coordinate.
Additional: a.k.a. 'Screen X' in event command 'Control Variables...'. For RMXP (RPG Maker XP), it wil goes from 0 (left of the screen) to 640 (right of the screen). For RMVX (RPG Maker VX :3), it will goes from 0 to 544. Take a look at images below for easier understanding. 1 in window's X = 1 pixel.
Script:
CODE
window.x = (integer)

(window in this case is 'the name of variable that hold this window', or use 'self' if using this in its class)


Y
Description: The window's Y-coordinate.
Additional: a.k.a. 'Screen Y' in event command 'Control Variables...'. For RMXP, it will go from 0 (top of the screen) to 480 (bottom end of the screen). For RMVX, it will goes from 0 to 416. Take a look at images below for easier understanding. 1 in window's Y = 1 pixel.
Script:
CODE
window.y = (integer)



RMXP Screen X/Y


RMVX Screen X/Y


Width
Description: The window's width
Additional: Window's width can be in any size you want, but should be at least 33 because of its 'contents' size. (I will explain about contents later) 1 in window's width = 1 pixel.
Script:
CODE
window.width = (integer)



Height
Description: The window's height.
Additional: Same as width, this should be at least 33. 1 in window's height = 1 pixel.
Script:
CODE
window.height = (integer)





Z
Description: The window's Z-coordinate. The larger this value, the closer to the player the plane will be displayed. If multiple objects share the same Z-coordinate, the more recently created object will be displayed closest to the player.
Description(RGSS2): It is no longer possible to use different Z coordinates for the window's background and its contents.
Additional: Basically, window will show above other window if it has more Z


or it's created after the other window.


Script:
CODE
window.z = (integer)



Windowskin
Description: Refers to the bitmap (Bitmap) used as a windowskin
Description(RGSS2): Only RPGVX skins may be used.
Additional: It stores the bitmap that you use for window skin. Different windows can have different skins. RMXP and RMVX is using different style of windowskin.
Script:
CODE
window.windowskin = (Bitmap)





Contents
Description: Refers to the bitmap (Bitmap) used for the window's contents.
Additional: It is the bitmap that create to draw text/images on window. It should have size (width, height) equal to (window's width - 32, window's height - 32). Because if content's size is bigger than that, you will see arrow on the sides of window. And this is why your window width's and height should be at least 33, you will have contents size at least 1 x 1 pixel. (Bitmap size 0 x 0 or negative size is not possible)

Here is the image of default content's size.


In RMVX, Window_Base will automatically create and dispose(clear it from memory) contents for you. But Window_Base in RMXP will only dispose contents for you. You have to create contents by:
CODE
self.contents = Bitmap.new(width - 32, height - 32)



Contents will prevent you from draw text outside window, which will lead to the arrow shows on the side. If you draw text and it's exceed content's size, the text will be cut off, like this:


Script: (Use in its window class only)
CODE
self.contents = Bitmap.new(width - 32, height - 32)

To create bitmap
CODE
self.contents.(method for bitmap, e.g. draw_text, fill_rect)

To control bitmap


Opacity
Description: The window's opacity (0-255). Values out of range are automatically corrected.
Additional: When window's opacity is changed, it will change the window's background and border's opacity. Content's (text/image that draw on window's contents) opacity will not change. 0 is lowest (you can't see window's background and border), 255 is highest.
Script:
CODE
window.opacity = (0 - 255)





Back_Opacity
Description: The window background's opacity (0-255). Values out of range are automatically corrected.
Additional: Similar to Opacity, but this will change only background's opacity, not border.
Script:
CODE
window.back_opacity = (0 - 255)





Contents_Opacity
Description: The opacity of the window's contents (0-255). Values out of range are automatically corrected.
Additional: This will change content's opacity, so it will change the opacity of text and image that draw on window's contents.
Script:
CODE
window.contents_opacity = (0 - 255)





Visible
Description: The window's visibility. If TRUE, the window is visible.
Additional: This is one of the useful properties when making HUD or Menu. Window will show if visible is true, and hide if visible is false.
Script: window.visible = (true/false)


==========================================
Some of properties that I didn't put in this article can be found in RMXP/VX help file (press F1 in program), search by keyword 'Window'.

If you have any question or suggestion about this article, feels free to post. I'll glad to hear(read) it. smile.gif

Thanks!
YanXie
Good job Wora :3 ,I hope with this guide,there will be less request for non-sensical scripts after this tongue.gif

Too bad I won't do anything about the syntax list until I finish the storage script tongue.gif

cheers,puppeto4. smile.gif
ERZENGEL
That's a great tutorial for modifying windows, woratana!
woratana
Thanks for reading this! puppeto and Erzengel.

Let me know if there's any article/tutorial you want me to write about smile.gif
Holder
This is great, I love to see things like this. From what you've covered here you've put alot of effort into it and with picture examples (always useful thumbsup.gif ).

Is this a first in a long run of Articles? If it is so then I hope you can continue past where most stop, it's normally past the variables and conditional statements part.

Just as a suggestion woratana, I would enjoy seeing how complete scripts come together - meaning as a tutorial, what you're using(code wise) and what it does to the final result.
Shichoku
Thanks for the excellent tutorial, Wora, and for the help that you provided me with the other day. :3
lahandi
QUOTE
Let me know if there's any article/tutorial you want me to write about


Can you tell me how to create some set of windows that can be called an closed when the player pressing certain button?

Thank you. smile.gif
YanXie
If you mean call and close window,and not write the window script,then you can easily do that by common event smile.gif

Look at screenshot below :



cheers,puppeto4. smile.gif
barkot
w00t!
Thanks Woratana-kun! biggrin.gif
This tut helped a lot biggrin.gif

yours,
Bark =]
Rukiri
Thanks man, This is gonna help for my custom Menu system I plan on doing, also how is RGSS2 different from ruby and RGSS1?
woratana
@Mystic

Not really different, tongue.gif

There're one article in RRR main site that talk about this though,
but I can't get you the link because I can't enter main site now.
semajames
Hey wora, great script. Could you post a tutorial clearly defining the differences between RGSS and RGSS2. I'm trying to learn scripting and have found some good tutorials for RGSS, but I'm running VX, so I'm getting a bit confused as to the difference between the 2. RMVX's help file doesn't clearly tell me, and I havn't found a good tutorial for this either. I'd appreciate the help.
GaijinSama
Exacly what I was looking for! Thanks so much!
carbajosa
I have made my window script but I have no Idea how to call it on event. Can someone teach me?
Leventhan
Excellent tutorial. =)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.