Designing the Main Menu

During the end of the last chapter, you wrote the base class for the UI screens you will be creating in this chapter. The first user screen to create is the main menu. Everything in your game spawns from this screen.

Add a new code file to your project called UiScreens.cs, and add the code in Listing 6.1 to the file.

Listing 6.1. The MainUiScreen Class
 /// <summary> /// The main selection screen for the game /// </summary> public class MainUiScreen : UiScreen, IDisposable { private Texture buttonTextures = null; private Texture messageTexture = null; private UiButton newButton = null; private UiButton exitButton = null; // Events public event EventHandler NewGame; public event EventHandler Quit; #region IDisposable Members ...

Get Beginning 3D Game Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.