Jump to content

Smooth gui open


DakiLLa

Recommended Posts

Posted

Hi. I want to make a smooth opening and closing gui menus. I know that i need to use guiGetAlpha and guiSetAlpha but i dont know how to use it correctly.

Can you help me with small example or just tell what i need to do.

thx :)

Posted
setTimer(guiSetAlpha,100,10,theGUI,guiGetAlpha(theGUI)/255+0.1) 

(although it seems weird with guiGetAlpha returning between 0 and 255, while guiSetAlpha only seem to work between 0 and 1... :roll: )

Or use the example HERE. ;)

Posted

ehm, i have made something, but no result..where i have mistakes ?

g_res_root = getResourceRootElement ( getThisResource () ) 
  
addEventHandler ( "onClientResourceStart", g_res_root, 
    function () 
        x, y = guiGetScreenSize () 
        p_wnd = guiCreateWindow ( x-280, y-600, 243, 164, "test", false ) 
        close () 
    end 
) 
  
function close (  ) 
    local currentAlpha = guiGetAlpha ( p_wnd ) 
    local newAlpha = currentAlpha - 4 
    if newAlpha < 0 then newAlpha = 0 end 
    guiSetAlpha ( p_wnd, newAlpha ) 
    if newAlpha ~= 0 then 
        setTimer ( open, 50, 1, p_wnd ) 
    end 
end 

Posted
g_res_root = getResourceRootElement ( getThisResource () ) 
  
addEventHandler ( "onClientResourceStart", g_res_root, 
    function () 
        x, y = guiGetScreenSize () 
        p_wnd = guiCreateWindow ( x-280, y-600, 243, 164, "test", false ) 
        close () 
    end 
) 
  
function close (  ) 
    local currentAlpha = guiGetAlpha ( p_wnd ) 
    local newAlpha = currentAlpha - 4 
    if newAlpha < 0 then newAlpha = 0 end 
    guiSetAlpha ( p_wnd, newAlpha ) 
    if newAlpha ~= 0 then 
        setTimer ( close, 50, 1, p_wnd ) 
    end 
end 

Try this? You put open in the timer while there's no open. :P

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