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 task and adding it to the task manager

  1. To create the method we'll add to the task manager we need to add a few more lines to the World class in our program. Create a blank line at the end of the __init__ method with only one tab at the start of it. Then add this code block there:
    def cycleMove(self, task):
    self.cycle1.setY(self.cycle1, .1)
    return task.cont
    
  2. This won't do the job on its own, though. We need to add our new method to the task manager. Add a new line right above print(taskMgr):
    taskMgr.add(self.cycleMove, "Cycle Move")
    
  3. Our code should look like this now:
    class World: def __init__(self): base.setBackgroundColor(0, 0, 0) self.track = loader.loadModel("../Models/Track.egg") self.track.reparentTo(render) self.track.setPos(0,0,-5) ...

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