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.

[Resolved]Adding another option to the title menu.

Status
Not open for further replies.
How would I do it?

Like how would I make a button called info and when you click on it, it takes you to a place that gives you information about the game?
 

khmp

Sponsor

You'll need to script a little but its not bad. I'm not sure of your experience in RGSS so I'll explain in detail but don't think I'm trying to make fun of you OK. :)

Alright first we need to override Scene_Title's main method. Sadly we can't just alias it which is basically inserting code at the beginning or end of a method. Also we need to alter how input is handled because its based off a choice made in the command window that holds new game, load game & exit.

Code:
class Scene_Title
  #--------------------------------------------------------------------------
  # * Main Processing : !Override!
  #--------------------------------------------------------------------------
  def main
    # If battle test
    if $BTEST
      battle_test
      return
    end
    # Load database
    $data_actors        = load_data("Data/Actors.rxdata")
    $data_classes       = load_data("Data/Classes.rxdata")
    $data_skills        = load_data("Data/Skills.rxdata")
    $data_items         = load_data("Data/Items.rxdata")
    $data_weapons       = load_data("Data/Weapons.rxdata")
    $data_armors        = load_data("Data/Armors.rxdata")
    $data_enemies       = load_data("Data/Enemies.rxdata")
    $data_troops        = load_data("Data/Troops.rxdata")
    $data_states        = load_data("Data/States.rxdata")
    $data_animations    = load_data("Data/Animations.rxdata")
    $data_tilesets      = load_data("Data/Tilesets.rxdata")
    $data_common_events = load_data("Data/CommonEvents.rxdata")
    $data_system        = load_data("Data/System.rxdata")
    # Make system object
    $game_system = Game_System.new
    # Make title graphic
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.title($data_system.title_name)
    # Make command window
    s1 = 'New Game'
    s2 = 'Continue'
    s3 = 'Info'
    s4 = 'Shutdown'
    @command_window = Window_Command.new(192, [s1, s2, s3, s4])
    @command_window.back_opacity = 160
    @command_window.x = 320 - @command_window.width / 2
    @command_window.y = 288
    
    # Continue enabled determinant
    # Check if at least one save file exists
    # If enabled, make @continue_enabled true; if disabled, make it false
    @continue_enabled = false
    for i in 0..3
      if FileTest.exist?("Save#{i+1}.rxdata")
        @continue_enabled = true
      end
    end
    # If continue is enabled, move cursor to "Continue"
    # If disabled, display "Continue" text in gray
    if @continue_enabled
      @command_window.index = 1
    else
      @command_window.disable_item(1)
    end
    # Play title BGM
    $game_system.bgm_play($data_system.title_bgm)
    # Stop playing ME and BGS
    Audio.me_stop
    Audio.bgs_stop
    # 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 command window
    @command_window.dispose
    # Dispose of title graphic
    @sprite.bitmap.dispose
    @sprite.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update : !Override!
  #--------------------------------------------------------------------------
  def update
    # Update command window
    @command_window.update
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @command_window.index
      when 0  # New game
        command_new_game
      when 1  # Continue
        command_continue
      when 2  # Information
        command_information
      when 3  # Shutdown
        command_shutdown
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Command: Information
  #--------------------------------------------------------------------------
  def command_information
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    # Switch to the Information Scene
    $scene = Scene_Info.new
  end
end

And then you can make a very tiny scene which could hold a picture with the game information you want displayed. Just stick the image with the game information in the 'graphics/pictures' folder of your project. And change that name_of_picture to the... well I think its self explanatory.

Code:
class Scene_Info
  def main
    # Create the sprite and load the image
    @sp_background = Sprite.new
    @sp_background.bitmap = RPG::Cache.picture('name_of_picture')

    Graphics.transition

    loop do
      Graphics.update
      Input.update
      # Check
      break if Input.trigger?(Input::C)
    end

    # Set the scene back to the title
    $scene = Scene_Title.new

    # Freeze the graphics so we can remove resources
    Graphics.freeze
    
    # Dispose of the image and its corresponding sprite
    @sp_background.bitmap.dispose
    @sp_background.dispose
  end
end

Lastly we need install these fun little scripts. So create two openings in the script editor(F11) above main but below Scene_Debug. In the first one paste the code from the first section in it. Do the same for the second. If you have any problems don't hesitate to update.

Good luck with it boboftibia! :thumb:
 

khmp

Sponsor

In order to change the options in the title menu you're going to need to edit some scripts. But by your blank stare I'm not sure on where you are lost or how to go about helping you. What specifically is giving you a hard time about he post above?
 
Jeez, way to go Bob...Your the one I goto when I need help with my game, what will I do if you start screwing up? (*cough* Its bish *Cough*)

EDIT:And another thing!

khmp;312278 said:
Lastly we need install these fun little scripts. So create two openings in the script editor(F11) above main but below Scene_Debug. In the first one paste the code from the first section in it. Do the same for the second.

So I'm guessing the script goes below Scene_Debug but above Main. I could be wrong tho, I usually am...
 
Ok, question about that.

U kno how u hav to add ur own picture..is there a way to use the windowskin graphics to go around a bunch of text that you write down?
do u understand?

In case u don't, I mean like say the info says: "This game is about blah blah", can you write that somewhere in the script and use the windowskin graphic for the menu?
 

khmp

Sponsor

Yes we can. We would need to create a window. :) Let's start:

Code:
class Window_Information < Window_Base
  # Append text lines onto this constant to change the text displayed.
  # When adding lines to it don't forget the comma between two elements
  # and the closing bracket at the end.
  INFORMATION_TEXT = ['First line of text to be displayed',
    'Second line of text to be displayed',
    'Third line of text to be displayed',
    'Fourth line of text to be displayed']

  def initialize
    super(0,0,640,480) # <- Because we want to cover the whole screen
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end

  def refresh
    self.contents.clear
    x, y = 0, (height / 2) - (INFORMATION_TEXT.size * 32)
    for sz_text in  INFORMATION_TEXT
      self.contents.draw_text( x, y += 32, 640, 32, sz_text, 1 )
    end
  end
end

And now we need to alter the Scene_Info class to use this window.

Code:
class Scene_Info
  def main
    # Create the window holding the information
    @w_Information = Window_Information.new

    Graphics.transition

    loop do
      Graphics.update
      Input.update
      # Check
      break if Input.trigger?(Input::C)
    end

    # Set the scene back to the title
    $scene = Scene_Title.new

    # Freeze the graphics so we can remove resources
    Graphics.freeze
    
    # Dispose of the window
    @w_Information.dispose
  end
end
 
Status
Not open for further replies.

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