This simple recipe will show you how to quickly put some text on the screen. This might be useful for debug output, but also for presenting the current score or hit points to the player.
If you haven't done it yet, set up your project according to the steps presented in the recipe Setting up the game structure before you proceed. You can find this recipe in Chapter 1, Setting Up Panda3D and Configuring Development Tools.
Let's put some text on the screen:
Open
Application.py
and add the following source code:from direct.showbase.ShowBase import ShowBase from direct.gui.OnscreenText import OnscreenText from panda3d.core import * class Application(ShowBase): def __init__(self): ShowBase.__init__(self) font = loader.loadFont("cmr12.egg") props = TextProperties() props.setTextColor(1, 1, 0, 0.5) tp = TextPropertiesManager.getGlobalPtr() tp.setProperties("yellow", props) OnscreenText...