62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 14 Apr 2016 03:31 PM |
| I have an offset frame that has scaled size. How can I convert the position to scaled? I'm sending the frame to the mouse' position. The mouse' position is in pixels, sooo yeah. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 14 Apr 2016 03:34 PM |
hmm
scale = offset/absolutesize
|
|
|
| Report Abuse |
|
|
|
| 14 Apr 2016 03:34 PM |
| https://forum.roblox.com/Forum/ShowPost.aspx?PostID=186928929 |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 14 Apr 2016 03:35 PM |
@ghost
That was for offset position and offset size I do believe.
@time
I'll try that, thanks |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 14 Apr 2016 03:41 PM |
Time, that's very close! But it's not perfect. I'm kinda looking for the closest I can get.
Current:
tower.Position = (tower.Position/tower.AbsoluteSize) |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 14 Apr 2016 03:44 PM |
tower.Position = UDim2.new(tower.Position.X.Offset/tower.AbsoluteSize.X,0,tower.Position.Y.Offset/tower.AbsoluteSize.Y,0)
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 14 Apr 2016 03:45 PM |
try absoluteposition then if thats really close
|
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
| |
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 14 Apr 2016 03:50 PM |
Turns out I wasn't setting it to scaled. When I set it to scale, it says like 25.5...
;-; |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
| |
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
| |
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 14 Apr 2016 05:18 PM |
| I pretty much need to implement this as my next feature to my game.. |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 14 Apr 2016 05:24 PM |
| I'm moving the tower to my mouse' location. And the mouse location is in pixels.. Not scaled.. Any other way to do what I'm trying to achieve? |
|
|
| Report Abuse |
|
|
|
| 14 Apr 2016 05:27 PM |
| UDim2.new(offset.x/cam.ViewportSize.X,0,offset.y/cam.ViewportSize.Y,0) |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 14 Apr 2016 05:30 PM |
Thanks. I think we're getting closer, but this is happening.. https://gyazo.com/202faf50d90be46e7114ef4ce481e9b5 |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 14 Apr 2016 05:32 PM |
oops i never assigned that UDim2 to the tower's position. lol
trying it now |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 14 Apr 2016 05:34 PM |
:D
It works great! Thanks!
Just curious if there's a workaround for this small bug. After I placed my tower, it shifted upward slightly. If there isn't an available workaround, I'll have to shift it downward or something after placement? idk to be honest |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 14 Apr 2016 05:37 PM |
| Got it! Just had to do some adjusting on the Y axis. Thanks all for your help!! |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 14 Apr 2016 05:49 PM |
Cri
This isn't gonna work.. I added like a + .036 to the Y axis and it's working inaccurately. Like for different screen sizes it won't work how it is in studio. Anyone have any other suggestions? |
|
|
| Report Abuse |
|
|
| |
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 14 Apr 2016 06:22 PM |
I did, and this time it was very tiny. :l
I changed Position to Size though |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
| |
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
| |
|
| |
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 14 Apr 2016 07:36 PM |
local function SpawnTower(tower) mDown = false tower.Parent = map tower.Visible = true while wait() do --This is to move the tower to the mouse' position for placement tower.Position = UDim2.new(0,m.X,0,m.Y) if mDown and not CheckCollision(tower) then break end end tower.RangeCircle.ImageTransparency = 1 tower.Attack.Disabled = false local cam = game.Workspace.CurrentCamera --Convert from pixels to scaled tower.Position = UDim2.new(tower.Position.X.Offset/cam.ViewportSize.X,0,(tower.Position.Y.Offset/cam.ViewportSize.Y) + .036,0) buying = false end |
|
|
| Report Abuse |
|
|