NotAvailable Posted May 30, 2011 Posted May 30, 2011 Hi, i want to create a fading window when u press F6. I tried to script it several times but it didnt worked Does someone know how to create that? Regards, Jesseunit
NotAvailable Posted May 31, 2011 Author Posted May 31, 2011 guiSetAlpha setTimer bindKey Yeh i did this: setTimer(guiSetAlpha, 2000, 1, infoWindow, 255) EDIT: It worked, but it didnd fade
karlis Posted May 31, 2011 Posted May 31, 2011 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
Moderators Citizen Posted June 3, 2011 Moderators Posted June 3, 2011 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
NotAvailable Posted June 7, 2011 Author Posted June 7, 2011 Thanks for the help all! now i know how to create fading windows
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now