Armed with that knowledge of the DirectGUI
system, we're ready to start building a Menu
class that we can use to create all of our game menus.
Open a blank document in NotePad++ and save it as
MenuClass_01.py
.Our first step is to import some things we'll need to make this menu happen. Type in this code:
from direct.gui.DirectGui import * from pandac.PandaModules import *
Now, we need to define the class and give it an
__init__
method. Add this code in next:class Menu: def __init__(self, menuGraphics, fonts, inputManager = None): self.menuGraphics = menuGraphics self.fonts = fonts self.inputManager = inputManager self.self = self
Now, we're going to create a method that initializes the menu. This may seem silly, when we already have an
__init__
method, but it will help keep the arguments we give the menu from getting even more confusing. The system will take a complicated list of arguments, but with two different methods we can separate...