Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Centering a Dynamically Scaling GUI?

Asked by
Foboh 5
9 years ago

I know that to center a GUI you would need to divide its pixel size in half.

So Size {0, 500} {0, 500} would need Position {0.5, -250} {0.5, -250}

But with Roblox going on mobile devices I would much rather use a screen percentage (the first number) to size and position my stuff. But then **how would I center the GUI if the size changes based on the screen resolution? **

Size: {0.5, 0} {0.25, 0} Position: {?, ?} {?, ?}

Do I need a script for this?

2 answers

Log in to vote
0
Answered by
dyler3 1510 Moderation Voter
9 years ago

Quite simple actually. Just set the position to .5 - Half of size. Try this for position:

{.25,0}{.375,0}

If you have any quesitons, please leave a comment below. Hope I helped :P

Ad
Log in to vote
0
Answered by 9 years ago

If the gui size is being resized by the Scale, then there are 2 methods of positioning the Gui.

Method 1

Divide the scale by two to get the position property, like so:

Size: {0.5, 0}, {0.25, 0}

Position: {0.25, 0}, {0.125, 0}

Method 2

Use the traditional gui centering method by dividing and negating the AbsoluteSize property of the Gui itself, like so:

Size: {0.5, 0}, {0.25, 0}

Position: {0.5, -Gui.AbsoluteSize.X / 2}, {0.5, -Gui.AbsoluteSize.Y / 2}

Hope this helped!

0
The Y Offset on the first is incorrect. It should be .5-.125, which is .375 . Just letting you know :P dyler3 1510 — 9y

Answer this question