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
 

Help simulating the macbook "Magnify" effect

Previous Thread :: Next Thread 
darkstriken is not online. darkstriken
Joined: 23 Oct 2010
Total Posts: 376
27 Sep 2015 03:34 PM
why it's still a free bump
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
27 Sep 2015 03:36 PM
Yes, but it kinda throws everybody off.

BACK ON TOPIC:

How do I re-size these icons with respect to the mouse. I made the code that is in the "subject" box and I'd love if someone can edit it so that the icons re-size accordingly with the mouse.
Report Abuse
TickerOfTime is not online. TickerOfTime
Joined: 02 Sep 2012
Total Posts: 2030
27 Sep 2015 05:38 PM
"Please don't post unless you know how to re-size them with respect to the mouse."

Well, given that is the topic of this thread, I am considering this thread closed.
Even though you post asking for help to resize them, you ask people not to post unless they can resize the icons. So, I will act like this thread never existed.
Report Abuse
Csharp0 is not online. Csharp0
Joined: 05 Mar 2015
Total Posts: 261
27 Sep 2015 06:05 PM
I guess if you had the X and Y center of the icon you could use http://wiki.roblox.com/index.php?title=API:Class/GuiObject/MouseEnter and use math below to get the distance from the center and mouse.

((x2-x1)^2+(y2-y1)^2)^0.5

I think that's correct.
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
27 Sep 2015 06:49 PM
This has a rather simple solution. I'll even make a model for you to see the code in action.

What we have to do is get a distance ratio and turn it into a percentage. Adjust the size and position to the bubble.

Here's the code:

local Mouse = game.Players.LocalPlayer:GetMouse(

)

local MagnifiableObjects = {

}

local function RegisterGUI(
GUI,
MaxMagnificationFactor,
RadiusCutoff
)
MagnifiableObjects[
GUI
] = {
MaxMagnificationFactor,
RadiusCutoff,
GUI.AbsoluteSize,
GUI.AbsolutePosition
}
end

Mouse.Move:connect(
function(
)
local X,Y = Mouse.X, Mouse.Y
for GUI, Data in pairs(
MagnifiableObjects
) do
local GUICenter = GUI.AbsolutePosition + GUI.AbsoluteSize/2
local Size = GUI.AbsoluteSize
local Distance = (Vector2.new(X,Y) - GUICenter).magnitude
local SizePercentage = 1-(Distance/Data[2])
SizePercentage = SizePercentage > 0 and SizePercentage or 0

local ChangeFactor = Data[1] * SizePercentage
ChangeFactor = ChangeFactor >= 1 and ChangeFactor or 1
local NewSize = Data[3] * ChangeFactor
local NewPositionAdjustment = Data[4] - (NewSize - Data[3])/2
GUI.Size = UDim2.new(0,NewSize.X, 0, NewSize.Y)
GUI.Position = UDim2.new(0,NewPositionAdjustment.X, 0, NewPositionAdjustment.Y)
end
end
)

RegisterGUI(script.Parent.Frame, 3, 300) -- Means "3" times bigger than what it was.

And here is the link to the model: http://www.roblox.com/GUI-Magnify-Effect-item?id=301330079

Use that model and you can see how the GUI changes size with respect to how close the mouse is to it.
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
28 Sep 2015 01:56 PM
THanks so much! I may not understand the math but it works.
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
28 Sep 2015 01:58 PM
Mhm. It had me stumped for just a moment with adjusting the size, but it was a fun challenge. Sometimes, understanding what is useful isn't required. Using it to make something greater is what counts.
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
28 Sep 2015 01:59 PM
I am using it for a UI in my new game I'm working on. It is a year project. Do you think it will make a good UI?
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
28 Sep 2015 02:06 PM
fish are you dumb or


#code return
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
28 Sep 2015 02:06 PM
Why would I be dumb?
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
28 Sep 2015 02:07 PM
Oh, the UI is not the year project. The game is lol.
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
28 Sep 2015 02:07 PM
Everytime someone asks what you mean you always respond "resize with respect to the mouse"

Like repeating doesnt make us instantly understand


#code return
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
28 Sep 2015 02:08 PM
And you chose to just post that now e.e
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
28 Sep 2015 02:09 PM
I just got on so


#code return
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
28 Sep 2015 02:12 PM
@nox7 Does this work with scale? It seems to make the icons dissapear for me.
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
28 Sep 2015 02:14 PM
"It seems to make the icons dissapear for me."

It doesn't matter if you use Scale or Offset, the script accounts for both using AbsoluteSize. I am not having issues with this, so you'll have to explain or post a detailed reproduction of your issue.

What numbers are you giving "RegisterGUI" and what size is the GUI changing to? Check in the Explorer window to see what it is changing to.
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
28 Sep 2015 02:15 PM
omg that was almost exactly what i had @nox7

i had a predesignated area tho and i just compared Y, not X and Y, since on the mac i think it only bases off of Y


Red Blossoms
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
28 Sep 2015 02:17 PM
@nox7

It basically went off the screen.

What is RadiusCutOff?
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
28 Sep 2015 02:19 PM
This is what I am feeding it

RegisterGUI(script.Parent.Taskbar.Icons, 3, 300)
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
28 Sep 2015 02:21 PM
"script.Parent.Taskbar.Icons"

It looks like you are giving it an entire collection GUI. What I mean by this is that it looks like you are giving it the GUI which contains all of your icons. Why? I was assuming you were doing this individually. Even then, that isn't too bad.

However, depending on how big the entire parent GUI is, you gave the magnifying factor a "3." This means it will be three times the size it originally way. This may make everything so large it goes off the screen. Try something much lower. Like 1.2 or 1.3
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
28 Sep 2015 02:22 PM
@Nox It actually is a frame containing them. ANd I tried it on each icon seperately and It didn't work out(same thing happened)
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
28 Sep 2015 02:23 PM
You'll have to just do something like publish a model, because I am having 0 issues with my tests. I'll need to see what you're doing so I can either fix the script, or show you what you're not doing right :/
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
28 Sep 2015 02:29 PM
@nox
http://www.roblox.com/For-nox7-item?id=301484333

I know the icons are bad, they are temporary for test.
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
28 Sep 2015 02:40 PM
Ah, I see what I did. I forgot that ROBLOX's descendants' position is in relation to their parents!

Change this:

] = {
MaxMagnificationFactor,
RadiusCutoff,
GUI.AbsoluteSize,
GUI.AbsolutePosition
}

To this:


] = {
MaxMagnificationFactor,
RadiusCutoff,
GUI.AbsoluteSize,
(not GUI.Parent:IsA("GuiBase")) and GUI.AbsolutePosition or (GUI.Parent.AbsolutePosition - GUI.AbsolutePosition)
}
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
28 Sep 2015 02:48 PM
@nox what does "RadiusCutoff" mean
Report Abuse
Previous Thread :: Next Thread 
Page 2 of 3Go to page: 1, [2], 3 Prev Next
 
 
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