Been wracking my brain for a better solution to this so just going to ask here as I am always concerned my solutions are more or less hacks.
Issue
Most of my GUI components have subcomponents, example would be a target hud has an image create as a DirectFrame, three DirectWaitBars representing different character stats and then text displaying the target’s name.
I’ve used reparentTo() and parent= to no avail. When I move the frame that the subcomponents should be parented to, the subcomponents do not move.
My Current Solution
What I’ve done as a solution was to keep track of all of the “children” in a dict and then iterate through and move them according to their relative position to their “parent”. However, I was reading that in render2d or aspect2d you can use reparentTo and it will function without needing to iterate through a dict like I use.
My Question
Is this correct? Is there some undocumented method that should be in the API to make this possible in pixel2d?
Answers, thoughts and comments are always welcome.
It is supposed to work fine, reparenting should work for any kind of node. If you’re sure that it’s not an issue in your own code, could you create a small test program that clearly shows the issue?
Added a few commented out lines of code to show what I had been trying. This version doesn’t even show the image.
What I’ve tried:
reparentTo
parent =
parenting to pixel2d and then to the self.frame
setting no pos
setting no scale
setting pos relative to the parented gui object that I wanted it parented to …
I will be buggered if I know why it won’t work and the pasted code my show my complete lack of coding knowledge. So here goes …
For what it’s worth … you did answer my question and it was a problem with my code.
Started to think about this a little more and I was reparenting to a DirectFrame, not a node in pixel2d. Fairly certain that was the error and for the life of me I didn’t even think to make a node for the gui components until you mentioned it.