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

 Username:
 Password:
   Not a member? Register!



Home > RGSS Script Reference > Window_PartyCommand

Window_PartyCommand


Inherits from: Window_Selectable

Description: This window shows the "Fight" and "Flee" options that appear at the beginning of each turn in battle.

Code


class Window_PartyCommand < Window_Selectable
# ------------------------------------
 def initialize
    super(0, 0, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = 160
    @commands = ["Fight", "Flee"]
    @item_max = 2
    @column_max = 2
    draw_item(0, normal_color)
    draw_item(1, $game_temp.battle_can_escape ? normal_color : disabled_color)
    self.active = false
    self.visible = false
    self.index = 0
  end
# ------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(160 + index * 160 + 4, 0, 128 - 10, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index], 1)
  end
# ------------------------------------
  def update_cursor_rect
    self.cursor_rect.set(160 + index * 160, 0, 128, 32)
  end
end

Properties


Commands: An array containing the two commands that are shown.

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. The width is set to 640 pixels, and the height to 64 pixels. Because this window appears in battle, its back opacity is set to 160 (translucent). The @commands array is then set to be ["Fight", "Flee"]. Because the items are to appear horizontally, both @item_max and @column_max are set to 2. Index 0 (Fight) is always drawn in the normal color. If the party can escape from this battle, then index 1 (Flee) is also drawn in the normal color. If the party can't escape, it is drawn in the disabled color. The window is then made inactive and invisible. Lastly, the window's contents are drawn with the refresh method.

Draw_Item

Arguments:
Index: The number of the index in @commands that will be drawn.
Color: The color in which the item will be drawn.
Local Variables: None

How it Works: This method draws one of the items in the party command window in the specified color. First, the font color is set to the color passed to this method. Next, the rectangle in which the command will be drawn is defined. The x coordinate is 160, plus 160 times the index of the command to be drawn, plus 4. The y coordinate is always 0. The width is always 118, and the height is always 32. The text is then drawn in the rectangle that was just defined. Notice that the optional alignment argument "1" is used in the self.contents.draw_text statement, meaning that the text will be centered within its rectangle.

Update_Cursor_Rect

Arguments: None
Local Variables: None

How it Works: This method updates the position of the cursor rectangle. If the index is 0 (Fight), the rectangle is drawn at (160,0). If the index is 1 (Flee), the rectangle is drawn at (320,0). In both cases, the width of the rectangle is 128 and the height is 32. 
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