ANIMATION DOLPHINS
The aim of this article is to show how to play a serie of bitmaps at the location of the mouse cursor when the user clicks. In order to do this, we are going to use the concepts of global list, behavior and message parsing.
Firstly, we need a serie of bitmaps representing a complete animation. To create a nice effect, the first and last bitmaps must be empty. Below, an animation of 31 bitmaps of a dolphin once imported in the cast.
|
The Lingo scripting is relatively easy, there are only three scripts :
Here is the detail of the three scripts :
on startmovie
end |
|
on exitFrame
end |
|
-- Behavior to manage a sprite animation global free_sprites property mysp, mymax, mycurrent, myletter, mystart on beginsprite me
end
on exitframe me
end
on start me, newloc
end |
Finally, we must place the sprites on the stage, take care to put the first member of the serie (d0) as it will not be visible (empty bitmap). Then choose the transparent background and attach the behavior to the sprite. Copy-Paste the sprite several times, the number of sprites should be the number of bitmaps of the animation + 1 (ie. d0 .... d30 --> 32 sprites) in order to always have at least one free sprite in the free_sprites list. |
On the left, the result as a Shockwave movie. Click on it to see the dolphins jumping out. |
As a conclusion, it could be nice to transform this script in order to re-use it easily. For that, we should setup the variables mymax et myletter by putting them into a on getpropertydescriptionlist handler. It is then possible to manage several animations by using several global lists.
The compressed Director file (.ZIP 20kb) is here.
If you encounter any trouble during the implementation or if you have done something cool with this technique, I'm available here.