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.

Scroll when index >= 3

Tdata

Sponsor

My problem is that i've had to constrict my Window_MenuStatus to show only 3 places. I have a max of 6 characters in the party at one time. i need to know how to make it "scroll" to the next one when @menu_index >= 3. Would someone please help me?
 
The way that Window_Selectable was built allows for scrolling windows. Just make sure the contents size is larger than the window's dimensions in the axis that you want it to scroll.
 

Tdata

Sponsor

I tried this:
Code:
def update_status
if @status_window.index >= 3
@status_window.oy = 120 * ((@status_window.index - 3) + 1)
else
@status_window.oy = 0
end
It scrolls, but there is nothing under the third character. Just a blank spot.
 

Tdata

Sponsor

Code:
class Menu_Drop
  
  
  #---
  # Begin Initialization
  #---
  
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  
  #---
  # End Initialization
  #---
  
  #---
  # Begin Main
  #---
  
  def main
  @sprite = Spriteset_Map.new
  #---
  # Begin Constants
  #---
    
  main_menu = ["Player", "Item", "File"]
  player_menu = ["Status", "Equip", "Skills"]
  item_menu = ["Loot", "Usable", "Key"]
  file_menu = ["Save", "Load", "Quit"]
  
  #---
  # End Constants
  #---
  
  #---
  # Begin Menus
  #---
  
  @main_menu = Window_ShopCommand_clone.new
  @main_menu.active = true
  @main_menu.visible = true
  @main_menu.index = @menu_index
  
  @player_menu = Window_Command.new(120, player_menu)
  @player_menu.x = 20
  @player_menu.y = 65
  @player_menu.index = @menu_index
  @player_menu.active = false
  @player_menu.visible = false
  
  @status_window = Window_MenuStatus.new
  @status_window.index = @menu_index
  @status_window.x = (20 + 120)
  @status_window.y = 65
  @status_window.active = false
  @status_window.visible = false
  
  #---
  # End Menus
  #---
  
   Graphics.transition
   loop do
     Graphics.update
     Input.update
     update
     if $scene != self
       break
     end
   end
   Graphics.freeze

   @main_menu.dispose
   @player_menu.dispose
   @sprite.dispose
   @status_window.dispose

 end
 def update
   @main_menu.update
   @player_menu.update
   @sprite.update
   @status_window.update
   if @main_menu.active == true
     main_menu_update
   elsif @player_menu.active == true
     player_menu_update
   elsif @status_window.active == true
     update_status
     end
 end
 def main_menu_update
    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 Input.trigger?(Input::A)
      case @main_menu.index
      when 0
      $game_system.se_play($data_system.decision_se)
      @main_menu.active = false
      @player_menu.active = true
      @player_menu.visible = true
      return
      when 1
        return
      when 2
        return
      end
    end
 end     
 def player_menu_update
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      @player_menu.active = false
      @player_menu.visible = false
      @main_menu.active = true
      @main_menu.index = 0
      return
    end
    if Input.trigger?(Input::A)
      $game_system.se_play($data_system.decision_se)
      case @player_menu.index
      when 0
        @status_window.visible = true
        @status_window.active = true
        @player_menu.active = false
        return
      when 1
        return
      when 2
        return
      end
    end
  end
    def update_status
      if @status_window.index >= 3
        @status_window.oy = 120 *((@status_window.index - 3) + 1)
        @status_window.refresh
      else
        @status_window.oy = 0
        @status_window.refresh
      end
      
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Make command window active
      @player_menu.active = true
      @status_window.active = false
      @status_window.visible = false
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::A)
      # Branch by command window cursor position
      case @player_menu.index
      when 0  # status
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to status screen
        $scene = Scene_Status.new(@status_window.index)
      when 1  # equipment
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to equipment screen
        $scene = Scene_Equip.new(@status_window.index)
      when 2  # skill
        # If this actor's action limit is 2 or more
        if $game_party.actors[@status_window.index].restriction >= 2
          # 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 skill screen
        $scene = Scene_Skill.new(@status_window.index)
      end
      
    end
  end
end
class Window_ShopCommand_clone < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(20, 0, 600, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    @item_max = 4
    @column_max = 4
    @commands = ["Player", "Item", "File", "Exit"]
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    x = 4 + index * 160
    self.contents.draw_text(x, 0, 128, 32, @commands[index])
  end
end

class Window_MenuStatus < Window_Selectable
  
  def initialize
    super(0, 0, 480, 360)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
    self.active = false
    self.index = -1
  end

end
 

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