Time for action – creating the menu bar
Double-click on the
MapEditor.vb
file in Solution Explorer to open theMapEditor
form in the design window.Click on the empty
MenuStrip
that you previously added to the form, and add menu entries for the following items (including the&
symbols, which will create keyboard shortcuts for the menu entries):&File
&Load Map
&Save Map
–
: A single dash, creating a separator lineE&xit
&Tools
&Clear Map
&Layer
&Background
&Interactive
&Foreground
Double-click on the Exit item under the File menu to have Visual Studio automatically generate an event handler for the Exit menu item.
Enter the following code into the
ExitToolStripMenuItem_Click()
event handler:game.Exit() Application.Exit()
What just happened?
We now have a standard Windows menu attached to our form with a few entries for our level editor. In order to add code to menu items other than the Exit command, we need to make modifications to our Game1
class, so we will come...