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.

CMS Probs with Menu Index

Hi! I am very new to rgss and rpgxp too and i was trying to create my first own cms after reading almost every tut i got. Including dubes.

Since three days i am nagging ona problem with the index method. I am able to draw and move my curosr where i want it, but cannot give him any action commands. I think its because the menu index is not defined correctly. But i cannot solve the prob myself. Help would be greatly appreciated!

here is the script for my menu so far.

PHP:
class Scene_CMS2
  
  class CMS_ICON < Window_Selectable
  
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
 def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  
  def initialize
    super(0, 80, 280, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.index = 0
    self.z = 200
    @column_max = 6
    @item_max = 6
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
   self.contents.blt(4,5,RPG::Cache.icon("034-Item03"), Rect.new(0,0,24,24))
    self.contents.blt(41,5,RPG::Cache.icon("035-Item04"), Rect.new(0,0,24,24))
    self.contents.blt(82,5,RPG::Cache.icon("036-Item05"), Rect.new(0,0,24,24))
    self.contents.blt(123,5,RPG::Cache.icon("037-Item06"), Rect.new(0,0,24,24))
    self.contents.blt(164,5,RPG::Cache.icon("038-Item07"), Rect.new(0,0,24,24))
    self.contents.blt(205,5,RPG::Cache.icon("039-Item08"), Rect.new(0,0,24,24))
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    self.cursor_rect.set(@index * 40, 0, 24, 24)
  end
end
  
  def main
       
    @cursor_index=@menu_index
       
    #Make Windows
    @cms_actors= CMS_ACTORS.new
    @cms_icon= CMS_ICON.new
    @cms_location= CMS_LOCATION.new
    @cms_gold= CMS_GOLD.new
    @cms_playtm= CMS_PLAYTM.new
    
    
    @cms_icon.active = true
    @cms_icon.visible = true
       
    # 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
    @cms_actors.dispose
    @cms_gold.dispose
    @cms_location.dispose
    @cms_playtm.dispose
    @cms_icon.dispose
   
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @cms_actors.update
    @cms_gold.update
    @cms_location.update
    @cms_playtm.update
    @cms_icon.update
   
    
   #if icon window is active: call update_icon
    if @cms_icon.active
      update_icon
       return
    end
  end
 
  def update_icon
    # 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 Input.trigger?(Input::C) 
    case @cursor_index
      when 0 
        item 
      when 1
        save 
      when 2
        status 
      when 3
        skill
      when 4
        exit 
      end  
    end
  
  end
  
    def item 
    $game_system.se_play($data_system.decision_se) #play an SE
    $scene = Scene_Item.new #Syntax to change scene
    end  

    def save 
    $scene = Scene_Save.new
    end  

    def status
    $scene = Scene_Status.new
    end 

    def skill
    $scene = Scene_Skill.new
    end 

    def exit 
    $game_system.se_play($data_system.cancel_se) #play an SE
    $scene = Scene_Map.new #Syntax to change scene
    $game_map.autoplay #Because we play music in the menu...
  
end
end
 
First, make Window class for your menu. Then, make a Scene class for your menu. I mean,

Code:
class CMS_ICON > Window_Selectable
  def initialize
  .....
  end
  (and other window related methods follow)
end #class end

class Scene_CMS2
  def initialize(menu_index = 0) 
    @menu_index = menu_index 
  end
  def main
    .......
  end
  (any menu scene related methods follow)
end #class end

like this.
 

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