cant script a fade out
  • Raz___
    junior Member
    Posts: 7
    Joined: Sun May 05, 2013 2:46 am

    cant script a fade out

    by Raz___ » Sat Feb 15, 2014 6:23 am

    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?
  • anomad
    master
    Posts: 412
    Joined: Sun Oct 21, 2007 10:07 pm
    Location: north cakalacky, usa
    Contact:

    Re: cant script a fade out

    by anomad » Sat Feb 15, 2014 7:45 pm

    . 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. )
  • Raz___
    junior Member
    Posts: 7
    Joined: Sun May 05, 2013 2:46 am

    Re: cant script a fade out

    by Raz___ » Mon Feb 17, 2014 4:42 am

    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.

Who is online

Users browsing this forum: No registered users and 20 guests