How do I make fade out?

gawakamygawakamy Member Posts: 109
Hi, Salad developers.
I am developing an app and have run into a problem. I have tried to make fade in and out. Finally, I found out how to make fade in from Cave Adventure. It showed me how to make fade in. However, I can not figure out how to make fade out. There was an solution in Cookbook Q&A, but it dosen't work. Can somebody show me how to do it please?
Thanks, all :D
«1

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    interpolate self.color.alpha to 0
  • CloudsClouds Member Posts: 1,599
    edited February 2012
    @JohnPapiomitis & @gawakamy

    To fade to black interpolate your image's alpha to -0.2
    To fade up from black interpolate your image's alpha to 1.2

    I know -0.2 and 1.2 don't actually exist when it comes to alpha channels, but doing this (as opposed to 0 and 1) solves the little jump Gamesalad has at the end of it's fades (when fading both images and audio).
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    @Tynan
    You are a freaking machine! How did you figure out using -0.2 and 1.2 for fades? Do you come from the future? (If yes, can you tell us when GameSalad becomes sentient? And if/when they change their name to Skynet? Does anyone actually survive past 2029?)
  • SlickZeroSlickZero Houston, TexasMember, Sous Chef Posts: 2,870
    Tynan comes from Narnia. Mystical and adventurous.

    If you have a lot of onscreen images and stuff, it may just be easier to have a solid black image that you interpolate the alpha from 0 to 1 over the whole screen.
  • CloudsClouds Member Posts: 1,599
    @SlickZero

    "Tynan comes from Narnia. Mystical and adventurous."

    . . . and I sleep in a wardrobe.

    "If you have a lot of onscreen images and stuff, it may just be easier to have a solid black image that you interpolate the alpha from 0 to 1 over the whole screen."

    No !!! : )

    Interpolate the solid black image's alpha between -0.2 and 1.2 otherwise you will get the little glitch ruining a nice smooth fade !!
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    @ Tynan

    When you see the interpolate glitch, is it set to linear? Or do you have in on ease out.
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    Ah, that god damn interpolate glitch... Interpolate is my favourite function, but yeah, the stuttery fades do take away from the polish of a game. Nice workaround.

    Ace
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    edited February 2012
    @JohnPapiomitis - It's not the ease out function that snaps the last part, it just does it anyway when interpolating numbers on both linear and ease out.

    Ace

    Edit. I just tested your method @Tynan and it works great.
  • CloudsClouds Member Posts: 1,599
    edited February 2012
    @RThurman

    "You are a freaking machine! How did you figure out using -0.2 and 1.2 for fades?"

    It started out as an audio issue, I could hear the annoying volume jump you get towards the end of a volume fade when you interpolate the volume from 0 to 1.

    So I made a constant volume looped square-wave played it in gamesalad, recorded the audio output of Gamesalad and took a look at the waveform in Logic . . . and there it was, an obvious and sudden jump in the waveform . . so back to Gamesalad, try a few things, went from 0 to 2 (instead of 0 to 1) to see if it was a bit-depth/quantisation thing . . . and it was completely gone ! No glitch ! . . . So I kept backing off the volume to see how close I could get to 1 without the glitch . . . . and 1.2 was the nearest I could get.

    I concluded it was an issue with the interpolate behaviour.

    So I tried interpolate to move a 1x1 pixel actor left to right across 500 pixels - as it moved it spawned another 1x1 pixel - and moved up by 1 pixel (but using move and not interpolate) . . . . if the problem was there you would see a 45 degree line going bottom left to top right with a little jump in the angle at the end . . . . there was nothing.

    But when I noticed that using interpolate on an alpha channel to do a fade up or down had a similar glitch at the end I tried the -0.2 to 1.2 trick and it completely solved it.

    Conclusion, there is a problem with interpolate when interpolating across a value below 1.


    ?Do you come from the future? (If yes, can you tell us when GameSalad becomes sentient? And if/when they change their name to Skynet? Does anyone actually survive past 2029?)"

    I come from a far off future place called Tuesday, GameSalad becomes sentient a few days after it implements tables that you can write to, it takes over the internet around 60 days later and after a brief fight with Youtube destroys the earth in 2016.
  • CloudsClouds Member Posts: 1,599
    edited February 2012
    @JohnPapiomitis

    "When you see the interpolate glitch, is it set to linear? Or do you have in on ease out."

    It happens in all combinations, linear, ease in, ease out and ease in & ease out - and happens for both audio volumes and alpha channels - going up and going down - basically when interpolating any value of 1 or less, so even though it's probably present when moving an actor you probably can't detect it as a move on an actor tends to be more than 1 pixel.
  • CloudsClouds Member Posts: 1,599
    @mynameisace

    "Edit. I just tested your method @Tynan and it works great."

    Ace, I want 20% of all profits from fades used in your applications for the next 200 years and you must include my name in the title of your applications.
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    edited February 2012
    I already add your name in to my game names... I thought you knew that... You just ignore me. I try and I try to make you love me, but your heart is blacker than the blackest polar bear... Just you wait until Valentine's Day... You'll love me then... You WILL love me then!

    Ace
    xxxxx
  • CloudsClouds Member Posts: 1,599
    edited February 2012
    "I already add your name in to my game names... I thought you knew that... You just ignore me."

    Like I said last time, I need my name in gold embossed 3D type, and it needs to be rotating (on a per character basis) at no less than 20 rpm, it's simply not enough just to thrown my name into your title like it was a dirty rag, I found your Angry Bird's rip-off particularly insulting (Tynan's Angry Turds™).

    "I try and I try to make you love me, but your heart is blacker than the blackest polar bear... Just you wait until Valentine's Day... You'll love me then!"

    If you breach the restraining order, or the 300 metre rule the judge granted I will have you sent back to the 'special hospital'. And that 301 metre long stick with the glove on the end that you used to touch me with . . . . that won't be tolerated again (although I have found your watch, needs a clean though).
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2012
    =)) You're a card, Tynan! Neat workaround, by the way...

    This glitch with interpolate has been with us in more than 3 betas, I'm certain. :-( And I'm sure I remember a time when there were smooth fade ins and outs ages ago.

    It puzzles me why GS HQ can't fix the problem beta after beta; I'm guessing it's simply a matter of adjusting an algorithm, maybe even referring back to a previous beta when it did work; that'd surely take no more than ten minutes?


    ----------------------------------------------
    http://davidgriffinapps.co.uk/

    iPad: End of the Earth game coming soon to the iTunes App Store....

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • SlickZeroSlickZero Houston, TexasMember, Sous Chef Posts: 2,870
  • CloudsClouds Member Posts: 1,599
    edited February 2012
    @JohnPapiomitis

    "When you see the interpolate glitch, is it set to linear? Or do you have in on ease out."

    Actually just checked, using ease in / ease out actually makes the glitch more pronounced - I managed to extract some graphs from Gamesalad that show the glitch in it's full horror, the graphs also explain why interpolating to 1.2 get's rid of the problem, I can post them up here if anyone is interested.
  • LumpAppsLumpApps Member Posts: 2,881
    Great tip Tynan! You rock! (or another music style of your choice)
  • CloudsClouds Member Posts: 1,599
    @LudwigHeijden

    Medium to bad late 1980s middle of the road Soft Rock (sleeves rolled up on my jacket + unnecessarily tight trousers).
  • CloudsClouds Member Posts: 1,599
    edited February 2012
    Tests show the following.

    You can get a fade on both an alpha channel and audio volume to function exactly as it should, glitch free, by doing the following:

    Interpolate to 1.2 and make the length of your fade 120% of what you need.

    So - for example - if you want to your music to fade from 0 to 1 over five seconds simply interpolate the volume from 0 to 1.2 over 6 seconds (which will give you to correct glitch free 5 second result).

    Here is what Gamesalad is doing towards the end of it's interpolation function when interpolating between 0 and 1, notice that basically everything after 0.9 is ignored and it just jumps to a value of 1 after 0.9.

    image
  • Fabri DamazioFabri Damazio Member Posts: 97
    Talking about performance, which is better?

    - Interpolate or
    - Timer decreasing the alpha

    ?
  • LumpAppsLumpApps Member Posts: 2,881
    @tynan: then your voice must be as high pitched as mine ;)
  • CloudsClouds Member Posts: 1,599
    edited February 2012
    @LudwigHeijden

    "then your voice must be as high pitched as mine "

    Once I get my safari shorts off I drop down to a low baritone.
  • CloudsClouds Member Posts: 1,599
    edited February 2012
    @NeoGeekStudios

    Talking about performance, which is better?
    - Interpolate or
    - Timer decreasing the alpha



    I'd put my money on the internal clock (time) being less of a performance strain, although I suspect Interpolate might reference the internal clock ? Not too sure to be honest, let us know what you find.


  • LuckyLurcherLuckyLurcher Member Posts: 343
    Thanks for the Interpolate info, Tynan. That has helped with my current project.
  • gawakamygawakamy Member Posts: 109
    Hi, GS dudes.
    Finally, I figured out it. Wow, I have not realized so many people commented to help.
    Thanks all. Big fortune with you :D
  • CloudsClouds Member Posts: 1,599
    edited February 2012
    A further correction on this interpolate bug (might be some use to someone out there).

    The glitch takes place in the last 0.1 of any interpolation process, the interpolation value doesn't have to be below 1 to display the glitch, it's just when you are going from 0 to 1 then having the last 10% of your interpolation chopped off is much more noticeable than having the last 0.1% of a hundred pixel movement (less than a pixel) chopped off.

    [EDIT] So it's the last 0.1 of any interpolation value, not just 0 to 1.
  • Rob2Rob2 Member Posts: 2,402
    This was a great discovery but I have found the jump is just the last .1 (literally) of any value. So if you were to interpolate a real attribute from 0 to .1 over ten seconds say it would happen instantly !!
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2012
    Hey @Rob, do you mean Interpolate is a time machine?! Cool!!

    @Tynan, excellent interp. investigation. (You're medal is in in the post ;-) :-) )

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • CloudsClouds Member Posts: 1,599
    edited February 2012
    @Rob2
    "This was a great discovery but I have found the jump is just the last .1 (literally) of any value. So if you were to interpolate a real attribute from 0 to .1 over ten seconds say it would happen instantly !!"

    Whoops, sorry, yes that's what I meant to say, the glitch takes place in the last 0.1 of any interpolation value - (not in the last 0.1 seconds).
  • CloudsClouds Member Posts: 1,599
    edited February 2012
    @gyroscope

    "excellent interp. investigation. (You're medal is in in the post)"

    I accept only 8 bit PNGs.
Sign In or Register to comment.