[Solved] Beginner's questions about GUI and Aspect2D

Greetings !

I’m all new to this game engine (and even new to every 3d thingy, for that matter), and I’m working on an easy game to get introduced. :smiley:

Up until now I’ve been doing pretty good on my own, but now I’m working with PGButton and I’m wondering a few things.

Like, initially, everything that you put under the aspect2d node will get rendered in a position relative to the camera.
What if I don’t want that ? And especially, what if I want the node to be initially placed relatively to the camera, but to stay where it is if the camera moves ?

And second question is about PGButton.
I have no problem creating buttons, but I do have some issues getting rid of them.
If I store a pointer to PGButton, when I try to delete it, the whole thing crash (claming that a virtual pure method has been called…).

Right now I get rid of the menu by removing the NodePath. But I don’t think the PGButton is cleaned afterwards, is it ?
And if not, I need to delete it myself… what’s the procedure to do that ? I noticed that I can’t start using “delete” on the button pointer as soon as I used setup or set_frame.

I can only delete the PGButton before I create attach its node to aspect2d.
If I try deleting it right after that, I got this :

Assertion failed: _ref_count == 0 || _ref_count == local_ref_count at line 129 of built/include/referenceCount.I
game: built/include/mutexPosixImpl.I:129: void ReMutexPosixImpl::acquire(): Assertion `result == 0' failed

And if I try to do it later, I got this whole “virtual pure method called” thingy.

I thank thee for helpin !
Good day !

If you’re using Panda’s reference counting system, you’re not allowed to delete objects yourself. Just let them go out of scope. Be sure to wrap reference counted object in a PT() instead of an ordinary pointer.

1 Like

Thank you !
It’s neat to finally know what PT is actually for ! I added it and indeed there are no leaks at all in my game.

I also found several way to work around the static/not static UI problem. So I’m going to mark this thread as solved.