Laysiks Posted February 24, 2015 Posted February 24, 2015 Hello! How to make GUI where position is center and length,height(not changed) are this same in all resolutions ?
Callum Posted February 24, 2015 Posted February 24, 2015 By using guiGetScreenSize and some basic maths.
Callum Posted February 24, 2015 Posted February 24, 2015 Well if you wanted to make a window appear in the centre of any resolution, let's assume the width of the window is 640, and the height is 480, and we have the variables resX and resY: x = resX / 2 - (640 / 2) y = resY / 2 - (480 / 2) width = 640 height = 480 It's all about logic and maths, not something you can really copy and paste (unless you only ever want the windows in the middle).
Saml1er Posted February 24, 2015 Posted February 24, 2015 I'll tell you a very simple way. DX local myResX, myResY = 1024, 768 -- This is my resolution. Relace it with yours ^^ local sx, sy = guiGetScreenSize ( ) sx,sy = sx/ myResX, sy/myResY -- divide it by your resolution and so on you can easily scale dxDrawImage ( sx * 100, sy*100, sx*40, sy*40 ) -- RELATIVE SIZES. This will fit on all resolutions ;p GUI -- For gui set the relative optional arguement to true local myResX, myResY = 1024, 768 -- This is my resolution. Relace it with yours ^^ guiCreateWindow ( 40/myResX, 30/myResY, 300/myResX , 600/myResY, "Relative sized window", true )
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