Newbie Posted March 20, 2014 Share Posted March 20, 2014 I have made a panel GUI with: button = {} window = {} staticimage = {} label = {} How can i make them stay on the screen at same point of all resolutions ? Link to comment
Dealman Posted March 20, 2014 Share Posted March 20, 2014 If you used absolute positions, you can divide the absolute value with your resolution - and then multiply it with the currently used one. For example; (Using 1360x768) local screenX, screenY = guiGetScreenSize() local exampleWindow = guiCreateWindow(screenX*(400/1360), screenY*(600/768), screenX*(150/1360), screenY*(300/768), "Example", true) In some cases it might not yield the result you want, and more complicated calculations might be needed. However, I have always used this method and it has always satisfied my needs so far. Link to comment
Moderators Citizen Posted March 21, 2014 Moderators Share Posted March 21, 2014 I have made a panel GUI with: button = {} window = {} staticimage = {} label = {} How can i make them stay on the screen at same point of all resolutions ? If you used the guieditor resource, you should set the parents relative to the screen. (Right click somewhere on the screen (but not on a gui element) and click on Rel/Abs parent or something.) This way it will generate the gui code using relative values. guiGetScreenSize is only needed to set the rel values in absolute one right before you use dx functions (they only support/accept absolute values). For the gui elements, there is no need to use that function since they accept both values but you have to specify that functions if you are sending him absolute or relative values by using the boolean argument "relative" (check the wiki pages to know which one is the "relative" arguement). So the Dealman's example is wrong because he uses guiGetScreenSize to tansform relative values into absolute one but still saying to the gui function the values he is sending to it are relative ones. So check the next examples (fixing the Dealman's post): local screenX, screenY = guiGetScreenSize() local exampleWindow = guiCreateWindow(screenX*(400/1360), screenY*(600/768), screenX*(150/1360), screenY*(300/768), "Example", false) is the same as: local exampleWindow = guiCreateWindow( 400/1360, 600/768, 150/1360, 300/768, "Example", true) Both examples will be placed correctly on all resolutions. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now