Programming Art, LLC
   
Products Web Services Free stuff Forums
SEARCH
   
SOFTWARE
100% Satisfaction Guarantee
Credit Cards Accepted
Programming Art's Tutorials

Director
Director Single Frame Animations
You've probably created animations in Director by laying out graphics in the score and then letting the playback head move from frame to frame creating animation. This works fine for animations that can be the same thing everytime, but if you find yourself needing to create dynamic animations at runtime, you'll probably want to learn about single-frame animations. The idea is to make the playback head "spin" on a single frame and then control things dynamically with Lingo. If you have something to contribute [or contest], please post your ideas to the forums.

Check out the very ninja-like source movie with this example to get an even closer look at single frame animations. Good luck!

Download the FREE Director source movie here! [Director 8.0, 188Kb]

To make the playback head stay on one frame, create a frame script with a "go to the frame" line like the following:

on exitFrame
 global gAnimationObject

   gAnimationObject.AdvanceAnimFrame()
   go to the frame
end


To help manage the task of animating on a single frame, I created an animation object which allows me to specify each "snapshot" of animation and play it back as I wish. The object looks like this:

property myMemberList, myLocList, mySpriteList

on new me
   me.myMemberList = []
   me.myLocList = []
   me.mySpriteList = []
   return me
end

on AddAnimFrame me, aMember, aLoc, aSprite

   set anError = 0
   --check for valid member
   if (aMember.number ‹= 0) then
      set anError = -1
   end if
   --check for a point object
   if (aLoc.objectP = FALSE) then
      set anError = -2
   end if
   --check for an integer greater than 0
   if (aSprite ‹= 0) or (aSprite.integerP = FALSE) then
      set anError = -2
   end if

   --store frame of animation in object
   if (anError = 0) then
      me.myMemberList.add(aMember)
      me.myLocList.add(aLoc)
      me.mySpriteList.add(aSprite)
   end if

   --return error code
   return anError
end

on AdvanceAnimFrame me
   set anError = 0
   --if there is nothing to advance, set the error code, otherwise advance the animation frame
   if (me.myMemberList.count = 0) then
      set anError = -1
   else
      if the member of sprite me.mySpriteList.getAt(1) <> me.myMemberList.getAt(1) then
         set the member of sprite me.mySpriteList.getAt(1) = me.myMemberList.getAt(1)
      end if
      set the loc of sprite me.mySpriteList.getAt(1) = me.myLocList.getAt(1)
      updatestage
      me.mySpriteList.deleteAt(1)
      me.myMemberList.deleteAt(1)
      me.myLocList.deleteAt(1)
   end if
   --return error code
   return anError
end

on ClearAll me
   me.myMemberList = []
   me.myLocList = []
   me.mySpriteList = []
   return 0
end

on GetSize me
   return me.myMemberList.count
end


So, to add to my animation, I simply provide my animation object with a series of members, locs, and sprite numbers. They are stored in the object and then I can advance my animation as I wish. Check out the source movie to get a closer look with a couple example animations. The source file is for Director 8.0.

Good luck!

Your Shopping Cart
$
Item(s)
CHECKOUT NOW