Sliding Menu I'm not good with names no... Version:1.0 Author:Stripe103 Date:June 1, 2010
Version History
Version 1.0 (Sep 23, 2009) Initial Release
Description
Here comes another menu that I've made, but this is looking better. Instead of having everything in a static page this script slides the windows in. It is easier to test so download the demo.
Features
Sliding windows Background continues if you want Background fades to desired color
Screenshots
Instructions
Just put above main and below the default script and you are ready to go! Oh and the configuration is in the top of the script.
Script
Script
CODE
#============================================================================== # * Scene_Menu # By: Stripe103 # Ver: 1.0 #------------------------------------------------------------------------------ # CONFIGURATION #============================================================================== # # FADE TO COLOR # When you are going into the menu the screen fades to this color. RED = -100 GREEN = -100 BLUE = -100 GREY = 150 # # Choose if you want the game to pause when in the menu. PAUSEMENU = false # #==============================================================================
# TERMS OF USAGE # #------------------------------------------------------------------------------------------------------------------ # # You are free to adapt this work to suit your needs. # # You can use this work both for commercial and non-commercial work. # # Credit is appreciated. # #------------------------------------------------------------------------------------------------------------------
#=========================================================== # INTRODUCTION # # Adds moving capabilities to your sprites and windows. Only useful to scripters. # Cross-engine (Works for XP and VX). # Easy to use and no ZeroDivision error. # Four methods to know: # # x_slide(new_x, incrementation) <-- Horizontal sliding # y_slide(new_y, incrementation) <-- Vertical sliding # bi_slide(new_x, new_y, x_incrementation, y_incrementation) <-- Dual sliding # is_sliding? <-- Query to check if sliding. #===========================================================
#=========================================================== # ** GFX_Slider #------------------------------------------------------------------------------ # This is mixed into windows and sprites to make them slide. #===========================================================
module GFX_Slider #-------------------------------------------------------------------------- # * Perform horizontal slide #-------------------------------------------------------------------------- def x_slide(x_dest, inc) @x_destination = x_dest @x_increment= inc end #-------------------------------------------------------------------------- # * Perform vertical slide #-------------------------------------------------------------------------- def y_slide(y_dest, inc) @y_destination = y_dest @y_increment = inc end #-------------------------------------------------------------------------- # * Perform both #-------------------------------------------------------------------------- def bi_slide(x_dest, y_dest, x_inc, y_inc) x_slide(x_dest, x_inc) y_slide(y_dest, y_inc) end #-------------------------------------------------------------------------- # * Update horizontal motion #-------------------------------------------------------------------------- def update_x_slide return if @x_destination == nil if @x_destination > self.x self.x = [self.x + @x_increment, @x_destination].min else self.x = [self.x - @x_increment, @x_destination].max end @x_destination = nil if @x_destination == self.x end #-------------------------------------------------------------------------- # * Update vertical motion #-------------------------------------------------------------------------- def update_y_slide return if @y_destination == nil if @y_destination > self.y self.y = [self.y + @y_increment, @y_destination].min else self.y = [self.y - @y_increment, @y_destination].max end @y_destination = nil if @y_destination == self.y end #-------------------------------------------------------------------------- # * Checks if sliding #-------------------------------------------------------------------------- def is_sliding? return (@x_destination != nil || @y_destination != nil) end #-------------------------------------------------------------------------- end
class Window_Base < Window include GFX_Slider #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- unless method_defined?(:kread_slide_window_init) alias_method :kread_slide_window_init, :initialize end def initialize(x, y, width, height) kread_slide_window_init(x, y, width, height) # Original call # When these two variables are different than the coordinates, the window moves. @x_destination = nil @y_destination = nil # Coordinates incrementation. @x_increment = 0 @y_increment = 0 end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- unless method_defined?(:kread_slide_window_update) alias_method :kread_slide_window_update, :update end def update kread_slide_window_update # Original call update_x_slide update_y_slide return if self.is_sliding? end #-------------------------------------------------------------------------- end
class Sprite include GFX_Slider #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- unless method_defined?(:kread_slide_sprite_init) alias_method :kread_slide_sprite_init, :initialize end def initialize(viewport = nil) kread_slide_sprite_init(viewport) # Original call # When these two variables are different than the coordinates, the window moves. @x_destination = nil @y_destination = nil # Coordinates incrementation. @x_increment = 0 @y_increment = 0 end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- unless method_defined?(:kread_slide_sprite_update) alias_method :kread_slide_sprite_update, :update end def update kread_slide_sprite_update # Original call update_x_slide update_y_slide return if self.is_sliding? end #-------------------------------------------------------------------------- end
#============================================================================== # ** Scene_Menu #------------------------------------------------------------------------------ # This class performs menu screen processing. #============================================================================== class Scene_Menu #-------------------------------------------------------------------------- # * Object Initialization # menu_index : command cursor's initial position #-------------------------------------------------------------------------- def initialize(menu_index = 0) @menu_index = menu_index @end_index = -1 end #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main # Make command window s1 = $data_system.words.item s2 = $data_system.words.skill s3 = $data_system.words.equip s4 = "Status" s5 = "Save" s6 = "End Game" @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6]) @command_window.x = 240 @command_window.y = 130 @command_window.opacity = 0 @command_window.index = @menu_index # 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 end window e1 = "To Title" e2 = "Shutdown" e3 = "Cancel" @end_window = Window_Command.new(160, [e1, e2, e3]) @end_window.x = 240 @end_window.y = 480 @end_window.opacity = 0 @end_window.index = @end_index # Make play time window @playtime_window = Window_PlayTime.new @playtime_window.x = 0 @playtime_window.y = 0 @playtime_window.opacity = 0 # Make steps window @steps_window = Window_Steps.new @steps_window.x = 0 @steps_window.y = 394 @steps_window.opacity = 0 # Make gold window @gold_window = Window_Gold.new @gold_window.x = 480 @gold_window.y = 0 @gold_window.opacity = 0 # Make status window @status_window = Window_MenuStatus.new @status_window.x = 640 @status_window.y = 0 @status_window.opacity = 0 # Make map background @spriteset = Spriteset_Map.new # Darken the screen @view = Viewport.new(0, 0, 640, 480) @view.tone = Tone.new(RED, GREEN, BLUE, GREY) # 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 @end_window.dispose @playtime_window.dispose @steps_window.dispose @gold_window.dispose @status_window.dispose @spriteset.dispose end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update # Update map background if the user wants it if PAUSEMENU != true @spriteset.update $game_map.update $game_system.map_interpreter.update $game_system.update $game_screen.update end # Update windows @command_window.update @end_window.update @playtime_window.update @steps_window.update @gold_window.update @status_window.update # If command window is active: call update_command if @command_window.active update_command return end # If status window is active: call update_status if @status_window.active update_status return end # If end window is active: call update_end if @end_window.active update_end 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) # If command other than save or end game, and party members = 0 if $game_party.actors.size == 0 and @command_window.index < 4 # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # 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) # Slide the window @command_window.x_slide(-240, 20) @playtime_window.x_slide(-460, 20) @steps_window.x_slide(-460, 20) @gold_window.x_slide(0, 20) @status_window.x_slide(160, 20) # Make status window active @command_window.active = false @status_window.active = true @status_window.index = 0 when 2 # equipment # Play decision SE $game_system.se_play($data_system.decision_se) # Slide the window @command_window.x_slide(-240, 20) @playtime_window.x_slide(-460, 20) @steps_window.x_slide(-460, 20) @gold_window.x_slide(0, 20) @status_window.x_slide(160, 20) # Make status window active @command_window.active = false @status_window.active = true @status_window.index = 0 when 3 # status # Play decision SE $game_system.se_play($data_system.decision_se) # Slide the window @command_window.x_slide(-240, 20) @playtime_window.x_slide(-460, 20) @steps_window.x_slide(-460, 20) @gold_window.x_slide(0, 20) @status_window.x_slide(160, 20) # Make status window active @command_window.active = false @status_window.active = true @status_window.index = 0 when 4 # 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 when 5 # end game # Play decision SE $game_system.se_play($data_system.decision_se) # Slide window @command_window.y_slide(-30, 20) @playtime_window.y_slide(-160, 20) @steps_window.y_slide(234, 20) @gold_window.y_slide(-160, 20) @end_window.y_slide(320, 20) # Make end window active @command_window.active = false @end_window.active = true @end_window.index = 0 end return end end #-------------------------------------------------------------------------- # * Frame Update (when status window is active) #-------------------------------------------------------------------------- def update_status # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Slide the window @command_window.x_slide(240, 20) @playtime_window.x_slide(0, 20) @steps_window.x_slide(0, 20) @gold_window.x_slide(480, 20) @status_window.x_slide(640, 20) # Make command window active @command_window.active = true @status_window.active = false @status_window.index = -1 return end # If C button was pressed if Input.trigger?(Input::C) # Branch by command window cursor position case @command_window.index when 1 # 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) when 2 # equipment # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to equipment screen $scene = Scene_Equip.new(@status_window.index) when 3 # status # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to status screen $scene = Scene_Status.new(@status_window.index) end return end end #-------------------------------------------------------------------------- # * Frame Update (when end window is active) #-------------------------------------------------------------------------- def update_end # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Slide the window @command_window.y_slide(130, 20) @playtime_window.y_slide(0, 20) @steps_window.y_slide(396, 20) @gold_window.y_slide(0, 20) @status_window.y_slide(0, 20) @end_window.y_slide(480, 20) # Make command window active @command_window.active = true @end_window.active = false @end_window.index = -1 return end
# If C button was pressed if Input.trigger?(Input::C) # Branch by command window cursor position case @end_window.index when 0 # to title command_to_title when 1 # shutdown command_shutdown when 2 # quit command_cancel end return end end #-------------------------------------------------------------------------- # * Process When Choosing [To Title] Command #-------------------------------------------------------------------------- def command_to_title # Play decision SE $game_system.se_play($data_system.decision_se) # Fade out BGM, BGS, and ME Audio.bgm_fade(800) Audio.bgs_fade(800) Audio.me_fade(800) # Switch to title screen $scene = Scene_Title.new end #-------------------------------------------------------------------------- # * Process When Choosing [Shutdown] Command #-------------------------------------------------------------------------- def command_shutdown # Play decision SE $game_system.se_play($data_system.decision_se) # Fade out BGM, BGS, and ME Audio.bgm_fade(800) Audio.bgs_fade(800) Audio.me_fade(800) # Shutdown $scene = nil end #-------------------------------------------------------------------------- # * Process When Choosing [Cancel] Command #-------------------------------------------------------------------------- def command_cancel # Play cancel SE $game_system.se_play($data_system.decision_se) # Slide the window @command_window.y_slide(130, 20) @playtime_window.y_slide(0, 20) @steps_window.y_slide(396, 20) @gold_window.y_slide(0, 20) @status_window.y_slide(0, 20) @end_window.y_slide(480, 20) # Make command window active @command_window.active = true @end_window.active = false @end_window.index = -1 end end
Credit
Stripe103 for the menu itself.
Kread-EX for making his "Graphics Slider".
Support
If you have any questions, post in this thread or PM me as always.