Scaling aspect2d

I’m attempting to change the scale of aspect2d so that it coordinate range of 0-799,0-599. I tried using the following code from this thread:

aspect2d.setScale(1./400, 1, 1./300)
aspect2d.setPos(-1, 0, -1)

It changed the positions, but didn’t seem to have any effect whatsoever on the scale of GUI objects. Even when I change it to -1./300, which drwr said would have the “side effect of inverting all of the text”, even that did not happen.

Has something changed that renders this technique invalid?

Hi, I think I may know what’s happening.

First thing, are you setting this scale and position before the call to run()? My guess is yes. If so, try this:

Listen once for the event “aspectRatioChanged”. Upon receiving it, reset your aspect ratio and positioning. Panda does some preliminary setup based on Config.prc settings and window sizes as soon as the run() call is made. Unfortunately for you, it overrides any of the settings you made in the process. However, it will send out the “aspectRatioChanged” event as soon as it’s done with this initialization. At this point you can safely do your changes and they’ll stick.

Also, Panda will try to reset these settings anytime you resize the window. To stop this, put this in your Config.prc with whatever your aspect ratio will be:

aspect-ratio 1.333333333333

Since you’re doing something somewhat unexpected for Panda, you won’t be able to use the helper nodes underneath aspect2d without adjusting them as well. But if you’re going this far, you should probably be able to adapt their settings to fit your needs.

That was it! Thanks.