|
| 08 Jan 2012 09:55 PM |
Well, I figured out the problem with my placement when using MouseButton1Down event. How to fix the problem is what I can't figure out.
_________________________________ | | | t | | | | _________________________ | | | || | | || | | || | | || | | j || | | || | | || | | || | |________________________.|| |_________________________________|
Item t is the monitor itself. Item j is the Roblox application window.
The AbsolutePosition of the Roblox GUI object is with respect to item t. Unfortunately, the Mouse events in the GUI objects return the mouse's AbsolutePosition, which means its position is relative to item t, not item j. How would I be able to calculate the mouse's location with respect to item j? I'm sure it's something EXTREMELY simple.
Cheers, -- AFF
~ 121/97/103 109/97 105 |
|
|
| Report Abuse |
|
|
|
| 08 Jan 2012 10:05 PM |
It seems like there should be a way to get the position of the mouse relative to the ScreenGui itself. I can't think of how, though. Maybe:
gui.MouseButton1Down:connect(function(x,y) mousePos = Vector2.new(x,y) appPos = Vector2.new(t.AbsolutePosition.x,t.AbsolutePosition.y) realPos = mousePos - appPos return realPos end)
I have no idea if that will work or not. It doesn't seem like it would, but I'm sure you can work off of it.
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
|
| 08 Jan 2012 10:06 PM |
I meant: gui.MouseButton1Down:connect(function(x,y) mousePos = Vector2.new(x,y) appPos = Vector2.new(j.AbsolutePosition.x,j.AbsolutePosition.y) realPos = mousePos - appPos return realPos end)
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 08 Jan 2012 10:19 PM |
It's actually not.... Otherwise, my game wouldn't work.
So your math has a problem with it. |
|
|
| Report Abuse |
|
|
| |
|
|
| 08 Jan 2012 10:38 PM |
"It's actually not.... Otherwise, my game wouldn't work.
So your math has a problem with it."
It seems I was mislead. I should have done a bit more research before I posted this.
local dot = Instance.new("Frame") dot.Size = UDim2.new(0,3,0,3) dot.BorderSizePixel = 0 dot.BackgroundColor3 = Color3.new(0,0,0)
function placeDot(x, y) local spot = dot:clone() local oP = script.Parent.Parent.Parent.AbsoluteSize local oX, oY = oP.X, oP.Y print(x, y) spot.Parent = script.Parent.Parent.Parent.Canvas spot.Position = UDim2.new(x/oX, -2, y/oY, -2) end
function displayPoint(x, y) placeDot(x, y) end
script.Parent.MouseButton1Down:connect(displayPoint)
That works. :D
Cheers, -- AFF
~ 121/97/103 109/97 105 |
|
|
| Report Abuse |
|
|