Putting the menu onscreen in front of the image [SOLVED]

Hi.

feeling like a total noob here, but ive got this card generated with a movietexture on it (this works fine). ive also got a menu (2 buttons parented to a top node).

the card is parented to pixel2d and the menu to aspect2d.

somehow i cant get the menu to be displayed in front of the card. the button just disappears…

could it be that pixel2d is ALWAYS rendered on top of aspect2d, or is there something else wrong here?

so far, i can only see the menu when i call card.hide()

any suggestions anyone?

furthermore, the button doesn’t do anything:

ive got a button like this:

class menu(ShowBase:
    def __init__(self):
        self.button = DirectButton(text = ("OK", "click!", "rolling over", "disabled"), scale=0.05, command=self.end())
    def end(self):
        sys.exit

but clicking the button doesnt exit the program…

do i need a “buttonlistener”? (like in java…)

I’m not sure of the answer to your render-order issue. You might try assigning the objects to the “fixed” bin and giving them appropriate indices, or perhaps creating a new bin for the GUI elements, or you might try assigning a depth offset to one or more of the items; there may be better ways, however, and I’m not sure that the above will work.

On the issue of the button not working, however, I believe that the problem there is simply that you’re passing in the result of the “end” function, not the function itself.

To be specific, try “command=self.end” (note the lack of brackets).

Finally, you seem to have omitted the brackets in the “sys.exit()” call.

hey, the same guy :wink:
thank you for helping me on this one too.
i fixed the button (stupid brackets) without brackets the sys.exit works fine in

self.accept("escape", sys.exit)

so it is confusing.

i dont know what you mean by the other stuff you wrote though, a ‘fixed’ bin? whats that? you know the card is on pixel2d, was your idea, and aspect2d doesnt fit like it should, so maybe i could parent the menu to pixel2d? ill see what happens

okay, tried parenting menu to pixel2d, but the butons disappeared… :confused:

oh, and the depth offset thing doesnt work.
i tried card -5 and menu 5,
card 5 and menu -5
card 500 and menu -5
etc. etc.

so, now i tried an onscreenimage parented to the same node as the buttons, and still the buttons disappear

orright!!!

i checked the manual, and guess what:

i found your bins!

problem solved, thanks for the tip.

I’m glad that you got it working. :slight_smile:

On the matter of the functions with- and without- brackets, let me explain a bit further - it’s a feature that can be quite useful, I think, and one that you’ll likely encounter again. (I’ll use “function” here for both functions and methods; the principle should be much the same.)

As I understand it:
When a function name is used without brackets, this produces a reference to the function, rather than calling it. So, in a button, “command=myFunction” assigns to “command” a reference to the function “myFunction”. Similarly, “self.accept(‘escape’, sys.exit)” passes in a reference to the function “sys.exit”, allowing it to be called later.

When a function name is used with brackets, the function is called and, if on the right-hand side of an assignment, the result of that function-call is assigned to whatever is on the left.

For example:

def myFunction():
    print "Kittens!"
    return 1

myFunction() # Prints "Kittens!"
var = myFunction() # Prints "Kittens!" and sets the value of "var" to 1

var2 = myFunction # Sets the value of "var2" to refer to my function; nothing should be printed.
var3 = var2() # Prints "Kittens!" and sets the value of var3 to 1

okay, thank you for this clarification.
quite a useful feature indeed, if handled properly.