|
| 07 Aug 2016 10:34 AM |
| Yes, this does have to do with scripting. I'm making a GUI, and at the bottom I have 3 image buttons. I want them each to take up 1/3 the width of the screen. Is there any way to find the size, or do I just have to experiment? |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 07 Aug 2016 10:36 AM |
local player = game.Players.LocalPlayer local mouse = player:GetMouse()
local ScreenSizeX = mouse.ViewsizeX local ScreenSizeY = mouse.ViewSizeY
|
|
|
| Report Abuse |
|
|
|
| 07 Aug 2016 11:01 AM |
Same thing he said above local player = game.Players.LocalPlayer local mouse = player:GetMouse()
local ScreenSizeX = mouse.ViewsizeX local ScreenSizeY = mouse.ViewSizeY
|
|
|
| Report Abuse |
|
|
|
| 07 Aug 2016 11:24 AM |
| Don't even bother finding the size, just use scale instead of transform when creating the frame. |
|
|
| Report Abuse |
|
|
|
| 07 Aug 2016 11:29 AM |
| To clarify, set the first frame's position to {{0,0},{0,0}} the second to {{0.33,0},{0,0}} and the third to {{0.66,0},{0,0}} This is not exactly a third but i think it should be close enough for you. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 07 Aug 2016 11:31 AM |
that sketchy. You need exact values
gui.Position = UDim2.new(0,ScreenSizeX/3,0,ScreenSizeY/3)
|
|
|
| Report Abuse |
|
|
| |
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 07 Aug 2016 11:40 AM |
| It's inaccurate and bad practice. |
|
|
| Report Abuse |
|
|
|
| 07 Aug 2016 11:44 AM |
| Please forgive me for being inaccurate, I didn't expect 0.00333333333... to be such a huge deal when creating a gui |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 07 Aug 2016 11:44 AM |
When we are talking about quality of a game, you can't just half ass it.
|
|
|
| Report Abuse |
|
|
|
| 07 Aug 2016 11:46 AM |
| I'm actually as confused as him, what's wrong with scale if you want a 1/3rd of the screen? I'm not saying scale makes good guis, but if it's what you want, why script a pseudo-scaling gui? |
|
|
| Report Abuse |
|
|
| |
|
OzzyFin
|
  |
| Joined: 07 Jun 2011 |
| Total Posts: 3600 |
|
|
| 07 Aug 2016 11:52 AM |
"I'm not saying scale makes good guis"
and no one is saying offset makes good guis |
|
|
| Report Abuse |
|
|
|
| 07 Aug 2016 11:53 AM |
The Width of a screen depends on the user's computer, or tablet. It varies based on the screen size. It's better to use Scale for making guis.
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 07 Aug 2016 11:54 AM |
There is nothing wrong with scale. Just the solution I posted was a simpler way of going about it. I already have posted a way in the past where you can directly center a gui using scale.
|
|
|
| Report Abuse |
|
|
Color3new
|
  |
| Joined: 05 Jul 2009 |
| Total Posts: 64 |
|
|
| 07 Aug 2016 11:54 AM |
I'm bit confused here as well. Scale, as the name implies, scales to the size of the screen.
The way you're doing it here, you'd need a loop somewhere updating the viewsize, and you know that the more loops you have, you're stacking up on lag. |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 07 Aug 2016 11:55 AM |
notice the significant amount of black space on the right of the screen when using 0.33 gyazo.com/4906bcfbdd207ace18c9d1b09d98393f
as opposed to a more accurate third gyazo.com/4497f49007753632c8ecf0e3fd19c27f |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 07 Aug 2016 11:55 AM |
woops i didnt mean that nvm
|
|
|
| Report Abuse |
|
|
|
| 07 Aug 2016 12:03 PM |
@Kodran
Using the most accurate I can go to (0.333) I got just a sliver on my screen.
http://prntscr.com/c2ql4c
Did you just use 0.3 or even 0.33? That seems intentionally dishonest if you did. |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 07 Aug 2016 12:07 PM |
I used 0.33
The different outcomes are because my screen is larger than yours, so a less accurate scale will make more difference for me in terms of number of pixels. |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 07 Aug 2016 12:08 PM |
| By larger screen I don't mean physically larger, I just mean higher resolution. |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 07 Aug 2016 12:11 PM |
That black space is nearly triple the size when I span it across all monitors gyazo.com/4906bcfbdd207ace18c9d1b09d98393f
Which proves you should never use inaccurate values, even if they look good for you because it may not look great for other people with different setups. |
|
|
| Report Abuse |
|
|
Color3new
|
  |
| Joined: 05 Jul 2009 |
| Total Posts: 64 |
|
|
| 07 Aug 2016 12:11 PM |
Mine is larger as well and I get a large sliver. How is roblox determining gui scale?
Your way is definitely more accurate, just seems a bit of a pain considering that you'll have to update the screen size variables to consolidate for when you resize your window, since you're using offset. |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 07 Aug 2016 12:11 PM |
Sorry wrong picture gyazo.com/c337fa7d4ea2fd6b11ab901d1ef096ab |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 07 Aug 2016 12:14 PM |
| Roblox is calculating scale perfectly. if you do 0.33*number of pixels you'll get exactly what 33% of the screen is. The problem is that isn't as accurate as dividing the number of pixels by 3. |
|
|
| Report Abuse |
|
|