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
 

Re: When User Clicks The Button Between Minimize and X

Previous Thread :: Next Thread 
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
10 Apr 2016 12:39 PM
I need to know when a user resizes their screen at any given time. This function works just fine so far:


function ResizeGui(prop)
if prop == "AbsoluteSize" then
-- resize stuff
end
end

GameGui.Changed:connect(ResizeGui)


GameGui is a ScreenGui in PlayerGui. It works totally fine when a user "drags" the size of a screen, but when that middle button in the top right is clicked, the change is not registered for some reason! How can I detect this? Thanks.
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
10 Apr 2016 12:51 PM
bump
Report Abuse
Smeers is not online. Smeers
Joined: 14 Feb 2013
Total Posts: 797
10 Apr 2016 12:58 PM
Odd, it should work o-o

In fact, I'm over 2000% sure it should, I've done it before for a smart resize method that kept aspect ratio.

Now my brain hurts.
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
10 Apr 2016 01:01 PM
@Smeers

Check out the left bar here:

https://www.roblox.com/games/160720254/Testing-Grounds


CODE FROM THE COMMENT EARLIER:

local chatSize = SG:GetCore("ChatWindowSize")
local chatPosition = SG:GetCore("ChatWindowPosition")
local newPos = chatPosition + UDim2.new(0, 0, chatSize.Y.Scale, chatSize.Y.Offset + 44)
local newSize = UDim2.new(chatSize.X.Scale, chatSize.X.Offset, 1 - newPos.Y.Scale, -newPos.Y.Offset - 38)
SideBar.Position = newPos
SideBar.Size = newSize


Works until you click that blasted button...
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
10 Apr 2016 01:03 PM
I think the chat window isn't being resized fast enough when the button is clicked. Should I just BindToRenderStep the entire sidebar?
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
10 Apr 2016 01:08 PM
Or should I calculate it using the same math from the core chat script...
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
10 Apr 2016 01:38 PM
SOLUTION:


local PHONE_SCREEN_WIDTH = 640
local TABLET_SCREEN_WIDTH = 1024

function ResizeGui(prop)
local newSize = GameGui.AbsoluteSize
local chatBarSize
local chatBarPosition

-- Phone
if newSize.X <= PHONE_SCREEN_WIDTH then
chatBarSize = UDim2.new(.5, 0, 0, 40)
chatBarPosition = UDim2.new(0, 0, .5, 2)
-- Tablet
elseif newSize.X <= TABLET_SCREEN_WIDTH then
chatBarSize = UDim2.new(.4, 0, 0, 40)
chatBarPosition = UDim2.new(0, 0, .3, 2)
-- Desktop
else
chatBarSize = UDim2.new(.3, 0, 0, 40)
chatBarPosition = UDim2.new(0, 0, .25, 2)
end

local newPos = chatBarPosition + UDim2.new(0, 0, 0, 42)
local newSize = UDim2.new(chatBarSize.X.Scale, chatBarSize.X.Offset, 1-newPos.Y.Scale, -newPos.Y.Offset-38)
SideBar.Position = newPos
SideBar.Size = newSize
end



Works like a charm. I'll probably simplify it but this works.
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
10 Apr 2016 01:44 PM
Ah-ha! Much cleaner!


local newSize = GameGui.AbsoluteSize
-- Phone
if newSize.X <= PHONE_SCREEN_WIDTH then
SideBar.Position = UDim2.new(0, 0, .5, 44)
SideBar.Size = UDim2.new(.5, 0, .5, -82)
-- Tablet
elseif newSize.X <= TABLET_SCREEN_WIDTH then
SideBar.Position = UDim2.new(0, 0, .3, 44)
SideBar.Size = UDim2.new(.4, 0, .7, -82)
-- Desktop
else
SideBar.Position = UDim2.new(0, 0, .25, 44)
SideBar.Size = UDim2.new(.3, 0, .75, -82)
end
Report Abuse
UFAIL2 is not online. UFAIL2
Joined: 14 Aug 2010
Total Posts: 6905
10 Apr 2016 01:51 PM
Camera.ViewportSize works when you click the button btw.
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