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 » Scripting Helpers
Home Search
 

Re: Accommodating for various screen sizes (Gui)

Previous Thread :: Next Thread 
Eternalfireeater is not online. Eternalfireeater
Joined: 01 May 2011
Total Posts: 10027
04 Oct 2013 08:51 PM
I basically have a ScreenGui with frames in them. Each frame is a page that you can view. In all of the frames I have the following script to make the Frame's size equal to the Roblox browser's size.

while wait(.1) do
script.Parent.Size = UDim2.new(1, 0, 1, 0)
end

Now I need a script that will change the position of everything in the frames to be proportional to the prior size. I threw together a little script to do that. I'm not sure why it doesn't work.

originalsize = UDim2.new(0, 806, 0, 584)
script.Parent.Changed:connect(function(property)
if property == "Size" then
c = script.Parent:GetChildren()
newsize = script.Parent.Size
for i = #c, 1, -1 do
c[i].Position = c[i].Position + (newsize - originalsize)
end
end
end)

~ℇℸℇℛηαℒℱίℛℇℇαℸℇℛ~
Report Abuse
Eternalfireeater is not online. Eternalfireeater
Joined: 01 May 2011
Total Posts: 10027
04 Oct 2013 08:53 PM
What I mean by "to be proportional to the prior size" is if you had a TextLabel that was in the center of the screen with the original size, it will adjust to be in the center of the screen with the new size.

~ℇℸℇℛηαℒℱίℛℇℇαℸℇℛ~
Report Abuse
morash is not online. morash
Joined: 22 May 2010
Total Posts: 5834
04 Oct 2013 10:15 PM
Center: UDim2.new(0.5, -(gui.Size.X.Absolute), 0.5, -(gui.size.Y.Absolute))
Report Abuse
Eternalfireeater is not online. Eternalfireeater
Joined: 01 May 2011
Total Posts: 10027
04 Oct 2013 10:27 PM
I'm not asking for the code to center everything since not everything is centered in the Gui. Some things are to the side. I need a code that will change the position of everything to make it proportional to the new size. For example: if the size increases by UDim2.new(0, 5, 0, 2) then the position of everything will increase by UDim2.new(0, 5, 0, 2).

~ℇℸℇℛηαℒℱίℛℇℇαℸℇℛ~
Report Abuse
morash is not online. morash
Joined: 22 May 2010
Total Posts: 5834
04 Oct 2013 10:37 PM
Use the relative positioning to position everything about how you want it.
Report Abuse
Eternalfireeater is not online. Eternalfireeater
Joined: 01 May 2011
Total Posts: 10027
04 Oct 2013 10:38 PM
I'm facedesking right now. I provided code that I want debugged. I'll re-post it.

originalsize = UDim2.new(0, 806, 0, 584)
script.Parent.Changed:connect(function(property)
if property == "Size" then
c = script.Parent:GetChildren()
newsize = script.Parent.Size
for i = #c, 1, -1 do
c[i].Position = c[i].Position + (newsize - originalsize)
end
end
end)

~ℇℸℇℛηαℒℱίℛℇℇαℸℇℛ~
Report Abuse
fisherman94 is not online. fisherman94
Joined: 21 Oct 2008
Total Posts: 3606
05 Oct 2013 12:39 AM
Morash was right. He's saying you can set all the Guis up to work regardless of screen size.
Set everything up to offset based on a certain percentage of the screen (normally .5). So if you want something centered, position would be .5 - size.x / 2.

This will automatically update without having to worry about scripts.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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