Submit Your Article Guild Wars 2 Forum RPG Maker VX.com
 
RPG Maker
 

 Username:
 Password:
   Not a member? Register!



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.

Code


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

Properties


This class has no properties.

Methods


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. 
Syntax
@
@@
$
alias
[array index]
attr_accessor
attr_reader
attr_writer
class
def
do
ensure
for
if
[iterator]
key => value
new
next
nil
redo
require
return
rescue
self
super
undef
unless
until
while
yield

Classes
Arrow_Actor
Arrow_Base
Arrow_Enemy
Game_Actor
Game_Actors
Game_BattleAct
Game_Battler
Game_Character
Game_Common
Game_Enemy
Game_Event
Game_Map
Game_Party
Game_Picture
Game_Player
Game_Screen
Game_SlfSwitch
Game_Switches
Game_System
Game_Troop
Game_Variables
Interpreter
Scene_Debug
Scene_End
Scene_Equip
Scene_File
Scene_Gameover
Scene_Item
Scene_Load
Scene_Map
Scene_Menu
Scene_Name
Scene_Save
Scene_Shop
Scene_Skill
Scene_Status
Scene_Title
Sprite_Battler
Sprite_Character
Sprite_Picture
Sprite_Timer
Spriteset_Battle
Spriteset_Map
Window_Base
Window_Battleresult
Window_Battlestatus
Window_Command
Window_DebugLeft
Window_DebugRight
Window_EquipItem
Window_EquipLeft
Window_EquipRight
Window_Gold
Window_Help
Window_InputNumb
Window_Item
Window_MenuStatus
Window_Message
Window_NameEdit
Window_NameInput
Window_PartyCom
Window_PlayTime
Window_SaveFile
Window_Selectable
Window_ShopBuy
Window_ShopCom
Window_ShopNum
Window_ShopSell
Window_ShopStatus
Window_Skill
Window_SkillStatus
Window_Status
Window_Steps
Window_Target

Other
Class Hierarchy
Global Variables


RPG RPG Revolution
RPG RPG Revolution is your #1 stop for game development and console RPG games, as well as those created by people like you. Link to us to support us, so we may grow to be better website community for you.

RPG RPG Revolution is an Privacy Policy and Legal