Game Development Reference
In-Depth Information
action button to get the option to do something, it will do nothing. Clearly, we must look elsewhere for the solution
to this problem. The window itself is created and populated in
Window_TitleCommand
. However, altering that method
will change the Title menu as well. Thus, you'll want to do the following:
1.
Copy
Window_TitleCommand
to your Materials section.
2.
Rename the copied class
Window_GameoverCommand
.
3.
Hop over to your altered
Scene_Gameover method
and switch
@command_window =
Window_TitleCommand.new
to
@command_window = Window_GameoverCommand.new
.
4.
Back at
Window_GameoverCommand
, find the
make_command_list
method (it's near the
bottom of the method).
The
make_command_list
method looks like this:
def make_command_list
add_command(Vocab::new_game, :new_game)
add_command(Vocab::continue, :continue, continue_enabled)
add_command(Vocab::shutdown, :shutdown)
end
As you can see, this method is responsible for the three options that we see in the Title menu. To make the
point, comment out (by typing in a single # before the line of code) the
new_game
command.. If you have followed my
instructions correctly, the game over menu should now look like Figure
14-4
.
Figure 14-4.
A screenshot of the game over menu after the changes
On the other hand, if you wanted to add a menu option to that list (say, for example, the ability to go back to
the Title screen), you would be best served by finding the
add_command
method, to see how it works. You could run
a search and find it that way, but look at the class definition for
Window_GameoverCommand
at the top of the script
page, and you'll see that this class is the child of
Window_Command
(this, of course, is also true in the case of
Window_
TitleCommand
). Once at
Window_Command
, you needn't look far, for the
add_command
method starts on line 61 of the
class. Look at the following to see the method in question:
#--------------------------------------------------------------------------
# * Add Command
# name : Command name
# symbol : Corresponding symbol
# enabled : Activation state flag
# ext : Arbitrary extended data
#--------------------------------------------------------------------------
def add_command(name, symbol, enabled = true, ext = nil)
@list.push({:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext})
end