turtly Posted August 29, 2016 Share Posted August 29, 2016 Hi guys, so my problem is that then I dxDrawImage an image it isn't in the same place for two different resolutions. Here is my current code: local x,y = guiGetScreenSize() -- Get screen resolution. function renderDisplay ( ) dxDrawImage ( x/2*1.65, y/2, 381, 209, 'hud.png' ) end function HandleTheRendering ( ) addEventHandler("onClientRender", root, renderDisplay) -- Keep everything visible with onClientRender. end addEventHandler("onClientResourceStart",resourceRoot, HandleTheRendering) I have been trying to place it into the top right corner of the screen. Thanks for reading Link to comment
Simple0x47 Posted August 29, 2016 Share Posted August 29, 2016 Just use relative positions. local sx, sy = guiGetScreenSize() -- Let's suppose the position and the size is 500, 250, 500, 250 We divide 500 by our width screen size, and 250 by our height screen size it will give a relative position like 0.5. local rx, ry, rsx, rsy = 500 / yourScreenWidth, 250 / yourScreenHeight, 500 / yourScreenWidth, 250 / yourScreenHeight dxDrawImage( rx * sx, ry * sy, rsx* sx, rsy * sy, ... ) Link to comment
Overkillz Posted August 29, 2016 Share Posted August 29, 2016 Other easy way could be if x >= 1280 and y >=720 then -- This will set the image only to the resolution 1280x720 or lower else -- This will set the image to the resolutions which surpass 1280x720 end Link to comment
turtly Posted August 29, 2016 Author Share Posted August 29, 2016 Just use relative positions. local sx, sy = guiGetScreenSize() -- Let's suppose the position and the size is 500, 250, 500, 250 We divide 500 by our width screen size, and 250 by our height screen size it will give a relative position like 0.5. local rx, ry, rsx, rsy = 500 / yourScreenWidth, 250 / yourScreenHeight, 500 / yourScreenWidth, 250 / yourScreenHeight dxDrawImage( rx * sx, ry * sy, rsx* sx, rsy * sy, ... ) I really don't get it, sorry. I tried to move it to the right side of my screen without any success. What values do I change to move it? Here is my code now: local x,y = guiGetScreenSize() -- Get screen resolution. local sx, sy = guiGetScreenSize() local yourScreenWidth, yourScreenHeight = guiGetScreenSize () -- Let's suppose the position and the size is 500, 250, 500, 250 We divide 500 by our width screen size, and 250 by our height screen size it will give a relative position like 0.5. local rx, ry, rsx, rsy = 0.05 / yourScreenWidth, 250 / yourScreenHeight, 381 / yourScreenWidth, 209 / yourScreenHeight --dxDrawImage( rx * sx, ry * sy, rsx* sx, rsy * sy, ... ) function renderDisplay ( ) dxDrawImage( rx * sx, ry * sy, rsx* sx, rsy * sy, "hud.png" ) end function HandleTheRendering ( ) addEventHandler("onClientRender", root, renderDisplay) -- Keep everything visible with onClientRender. end addEventHandler("onClientResourceStart",resourceRoot, HandleTheRendering) Link to comment
ma2med Posted August 29, 2016 Share Posted August 29, 2016 On which resolution this working? Link to comment
turtly Posted August 29, 2016 Author Share Posted August 29, 2016 I got it using guieditor, thanks! 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