Jump to content

Cuestions


Starkz

Recommended Posts

local guiAnimations = { } 
  
function guiFade ( gui, state ) 
    if ( not guiAnimations [ gui ] ) then 
        guiAnimations [ gui ] = { } 
    end 
    if isTimer ( guiAnimations [ gui ].fadeIn ) then 
        killTimer ( guiAnimations [ gui ].fadeIn ) 
        guiAnimations [ gui ].fadeIn = nil 
    end 
    if isTimer ( guiAnimations [ gui ].fadeOut ) then 
        killTimer ( guiAnimations [ gui ].fadeOut ) 
        guiAnimations [ gui ].fadeOut = nil 
    end 
    if ( state == "out" ) then 
        guiAnimations [ gui ].fadeIn = setTimer ( guiFade, 50, 1, gui, state ) 
        local alpha = guiGetAlpha ( gui ) 
        guiSetAlpha ( gui, ( alpha - 0.1 ) ) 
        if ( alpha == 0 ) then 
            guiSetVisible ( gui, false ) 
            killTimer ( guiAnimations [ gui ].fadeIn ) 
            guiAnimations [ gui ] = nil 
        end 
    elseif ( state == "in" ) then 
        guiSetVisible ( gui, true ) 
        guiAnimations [ gui ].fadeOut = setTimer ( guiFade, 50, 1, gui, state ) 
        local alpha = guiGetAlpha ( gui ) 
        guiSetAlpha ( gui, ( alpha + 0.1 ) ) 
        if ( alpha == 1 ) then 
            killTimer ( guiAnimations [ gui ].fadeOut ) 
            guiAnimations [ gui ] = nil 
        end 
    end 
end 

Use that function for fading in and out GUI elements.

Example:

local window = guiCreateWindow ( arguments ) 
guiFade ( window, "out" ) 

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