Jump to content

Fade


Beluga

Recommended Posts

bindKey ("m","down",  
function(key,state)  
    if (guiGetVisible (gameWindow) == false) then  
        guiSetVisible (gameWindow,true)  
        showCursor (true,true) 
    else 
        guiSetVisible (gameWindowWindow,false)  
        showCursor (false,false) 
        end  
    end  
end) 

I got his code now. If I press "M" it shows "gameWindow" but I was searching on the wiki and couldn't find anything about slowly fade in. So my question is: Somebody can help me with making this: If I press "M" the "gameWindow" slowly fade in and when I press again it slowly fade out again.

P.s I tried something with guiGetAlpha and guiSetAlpha but It didn't helped.

function openMenu() 
    local menu = guiGetVisible(gameWindow) 
    if menu == false then 
        local currentAlpha = guiGetAlpha(gameWindow) 
        local newAlpha = currentAlpha - 4 
        if newAlpha < 0 then newAlpha = 0 end 
        guiSetAlpha(gameWindow,newAlpha) 
        if newAlpha ~= 0 then 
            setTimer(openMenu, 50, 1) 
        end 
    elseif menu == true then 
        local currentAlpha = guiGetAlpha(gameWindow) 
        local newAlpha = currentAlpha + 4 
        if newAlpha > 255 then newAlpha = 255 end 
        guiSetAlpha(gameWindow,newAlpha) 
        if newAlpha ~= 255 then 
            setTimer(openMenu,50,1) 
        end 
    end 
end 
bindKey("m","down",openMenu) 

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