|Top Previous Next|
DPSF provides an Animations class that may be used to easily store the texture coordinates of separate images stored within a single texture. NOTE: Because the particle systems only store a single texture, all of the frames of an animation must stored in a single texture (image file). This method is used over storing each frame in a separate texture because texture swapping is very expensive.
The Animations class uses two central concepts: a Picture and an Animation. A Picture can be thought of as a frame of the animation, except that it can be used in multiple spots throughout the Animation. An Animation is simply a sequence of Pictures used to make up the animation.
Pictures can be created using the CreatePicture() function, where you supply the texture coordinates of the texture that should be used for the picture's image. If the images are arranged in a nice grid fashion in the texture, you can use the CreatePicturesFromTileSet() function to easily create all of the pictures to use in the animation. So each Picture that you create will have a unique ID, and will hold the texture coordinates that should be used to display that picture.
Animations can be created using the CreateAnimation() function, where you supply the sequence of Picture IDs that should make up the animation. You must also supply how long of a pause there should be (in seconds) between switching pictures, so the shorter the pause between switching pictures the faster the animation will be played. The same delay is used for switching between all pictures; if you want one picture to be shown longer than the others, then put it in the picture sequence twice in a row. The last parameter that you must supply is how many times the animation should play before stopping. If this is set to one the animation will play only once, two will make it loop and play twice, etc. Setting this to zero will cause the animation to loop forever and never stop playing. Each Animation created is assigned a unique ID, and you may specify which animation should play by setting the CurrentAnimationID.
For specific information on the class functions and properties see the DPSF API Documentation.