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 » Scripters
Home Search
 

AbsolutePosition Y being wonky

Previous Thread :: Next Thread 
ASpoonfullOfSucrose is not online. ASpoonfullOfSucrose
Joined: 28 Oct 2015
Total Posts: 442
09 Aug 2016 06:21 PM
The area in which the AbsolutePosition Y is being calculated is a bit off.

E.g I've got a frame 100x100, positioned at Y scale 0.5 and X scale 0.5.
When my script tries to detect the presence of the frame using its absoluteposition, the mouse has to always be about 10-20 pixels higher than the actual border of the frame to register it's detection.

Meaning that it doesn't detect it as soon as the mouse is within its X and Y absolutes. X is fine though, Y is just off.

local function MouseOver(frame) --returns true/false if the mouse is over a frame. (Or any GUI object)
local TopBound = frame.AbsolutePosition.Y
local BottomBound = frame.AbsolutePosition.Y + (frame.AbsoluteSize.Y)
local LeftBound = frame.AbsolutePosition.X
local RightBound = frame.AbsolutePosition.X + frame.AbsoluteSize.X
if MouseY > TopBound and MouseY < BottomBound and MouseX > LeftBound and MouseX < RightBound then
return true
end
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
09 Aug 2016 06:22 PM
Why not just use the MouseEnter and MouseLeave events?
Report Abuse
ASpoonfullOfSucrose is not online. ASpoonfullOfSucrose
Joined: 28 Oct 2015
Total Posts: 442
09 Aug 2016 06:23 PM
My structuring doesn't allow for it. So I have to use a script.
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
09 Aug 2016 06:27 PM
GetGuiExtents = function(Gui)
local SizeX, SizeY = Gui.AbsoluteSize.X, Gui.AbsoluteSize.Y
local PositionX, PositionY = Gui.AbsolutePosition.X, Gui.AbsolutePosition.Y
local ExtentX = PositionX + SizeX
local ExtentY = PositionY + SizeY
return {Position = {X = PositionX, Y = PositionY}, Size = {X = SizeX, Y = SizeY}, Extent = {X = ExtentX, Y = ExtentY}}
end

GetPointInExtent = function(Extent, PointX, PointY)
local PointX = type(PointX) == 'number' and PointX or Mouse.X
local PointY = type(PointY) == 'number' and PointY or Mouse.Y
local XOverlap = PointX >= Extent.Position.X and PointX <= Extent.Extent.X
local YOverlap = PointY >= Extent.Position.Y and PointY <= Extent.Extent.Y
return YOverlap and XOverlap
end

local isMouseOver = GetPointInExtent(GuiExtents,X,Y)

if isMouseOver then

end

Credit: TickerOfTime


Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
09 Aug 2016 06:28 PM
and check this out:

https://forum.roblox.com/Forum/ShowPost.aspx?PostID=195765412


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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