Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 14 Jan 2012 10:46 AM |
My question is about the GUI positioning at this place made by Vitos:
http://www.roblox.com/Snake-place?id=12567054
I was interested in the fact that the orange GUI that set the boundaries for the movement of the snake appears in the middle of the screen, no matter what screen size, and the fact that it doesn't get bigger when re-sized. I know you can use scale to set it in the middle of the screen, but using scale will cause the boundaries to get either smaller or larger. I was curious about how Vitos did this. I PMed him, but he hasn't responded yet, and I want a quick answer.
~Flurite |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 14 Jan 2012 10:50 AM |
So pretty much the question is how to position and size a GUI in the middle of every screen, and the same size on every screen.
~Flurite |
|
|
| Report Abuse |
|
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 14 Jan 2012 10:57 AM |
Position is independent of size. However, you can size it and then position it based on that with scale, which is relative to the screen's size. |
|
|
| Report Abuse |
|
|
|
| 14 Jan 2012 11:00 AM |
Size it to whatever you want using scale and then take away half of the scale size from 0.5 for both X and Y in position?
[The silence answered my question.] |
|
|
| Report Abuse |
|
|
|
| 14 Jan 2012 11:00 AM |
Latetoast...
[The silence answered my question.] |
|
|
| Report Abuse |
|
|
Ryfel
|
  |
| Joined: 03 Jan 2012 |
| Total Posts: 14 |
|
|
| 14 Jan 2012 11:37 AM |
he just used scale of position and offset for size for example
Size=UDim2.new(0,500,0,500) Pos=UDim2.new(0.5,-250,0.5,-250) |
|
|
| Report Abuse |
|
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 14 Jan 2012 11:41 AM |
| Ryfel has the correct idea. You see, GUI objects are positioned with a top-left point. Therefore, if you must position it with a center point, you must take the center point and move it up by half the element's height and move it left by half the element's width to get the top-left point. |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 14 Jan 2012 11:46 AM |
Hmm.. then if I do use a mix of offset and scale it will be hard to detect colliding GUIs, because I'm pretty sure AbsoluteSize and AbsolutePosition aren't accurate..
~Flurite |
|
|
| Report Abuse |
|
|
|
| 14 Jan 2012 06:15 PM |
@Flurite --This is comparing floats so it might help.
function IsEqual(num1,num2) local x = 0.000001 return math.abs(num1-num2) <= x * math.abs(num1) end
You can adapt that I guess. [The silence answered my question.] |
|
|
| Report Abuse |
|
|