Jump to content

[HELP]How to create fading window


Recommended Posts

how it could fade, if alpha keeps being same?

  
local alpha=255 
local fadetime=3000 --3sec 
local timesasec=20 --how much times in sec to change it 
setTimer(function() 
  alpha=alpha-255/(1000/timesasec) 
  guiSetAlpha(myWindow,alpha) 
end,1000/timesasec,fadetime/1000*timesasec) 
  

edit: heres more efficent version

  
function fadeGUI(theGUI,time,fadeIn) --time in ms, fadeIn:false to fade out 
  local toAlpha=fadeIn and 255 or 0 
  local currAlpha=guiGetAlpha(theGUI) 
  local currTicks=getTickCount() 
  local offsetAlpha=toAlpha-currAlpha 
  local func=function() 
    local progress=math.min(1,(getTickCount()-currTicks)/time) 
    guiSetAlpha(theGUI,currAlpha+progress*offsetAlpha) 
    if progress==1 then 
      removeEventHandler("onClientRender",root,func) 
    end 
  end 
  addEventHandler("onClientRender",root,func) 
end 
  

Link to comment
  • Moderators

or this:

setTimer(addAlpha, 50, 80, infoWindow) -- 0 => 255 in 4 sec ( 50*80 = 4000 ms = 4 sec ) 
  
function addAlpha( element ) 
    local alpha = guiGetAlpha( element ) 
    guiSetAlpha( element, alpha+(255/80) ) 
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...