Home > RGSS Script Reference > Window_Target
Window_Target
Inherits from: Window_Selectable
Description: This window is shown when the player selects an item or skill that requires a target in the item or skill menus within the main menu. This window isn't shown in battle.
class Window_Target < Window_Selectable
# ------------------------------------
def initialize
super(0, 0, 336, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.z += 10
@item_max = $game_party.actors.size
refresh
end
# ------------------------------------
def refresh
self.contents.clear
for i in 0...$game_party.actors.size
x = 4
y = i * 116
actor = $game_party.actors[i]
draw_actor_name(actor, x, y)
draw_actor_class(actor, x + 144, y)
draw_actor_level(actor, x + 8, y + 32)
draw_actor_state(actor, x + 8, y + 64)
draw_actor_hp(actor, x + 152, y + 32)
draw_actor_sp(actor, x + 152, y + 64)
end
end
# ------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.set(0, 0, self.width - 32, @item_max * 116 - 20)
else
self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
end
end
end
|
This class has no properties.
Initialize
Arguments: None
Local Variables: None
How it Works: This method initializes the window. The x and y coordinates of the upper-left pixel of the window are both set at 0, though the y coordinate of the window will change based on the position of the item or skill selected within its parent window. The width is set to 338 pixels, and the height to 480 pixels. Because this window is meant to appear above its parent window, the z-index of this window is increased by 10. The value of @item_max is set to the number of actors in the party, and then the window's contents are drawn with the refresh method.
Refresh
Arguments: None
Local Variables: None
How it Works: This method draws the window's contents, in a very similar way to the method Window_MenuStatus#Refresh. For each actor in the party, the various elements in the character's status (name, class, level, status, HP, and SP) are drawn relative to the x and y coordinates declared in the first two statements of the for loop (x = 4, and y = 116 times the relative position of the party member, by default). Explanations of the methods called to draw the different elements can all be found in the documentation for Window_Base.
Update_Cursor_Rect
Arguments: None
Local Variables: None
How it Works: This method updates the position of the cursor rectangle. Since this window allows the cursor to target all party members at once, having an @index value of -1 has a special meaning, namely "target all". Thus, if the value of @index is less than 0, the rectangle is drawn at x and y coordinates 0, with a width as wide as the window itself, minus 32 pixels. The height of the rectangle is determined by the number of actors currently in the party (the value of @item_max. Specifically, the height is 116 times the number of actors in the party, minus 20. If the value of @index is 0 or greater, then a single actor is highlighted, so the y coordinate of the rectangle is 116 times the value of @index and the height is fixed at 96 as opposed to that which was described above.
|
|