Animation library

Trevor DeVore lists at mangomultimedia.com
Mon Aug 2 12:51:14 EDT 2004


On Aug 2, 2004, at 7:31 AM, Troy Rollins wrote:
> On Aug 2, 2004, at 7:45 AM, Kevin Miller wrote:
>
>> It is now open source.  All that is happening is that we're not 
>> supporting
>> it ourselves.  We'll post it soon.  We're not abandoning doing 
>> animation in
>> Rev, just saying that there are better ways to do it, such as using 
>> the
>> Player object.  Look out for further improvements related to this 
>> area in
>> later releases.
>
> Hey, that's great - both the open sourcing of the current, and the 
> fact that RunRev is looking to make a better system.
>
> FWIW - The specific "type" of animation I am referring to is more in 
> the line of "interface animation." e.g. a panel of controls slides 
> onto the screen, and each control fades up one after the other, after 
> which the default control pulses... that sort of thing.

Troy,

Maybe this isn't exactly what you are after but I have used the 
following handlers for interface animation.  I dynamically create the 
controls from a db in a group and then call the following to ease it 
onto the screen.  I've found that scripted animation works very well in 
Revolution.  If you want to see some really cool stuff track down some 
of samples that Scott Rossi has done.

Here is an example of using the libAnim_Ease function taken from my 
code:

libAnim_Ease id of group (pTarget & i), owner of group (pTarget & i), \
         item 1 of loc of group (pTarget & i), tOffsetLeft + (width of 
group (pTarget & i) / 2), \
         item 2 of loc of group (pTarget & i), item 2 of loc of group 
(pTarget & i), \
         false, 10, 10

If you set pWithMsgs to "true" then make sure you have the following 
messages in the message path:

libAnim_Finished
libAnim_Update


-- 
Trevor DeVore
Blue Mango Multimedia
trevor at mangomultimedia.com




/**
  * Performs the ease animation on an object
  *
  * @param pObjID    objID      ID of the object to animate
  * @param pOwner    obj        Owner of the object to animate
  * @param pStartX   integer    Starting x position
  * @param pEndX     integer    Ending x position
  * @param pStartY   integer    Starting y position
  * @param pEndY     integer    Ending y position
  * @param pWithMsgs boolean    Whether to send updates to object on 
updates and finishing.
  * @param pSpeed    integer    Speed of animation in milliseconds.  How 
often message is sent.
  * @param pNumSteps integer    Number of steps to do the animation in
  */
on libAnim_Ease pObjID, pOwner, pStartX, pEndX, pStartY, pEndY, 
pWithMsgs, pSpeed, pNumsteps
   local tTarget

   put "control id " & pObjID & " of " & pOwner into tTarget

   set the libAnim["uCurrentStep"] of tTarget to 1
   set the libAnim["uNumSteps"] of tTarget to pNumsteps
   set the libAnim["uStepSizeX"] of tTarget to (pEndX - pStartX) / 
pNumSteps
   set the libAnim["uStepSizeY"] of tTarget to (pEndY - pStartY) / 
pNumSteps
   set the libAnim["uStepAngle"] of tTarget to 2 * pi / pNumSteps
   set the libAnim["uSendMessages"] of tTarget to pWithMsgs
   set loc of tTarget to pStartX, pStartY

   # Start animation
   libAnim_CosineInterpolation pObjID, pOwner, pSpeed
end libAnim_Ease


/**
  * Animates an object using cosine interpolation
  *
  * @param pObj   objID    ID of control to animate
  * @param pOwner obj      Owner of the object (long owner)
  * @param pSpeed integer  How often to resend the message in 
milliseconds.
  */
on libAnim_CosineInterpolation pObjID, pObjOwner pSpeed
   local tVelocityScale
   local tTarget

   put "control id " & pObjID & " of " & pObjOwner into tTarget

   put 1 - \
       cos (the libAnim["uCurrentStep"] of tTarget * the 
libAnim["uStepAngle"] of tTarget) \
       into tVelocityScale
   put item 1 of loc of tTarget into tX
   put item 2 of loc of tTarget into tY
   set loc of tTarget to (tX + (tVelocityScale * the 
libAnim["uStepSizeX"] of tTarget), \
       tY + (tVelocityScale * the libAnim["uStepSizeY"] of tTarget))
   set the libAnim["uCurrentStep"] of tTarget to the 
libAnim["uCurrentStep"] of tTarget + 1
   if (the libAnim["uCurrentStep"] of tTarget <= the 
libAnim["uNumSteps"] of tTarget) then
     send "libAnim_CosineInterpolation" && pObjID &","& pObjOwner & "," 
& pSpeed to me in pSpeed milliseconds
   else
     if (the libAnim["uSendMessages"] of tTarget = true) then
       send "libAnim_Finished" to tTarget
     end if
   end if
end libAnim_CosineInterpolation



More information about the use-livecode mailing list