O'Reilly logo

Panda3D 1.6 Game Engine by Dave Mathews

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - creating a menu system

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.

  1. Open a blank document in NotePad++ and save it as MenuClass_01.py.
  2. 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 *
    
  3. 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
    
  4. Now, we're going to create a method that initializes the menu. This may seem ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required