Home > RGSS Script Reference > Scene_End
Scene_End
Inherits from: None
Description: This class handles the menu that appears when you select the "End Game" option from the main menu.
class Scene_End
# ------------------------------------
def main
s1 = "Go to Title"
s2 = "Shutdown"
s3 = "Cancel"
@command_window = Window_Command.new(192, [s1, s2, s3])
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 240 - @command_window.height / 2
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@command_window.dispose
if $scene.is_a?(Scene_Title)
Graphics.transition
Graphics.freeze
end
end
# ------------------------------------
def update
@command_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(5)
return
end
if Input.trigger?(Input::C)
case @command_window.index
when 0
command_to_title
when 1
command_shutdown
when 2
command_cancel
end
return
end
end
# ------------------------------------
def command_to_title
$game_system.se_play($data_system.decision_se)
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
$scene = Scene_Title.new
end
# ------------------------------------
def command_shutdown
$game_system.se_play($data_system.decision_se)
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
$scene = nil
end
# ------------------------------------
def command_cancel
$game_system.se_play($data_system.decision_se)
$scene = Scene_Menu.new(5)
end
end
|
Command_Window: A Window_Command object representing the End Game menu.
Main
Arguments: None
Local Variables: None
How it Works: This is the main method that initializes the object, processes the update, and disposes of the object. The first part of the method sets the text of the command window and sets its position. The main loop updates the graphics, checks for input, and updates the window in response to user input. Once the value of $Scene has changed (because the user has selected a command), the final part of the method disposes of the window If the new scene is the title screen, the graphics transition and freeze.
Update
Arguments: None
Local Variables: None
How it Works: This method makes the menu respond to user input. If the current input is "B" (cancel), then the cancel sound effect is played and the value of $Scene is changed to the menu screen. If the current input is "C" (decision), then the value of @command_window.index is checked to see where the cursor highlight is on the menu. If the index is 0 (Go to Title Screen), then the Command_to_Title method is called. If the index is 1 (Shutdown), then Command_Shutdown is called. If the index is 2 (Cancel), then Command_Cancel is called.
Command_to_Title
Arguments: None
Local Variables: None
How it Works: This method returns the player to the title screen. The decision sound effect is played, and the BGM, BGS, and ME are faded out with a fade duration of 800 ms. The $Scene is then changed to the title screen.
Command_Shutdown
Arguments: None
Local Variables: None
How it Works: This method returns the player to the title screen. The decision sound effect is played, and the BGM, BGS, and ME are faded out with a fade duration of 800 ms. The $Scene is then changed to nil, when causes Game.exe to exit.
Command_Cancel
Arguments: None
Local Variables: None
How it Works: This method cancels the menu and returns the user to the main menu. The decision sound effect is played, and $Scene is changed back to the main menu.
|
|