Jump to content

dxDrawImage not in the same place on different resulotions


turtly

Recommended Posts

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

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...