gsrigg
April 28, 2011, 6:49pm
1
I assumed this would give me a full screen frame:
from direct.gui.DirectGui import OnscreenImage, DirectFrame
from direct.gui.DirectGui import DGG
class MainMenu():
def __init__(self,render2d):
self.render2d = render2d
self.menuBackground = OnscreenImage(image='images/mainmenu.jpg', scale=1,
parent=self.render2d, pos=(0,0,0))
# size is left, right, BOTTOM, top
self.cPanel = DirectFrame(frameColor=(0,0.5,0.5, 1),
frameSize=(-1, 1, -1, 1),
pos=(0,0,0), relief = DGG.RAISED)
def hide(self):
self.menuBackground.hide()
self.cPanel.hide()
def show(self):
self.menuBackground.show()
self.cPanel.show()
It doesn’t, it gives me:
I thought that 2d co-ordinates worked as:
Cheers,
Gary
You must use aspect2d (where bottom left of window is (-1, -1) and up right is (1, 1)).
The second way is to scale your frame with w/h(here your bottom left is (-w/h, -1) and up right is (w/h, 1)).
gsrigg
April 28, 2011, 7:12pm
3
deflected:
You must use aspect2d (where bottom left of window is (-1, -1) and up right is (1, 1)).
The second way is to scale your frame with w/h(here your bottom left is (-w/h, -1) and up right is (w/h, 1)).
I am… by default, DirectFrame is reparented to aspect2d. And I’m working within the co-ordinates you give - -1,-1 to 1,1 …
drwr
April 28, 2011, 7:18pm
4
Actually, it’s render2d whose range is -1 … 1 over the entire screen.
aspect2d, on the other hand, is scaled so that all coordinates are square (X and Y have the same scale). Since your window is not square, that means that the range of aspect2d is -1.333 … 1.333 over X, and -1 … 1 over Y. Unless you have a wider window, of course.
David
gsrigg
April 28, 2011, 7:28pm
5
drwr:
Actually, it’s render2d whose range is -1 … 1 over the entire screen.
aspect2d, on the other hand, is scaled so that all coordinates are square (X and Y have the same scale). Since your window is not square, that means that the range of aspect2d is -1.333 … 1.333 over X, and -1 … 1 over Y. Unless you have a wider window, of course.
David
Ah, got it. Aspect2d will keep a square square while render2d will squish it.
Thanks to both,
Gary
deflected:
You must use aspect2d (where bottom left of window is (-1, -1) and up right is (1, 1)).
The second way is to scale your frame with w/h(here your bottom left is (-w/h, -1) and up right is (w/h, 1)).
I`m sleeping … Sorry gsrigg.