Ending game and returning to main menu - States?

Hi,
I’m making a race game, and my questions are:
How do I return my main menu when my the race is over?
Is there a simple way to destroy the “game”-object, so I can make a new one and start the game again.

Please help me!

-Ole

Sounds like you’re asking a general programming question, not specifically related to Panda.

I really have no idea how to answer your question, since I know nothing about how you’ve set up your program, what your main menu is, and what you mean by the “game” object.

In general, you can stop things from being rendered by removing them from the scene graph. Generally you do this by calling nodePath.removeNode() on the top node. For a 2-d DirectGUI widget, you must generally call destroy() on the toplevel frame (which removes the NodePath and also cleans up hooks).

You don’t have to explicitly destroy objects in Python; you can just stop using them and they get automatically deallocated when the last reference is gone. You probably want to add some method to your “game” object to undo everything it did when you created it, though, for instance by removing all of your NodePaths.

Good luck sorting out your cleanup code.

David