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: GUI Positioning/Mouse Placement

Previous Thread :: Next Thread 
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
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
DihydrogenOxide is not online. DihydrogenOxide
Joined: 20 Feb 2011
Total Posts: 642
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
DihydrogenOxide is not online. DihydrogenOxide
Joined: 20 Feb 2011
Total Posts: 642
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 is not online. 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
Cozzy00000 is not online. Cozzy00000
Joined: 02 Apr 2011
Total Posts: 3536
08 Jan 2012 10:25 PM
wat r u talking bout?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
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
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