Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

A problem with switching between actors in Main Menu.

Culex

Member

I am making a main menu that displays the characters separately. For example, when you open up the main menu, it displays only actor #1. I am trying to make it that so when you press Input::L (Q) or Input::R (W), you can switch between the actors.

The problem is, that when I scroll with the "Q" and "W" keys, it will not proceed to the next or previous actor, but will remain on the first actor only. I can't seem to isolate the issue, but I think it has something to do with @menu_index and @actor_index conflicting with one another. I could be wrong.

Here is my Window_MenuStatus:

Code:
#==============================================================================
# ** Window_MenuStatus
#------------------------------------------------------------------------------
#  This window displays party member status on the menu screen.
#==============================================================================

class Window_MenuStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 0, 544, 320)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_graphic(@actor, x, y)
  end
end
As you can see, I tried to modify Window_MenuStatus to conform to the behavior of Window_Status.

Now, here is my Scene_Menu (notice that only have input for Input::R at the moment, which is enough information needed for now):

Code:
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs menu screen processing.
#==============================================================================

class Scene_Menu
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0, menu_index = 0)
    @menu_index = menu_index
    @actor_index = actor_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Get actor
    @actor = $game_party.actors[@actor_index]
    # Make command window
    s1 = "Inventory"
    s2 = "Abilities"
    s3 = "Equipment"
    s4 = "Save Game"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4])
    @command_window.x = 240
    @command_window.y = 192
    @command_window.z = 101
    @command_window.index = @menu_index
    @help_window = Window_Help.new
    @help_window.x = 48
    @help_window.y = 48
    case @command_window.index
    when 0
      @help_window.set_text("View items and artifacts in the inventory.")
    when 1
      @help_window.set_text("View physical or magical abilities.")
    when 2
      @help_window.set_text("Equip or remove weapons and armor.")
    when 3
      @help_window.set_text("Record in-game progress for later reference.")
    end
    # If number of party members is 0
    if $game_party.actors.size == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
      @command_window.disable_item(3)
    end
    # If save is forbidden
    if $game_system.save_disabled
      # Disable save
      @command_window.disable_item(4)
    end
    # Make status window
    @status_window = Window_MenuStatus.new(@actor)
    @status_window.x = 48
    @status_window.y = 112
    # Make location window
    @location_window = Window_Location.new
    @location_window.x = 48
    @location_window.y = 368
    @location_window.opacity = 0
    # Make gold window
    @gold_window = Window_Gold.new
    @gold_window.x = 432
    @gold_window.y = 368
    @gold_window.opacity = 0
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @command_window.dispose
    @help_window.dispose
    @status_window.dispose
    @location_window.dispose
    @gold_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @command_window.update
    @help_window.update
    @status_window.update
    @location_window.update
    @gold_window.update
    case @command_window.index
    when 0
      @help_window.set_text("View items and artifacts in the inventory.")
    when 1
      @help_window.set_text("View physical or magical abilities.")
    when 2
      @help_window.set_text("Equip or remove weapons and armor.")
    when 3
      @help_window.set_text("Record in-game progress for later reference.")
    end
    # If command window is active: call update_command
    if @command_window.active
      update_command
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when command window is active)
  #--------------------------------------------------------------------------
  def update_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @command_window.index
      when 0  # item
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to item screen
        $scene = Scene_Item.new
      when 1  # skill
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Skill.new(@actor_index)
      when 2  # equipment
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Equip.new(@actor_index)
      when 3  # save
        # If saving is forbidden
        if $game_system.save_disabled
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to save screen
        $scene = Scene_Save.new
      end
      return
    end
    # If R button was pressed
    if Input.trigger?(Input::R)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To next actor
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      # Switch to different actor
      $scene = Scene_Menu.new(@actor.index, @menu_index)
      return
    end
  end
end
I had designed each option in the command window to apply to the current actor only, so that there wouldn't a big, ugly, and unnecessary cursor flashing about.

Again, the problem I am having is that when I press the "Q" or "W" keys, it does not proceed to the next actor, but remains on the first actor. Thank you for your assistance.
 
Code:
# If R button was pressed
    if Input.trigger?(Input::R)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To next actor
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      # Switch to different actor
      [B]$scene = Scene_Menu.new(@actor.index, @menu_index)[/B]
      return
    end

You are increasing @actor_index, but aren't using it when you call your scene.

Isn't it supposed to be something like:
Code:
$scene = Scene_Menu.new(@actor_index, @menu_index)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top