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 - using doMethodLater

  1. Change the line where we add our task to taskMgr so it matches the following:
    taskMgr.doMethodLater(5, self.cycleMove, "Cycle Move")
    
  2. Save this as chp03_04.py and run it. Wait 5 seconds for the task to startup. All of the output stays the same, but now there is a 5 second delay before the task beings.
  3. Let's create a new task to really see this in action. Add a new method to the World class with this code:
    def debugTask(self, task):
    print(taskMgr)
    return task.cont
    
  4. We don't need to print the taskMgr in two places, so remove the print(taskMgr) line from the cycleMove method. Also, we need to add the new task to the taskMgr. Add the following line below the taskMgr.doMethodLater method call:
    taskMgr.add(self.debugTask, ...

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