Starkz Posted January 16, 2014 Share Posted January 16, 2014 Is there a way to make the music gradually lower when it ends? and another How I can do to make an image appear gradually from transparent to visible? I think in both cases can be done with some kind of timer, but I'm really new to LUA. Link to comment
Castillo Posted January 16, 2014 Share Posted January 16, 2014 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
Starkz Posted January 16, 2014 Author Share Posted January 16, 2014 Ty, and with the music, is there any way? Link to comment
Castillo Posted January 16, 2014 Share Posted January 16, 2014 I guess you can use getSoundPosition. Link to comment
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