Jump to content

Apply DX Image on Cursor?


Maurize

Recommended Posts

  
addEventHandler( "onClientRender", getRootElement(), 
function() 
if ( isCursorShowing() == true ) then 
    local sx, sy, wx, wy, wz = getCursorPosition" class="kw4">getCursorPosition() 
    dxDrawImage( sx, sy, 55, 75, "mainFiles/elementCursor.png" ) 
    end 
end ) 
  

Doen't work. Image is in the top-left corner... Anything wrong?

Link to comment

It returns a relative values, but you need absolute values for dxDrawImage.

addEventHandler( "onClientRender", getRootElement(), 
function() 
if ( isCursorShowing() == true ) then 
    local sx, sy, wx, wy, wz = getCursorPosition() 
    local sx, sy = relativeToAbsolute(sx, sy) 
    dxDrawImage( sx, sy, 55, 75, "mainFiles/elementCursor.png" ) 
    end 
end ) 
  
  
function relativeToAbsolute( X, Y ) 
    local rX, rY = guiGetScreenSize() 
    local x = X*rX 
    local y = Y*rY 
    return x, y 
end 
  

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