Home > Tutorials > Ruby Game Scripting System 2 > Window Properties
Window Properties 
[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. :P
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. :)
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 scren). 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 wil goes from 0 (top of the screen) to 480 (bottom end of the scren). 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. :)
Thanks!
|
|
Details
|
|
Tutorial:
|
Window Properties |
|
Date Listed:
|
2008-06-02 |
|
Author:
|
woratana
|
|
Total Hits:
|
8779 |
|
|