Frame-based animation

Malte Brill revolution at derbrill.de
Sat Feb 11 13:31:18 EST 2012


Hi Richard,

here is a bareBone frame based handler... Very crude, nothing special. I assume for starters this is in a button. You will want to do adjustments.

Cheers,

Malte


local sStartTime,sCurrentFrame
on mouseUp
   set the flag of me to not the flag of me
   
   if the flag of me then 
      put the milliseconds into sStartTime
      put 0 into sCurrentFrame
      doAnimation
   else
      repeat for each line theLine in the pendingMessages
         if "doAnimation" is in theLine then cancel item 1 of theLine
      end repeat
   end if
   
end mouseUp

command doanimation
   lock screen
   -- assuming a frameRate of 25
   local tElapsed
   put the millisecs into tElapsed
   put sCurrentFrame + 1 into sCurrentFrame
   put sCurrentFrame
   put the millisecs - tElapsed into tElapsed
   switch sCurrentFrame
      case 1
         hide me
         break
      case 100
         show me
         break
   end switch
   unlock screen
   if the flag of me then
      if tElapsed >=40 then
         doAnimation
         -- want to check for adjusting the timing maybe...
      else
         send "doAnimation" to me in 40 - tElapsed millisecs
      end if
   end if
   
end doanimation



More information about the use-livecode mailing list