generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: What's the best way to center a GUI?

Previous Thread :: Next Thread 
xPyroniz is not online. xPyroniz
Joined: 08 Sep 2015
Total Posts: 68
18 Jan 2016 09:36 PM
It's kinda annoying just trying diff positions over and over.


Report Abuse
Gensoki is not online. Gensoki
Joined: 15 Feb 2014
Total Posts: 1982
18 Jan 2016 09:38 PM
For scale 1 - X / 2 don't follow order of operations
Report Abuse
xPyroniz is not online. xPyroniz
Joined: 08 Sep 2015
Total Posts: 68
18 Jan 2016 09:38 PM
The way you put that was a bit confused, so is it the X scale divided by 2, or..


Report Abuse
MakerModelLua is not online. MakerModelLua
Joined: 24 Feb 2013
Total Posts: 3544
18 Jan 2016 09:40 PM
I've developed the unique skill to subconsciously center any gui without any conscious mathematics.

Anyway, For scale 1 - X / 2 don't follow order of operations[2]
Report Abuse
Gensoki is not online. Gensoki
Joined: 15 Feb 2014
Total Posts: 1982
18 Jan 2016 09:40 PM
Well if scale is out of one you do 1-X first and then divide by 2 to center the axis
Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
18 Jan 2016 09:40 PM
http://forum.roblox.com/Forum/ShowPost.aspx?PostID=181948703
Report Abuse
xPyroniz is not online. xPyroniz
Joined: 08 Sep 2015
Total Posts: 68
18 Jan 2016 09:41 PM
Ohh, I see


Report Abuse
xPyroniz is not online. xPyroniz
Joined: 08 Sep 2015
Total Posts: 68
18 Jan 2016 09:43 PM
Can I have a example? My GUI size is

0, 400, 0, 400


Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
18 Jan 2016 09:44 PM
0.5, -200, 0.5, -200
Report Abuse
xPyroniz is not online. xPyroniz
Joined: 08 Sep 2015
Total Posts: 68
18 Jan 2016 09:49 PM
ty


Report Abuse
Gensoki is not online. Gensoki
Joined: 15 Feb 2014
Total Posts: 1982
18 Jan 2016 09:50 PM
Actually this is more ugly but ok

local abssize = script.Parent.AbsoluteSize -- ScreenGUI Absolute Size in Pixels
local abspos = script.Parent.AbsolutePosition -- ScreenGUI Absolute Position in Pixels
local absx = abssize.x -- X Value of the Vector2 Absolute Size
local absy = abssize.y -- Y Value of the Vector2 Absolute Size
local abspositionx = abspos.x -- X Value of the Vector2 Absolute Position
local abspositiony = abspos.y -- Y Value of the Vector2 Absolute Position
local x = script.Parent:WaitForChild'Frame' -- The Frame
local sizex = x.Size.X.Offset -- Frame's X Value from Offset of Size
local sizey = x.Size.Y.Offset -- Frame's Y Value from Offset of Size

function updatevalues()
abssize = script.Parent.AbsoluteSize
abspos = script.Parent.AbsolutePosition
absx = abssize.x
absy = abssize.y
abspositionx = abspos.x
abspositiony = abspos.y
x = script.Parent:WaitForChild'Frame'
sizex = x.Size.X.Offset
sizey = x.Size.Y.Offset
end

while wait() do
local newsizex = absx * 0.1 -- 10% of the screengui which covers the whole entire screen (x)
local newsizey = absy * 0.1 -- 10% of the screengui which coverse the whole entire screen (y)
local newposx = (absx - sizex) / 2 -- Takes Full Size then divides it by half to bring it to the center of screen (x)
local newposy = (absy - sizey) / 2 -- Takes Full Size then divides it by half to bring it to the center of screen (y)
script.Parent.Frame.Size = UDim2.new(0, newsizex, 0, newsizey) -- The new Size
script.Parent.Frame.Position = UDim2.new(0, newposx, 0, newposy) -- The new Position
updatevalues()
end

Lol never thought this post would be useful
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image