Page 1 of 1

cant script a fade out

Posted: Sat Feb 15, 2014 6:23 am
by Raz___
So basically in my MessageEvent() I have it select a video based on text input(this part works fine) but then I want it to fade out at the end(or at the very least stay up for a set time then cut out) here is what I have

import time
#selects video, this part works
time.sleep(7)
opac = 0.0 #this stands for opacity
for i in range(0, 10):
time.sleep(.1)
modul8.setValue('ctrl_layer_alpha, opac, 1)
opac -= .1

the problem I am running into is it does not effect anything on the screen until the entire script has finished running, so that after the message call it waits about 8 seconds then displays a completely faded layer never showing what I want. I would be happy with just playing the video and then a hard cut after the length of time, but it wont do that.

Does anyone know whats wrong with my code or can think of another way of doing this?

Re: cant script a fade out

Posted: Sat Feb 15, 2014 7:45 pm
by anomad
. iirc, the modul8 engine is deterministic (so everything runs as fast as it can, whenever it can... anyone feel free to correct me on this )

. for time based items, i use PeriodicalEvent()

. so, in Init() declare a variable, ie,

Code: Select all

      fadeOutConter = 1.0


. in PeriodicalEvent() have some code similar to

Code: Select all

if fadeOutCounter > 0 :
     fadeOutCounter -= 0.05   ## change this number to speed up/slow down how fast things happen
     modul8.setValue('ctrl_layer_alpha, fadeOutCounter, 1)



. then, in MessageEvent, whenever the button is clicked (or whatever), reset fadeOutCounter to equal 1.0

. hope that helps :)

-james
(a nomad. )

Re: cant script a fade out

Posted: Mon Feb 17, 2014 4:42 am
by Raz___
Great wonderful that worked perfectly thank you so much, I had started to get really worried that I would never be able to finish this installation.