2 Replies Latest reply on Nov 9, 2006 2:08 PM by Applied CD

    Smoother animation?

    Applied CD Level 1
      I’ve got a background bitmap that needs to gently shift up and down in a loop. The movement is very subtle and slow … 10 pixels over 100 frames @ 30 fps. The problem is that Director doesn’t appear to tween fractional pixels, so what I see is a somewhat undesirable “stepping motion” where the background moves 1 pixel, waits 10 frames until the tween rounds up to the next whole pixel, then moves another pixel, and so on. Does anyone have a trick for smoothing out “micro” animation of this sort?
        • 1. Re: Smoother animation?
          duckets Level 1

          I've got a behaviour which can make sprites move fractionally between pixels like this, but it's fairly processor intensive (uses copypixels on a multiplied up version of the image) so I'm not sure how fast it would perform on a large background image.

          Here it is:

          It's just one behaviour which you place on a sprite, and once it's on you have to set the sprite's position using a 'setLoc()' command, with a floating point 'point', like this:

          spriteRef.setLoc( point(10.3,21.9) )

          More details are in the behaviour comments.
          Hope this helps!

          - Ben
          • 2. Re: Smoother animation?
            Applied CD Level 1
            Thanks Ben, that worked well … one extra step was all it needed to make the motion much smoother. I had some trouble with the portion of the script that tests for an existing cast member, I found I could remove the test without any ill effects. You dispose of the cast member at the end of the script anyway.

            tMem was never void, it returned “member -1 castlib 1” if the member didn’t exist. But since it’s deleted at the end of the script it never should exist before this point.

            -- create a temp cast member to use, so we don't damage the original
            tempName = "temp subpixel image for "&my&" frame "&the frame
            -- tMem = member(tempName)
            -- if voidP(tMem) then
            tMem = new(#bitmap)
            tMem.name = tempName
            -- end if

            my.member = tMem