JoC #23: Animating the image

      A positive attitude may not solve all your problems,
      but it will annoy enough people to make it worth the effort.
            — attributed to Herman Oliver Albright

A last little bit before we leave our coloured circles behind: an animation. In this case, it’s a very simple one: fading out the circles. But it shows an important technique: The appearance of an actor can change all the time, if we want to. This is the basis for many visual effects.

And, we finally see an if-statement with an else clause! I can’t believe that it took this long for this to pop up.

Download video

Concepts discussedtransparency, dynamically changing images, if-statement

6 thoughts on “JoC #23: Animating the image

  1. Is there a setColor bug? Instead of having the ball fade out, I wanted to have it get brighter and then disappear. My poking and prodding leads me to believe transparency always starts at 255.

  2. Actually, I’m rethinking this, so I should just go with the symptom. In changeTransparency, if I change
    if (alpha > 0) -> decrease transparency
    if (alpha increase transparency
    then the image is instantly removed. Using the debugger, it consistently says alpha = 255.
    The debugger reports transparency = 255 elsewhere, also.
    Any hints on how to figure out?

  3. Where the transparency starts depends on how you create the color object.

    There is a Color constructor with four parameters: (r, g, b, alpha). If you use this, the transparency will be set to whatever you specify.

    There is another constructor with three parameters: (r, g, b). No alpha. In that case, the color is solid (opaque). That means that the transparency (alpha) value is 255. That’s the default for all colours that don’t specify an alpha value.

    It’s very unlikely that there is a bug in this. If it doesn’t do what you expect, the bug is more likely in your code, or it’s a misunderstanding of how things should work.

  4. Pingback: JOC#23: Image Animation -

Leave a Reply

Your email address will not be published. Required fields are marked *