Ive got some problems regarding my Menu.
(local and global variables, too - but in context to the menu)
I want to make a Menu where you can either (Directbutton) press Start - Options - Credits (f.ex.) and then it should clear all buttons and the program will run in the subprogram
f.ex: def menu(): #style of menu with onscreentext and directbuttons and stuff
(button)…,command=Sound)
(sub-program) def Sound(): #style of Sound menu but without the menu´s onscreentext and directbuttons, options to change the sound
(button back to menu)…,command=menu)
so basically what im saying is:
Is there a function that deletes all objects or something?
Hey EraseIt! That was really helpful! Thanks a lot!
I am ready with my menu so far. The only problem, I have is: how do I programm a button “Back” from the optionsMenu? I tried just to copy “command=parent.gotoMain” from the same button in the ingameMenu, but it doesn’t work. In the command line I get a message:
“(all display modules loaded.)
Traceback (most recent call last):
File “main.py”, line 18, in
w = World()
File “main.py”, line 9, in init
self.gui = UserInterface()
File “local directory\panda3dmenu\trunk\data\UserInterface.py”, line 28, in init
File “local directory\panda3dmenu\trunk\data\gui\OptionsMenu.py”, line 36, in init
command=parent.gotoMain
NameError: global name ‘parent’ is not defined”
I really tried what I could. So, I would be very grateful for your (or someone else’s) help.
The main idea is to create multiple frames and switch between them.
To follow your exemple : “Options” -“Credits” will be parented to a frame called Father. Clicking on “Options” should hide Father and show your second frame, let’s say called, ChildOne with all your options and a Back Button.
Clicking on Back will hide frame ChildOne and show Father frame.
An other one is to use FSM which will do more or less what explained above but in a more robust way.
Reading this article will explain it better than I : http://games.odaclick.com/tag/panda3d/
Yes! The menu works fine now. Thanks to all for your explanations and examples. Now I know what the idea behind this all is. Used EraseIt’s example, which is more than sufficient. Just need to optimize it a bit, because I won’t make a multiplayer or save/load functions. If I’ll have any other questions, I’ll ask here.