Wei Posted January 15, 2014 Share Posted January 15, 2014 I am scripting for like realy long time, and I still don't understand how to calculate dx draws for all resolutions ? like i want a reactangle at 300 300 300 300 at my resolution (1024/768). How would I make that player wich has bigger resolution would have in same place? (it would be more than 300) Thanks, Wei Link to comment
pa3ck Posted January 15, 2014 Share Posted January 15, 2014 Get the resolution first with guiGetScreenSize, then calculate the position from the two numbers you got. You might want to read this https://wiki.multitheftauto.com/wiki/Int ... the_window Link to comment
Gallardo9944 Posted January 15, 2014 Share Posted January 15, 2014 in fact, the question is stated incorrectly. The player will have the rectangle at 300,300 with any resolution, but if you mean you want to scale it, you could easily do it like that: local sx,sy = 300,300 -- Your size local px,py = 300,300 -- Your position local x,y = guiGetScreenSize() -- Get the resolution of the player local scale = y/768 -- Scale to your screen height (Divide by some smaller value to make it scale more, divide by bigger value to scale less) I divided it by your screen height so the scale is 1 for you and it changes for other players depending on their resolution. sx,sy = sx*scale,sy*scale -- Calculate the absolute size depending on the resolution. px,py = px*scale,py*scale -- Calculate the position as well. I suggest to always scale by the screen height as it is never bigger than the screen width, so the image/rectangle/whatever won't get out of the box. 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