Home > RGSS Script Reference > Window_BattleStatus
Window_BattleStatus
Inherits from: Window_Base
Description: This class is for the window that shows the party's HP, SP, and status in battle.
class Window_BattleStatus < Window_Base
# ------------------------------------
def initialize
super(0, 320, 640, 160)
self.contents = Bitmap.new(width - 32, height - 32)
@level_up_flags = [false, false, false, false]
refresh
end
# ------------------------------------
def dispose
super
end
# ------------------------------------
def level_up(actor_index)
@level_up_flags[actor_index] = true
end
# ------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
actor_x = i * 160 + 4
draw_actor_name(actor, actor_x, 0)
draw_actor_hp(actor, actor_x, 32, 120)
draw_actor_sp(actor, actor_x, 64, 120)
if @level_up_flags[i]
self.contents.font.color = normal_color
self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
else
draw_actor_state(actor, actor_x, 96)
end
end
end
# ------------------------------------
def update
super
if $game_temp.battle_main_phase
self.contents_opacity -= 4 if self.contents_opacity > 191
else
self.contents_opacity += 4 if self.contents_opacity < 255
end
end
end
|
Level_Up_Flags: An array of four flags, one for each position within the party, that tell the window whether it should display the character's status (if the flag is false) or the string "LEVEL UP!" (if the flag is true).
Initialize
Arguments: None
Local Variables: None
How it Works: This method initializes the window's state. First, it sets the x and y coordinates of the window's upper-left pixel to 0, 320, and its width and height to 640 and 160, respectively. The four flags in @level_up_flags are initially set to false since the string "LEVEL UP!" won't be shown under most circumstances. Finally, the call to refresh populates the window with data.
Dispose
Arguments: None
Local Variables: None
How it Works: This method simply calls its superclass method to clear the window and free the memory allocated to it.
Level_Up
Arguments:
Actor_Index: The relative party position of the actor whose level up flag should be set.
Local Variables: None
How it Works: This method sets one flag in @level_up_flags. The array index of the flag set is equal to the index value passed to this method.
Refresh
Arguments: None
Local Variables: None
How it Works: This method draws the window's contents. First, the existing contents of the window are cleared. For each actor in the party, the following is carried out: The method determines at what x coordinate the text for this actor should be drawn. This value is equal to 160 times the actor's index, plus 4 (remember that the first actor has an index of 0). The actor's name is then drawn at this x coordinate, and y coordinate 0. The actor's HP is drawn at this x coordinate, and y coordinate 32, and the actor's SP is drawn at this x coordinate, and y coordinate 64. Note that the allowed width for both the HP and SP text is 120, which by default is not enough to allow the maximum value to be drawn. If the level up flag for this actor is set, then the string "LEVEL UP!" is drawn at the x coordinate established above, and y coordinate 96. Otherwise, the Window_Base#Draw_Actor_State method is called to draw the actor's status ailments. Please see the documentation for Window_Base for information on how this method works.
Update
Arguments: None
Local Variables: None
How it Works: This method updates the window's contents. First, Window_Base#Update is called to perform updating common to all windows. The updating specific to this window involves the text opacity. If the battle's current phase is 4 (Main Phase), the text opacity decreases by 4 each frame if its opacity is more than 191. If it is not the main phase, then the text opacity increases by 4 if its opacity is less than 255. The practical effect of this is that at the beginning of the main phase, the opacity of the text will decrease by 64 over a period of 16 frames, and the reverse will happen at the end of the main phase.
|
|