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 - collecting garbage from the Track class

Let's test the destroy method we've built up for the Track class so far.

  1. Open TrackClass_00.py.
  2. Type in our __del__ method to the bottom of the class:
    def __del__(self):
    print("Track Removed")
    
  3. Resave the file with the same name and run the game. Test the clean up by clicking the New Game button and checking the command prompt.
  4. As shown in the following screenshot, this time our garbage collection is working fine. Remove the __del__ method from the Track class and resave the file again.
Time for action - collecting garbage from the Track class

What just happened?

That does it for our garbage collection! This is one of the most important things to get ...

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