In a 2D top-down game, sometimes a southern door is close to the bottom of the screen. When the ‘Open Door’ options dialogue appears (in a Billboard GUI), it is sometimes half off screen. I’ve been trying to correct it, but, the numbers don’t add up.
The billboard is at the bottom, and is missing its ‘description’ textbox; if there were multiple unlock options, then, they also go off-screen. The total thing varies in size according to the options. It’s not always at the bottom, so, I can’t implement a generic top adjustment of -50 etc (else it starts appearing over the middle the map in many rooms).
I have some test code to print the Y-values of the Billboard and screen size, using some ideas seen on this forum.
Local Script, a direct child of the BB:
-- Now it is displayed, check to see if it going off-screen (for now, just checking top-or-bottom)
-- bb is the BillboardGUI, created just beforehand, parented & with some sizing tweaks.
print(bb.AbsolutePosition.Y.."+"..bb.AbsoluteSize.Y.."+10="..(bb.AbsolutePosition.Y + bb.AbsoluteSize.Y + 10),"is it >",workspace.CurrentCamera.ViewportSize.Y)
if (bb.AbsolutePosition.Y + bb.AbsoluteSize.Y + 10) > workspace.CurrentCamera.ViewportSize.Y then
bb.SizeOffset.Y = workspace.CurrentCamera.ViewportSize.Y - bb.AbsolutePosition.Y - bb.AbsoluteSize.Y - 10
end
This prints:
0+60+10=70 is it > 470
If the total of those numbers is > 470, then, it is off-screen. It IS off-screen, but the numbers don’t reflect that, and so it never fires the correction script.
Why does bb.AbsolutePosition.Y say ‘0’? Selecting the BB in the studio tree shows its boundaries; it definitely starts along its top border as you’d expect, so definitely has a HIGH absolute-Y; it must be around 410.