AnimationChain
Introduction
AnimationChains represent a series of AnimationFrames which can be used to animate objects which implement the IAnimationChainAnimatable interface such as Sprites. AnimationChains can be created in code, or they can be created using the AnimationEditor. The AnimationEditor is installed when running the FlatRedBall installer which can be found on the downloads page. The IAnimationChainAnimatable page has more information on how to use AnimationChains, so please check it out after finishing up this page.
Namespace
The following statement will help reduce code when working with AnimationChains.
Creating AnimationChains
AnimationChains can be created manually by creating the frames individually through code, by loading a .achx file, or through the content pipeline.
Creating AnimationChains in Code
Notice that the .1f is the frame length in seconds. For from-file and content pipeline loading, see the AnimationChainList wiki entry.
Note: The AnimationFrame class is used to define individual frames in an AnimationChain. For more information on how to modify your animations, including how to create animations by using parts of a single Texture, see the AnimationFrame page.
Loading an AnimationChainList from file
For information on loading an AnimationChainList from a .achx file, see this page.
Accessing AnimationFrames
AnimationChains are also Lists of AnimationFrames. Therefore the AnimationChain provides the same interface as a list for accessing frames, such as indexing ( [index] ), properties like Count, and methods like Add. For example, the following code can be used to change the referenced texture of all frames in an animation chain to NewTexture :
AnimationChain Members
Related Classes
FlatRedBall.Graphics.Animation.AnimationFrame - AnimationChains represent a list of AnimationFrames. When an AnimationChain is applied to an object, the object flips through and uses the AnimationFrames to modify its appearance.
FlatRedBall.Graphics.Animation.AnimationChainList - AnimationChainLists are lists of AnimationChains. Objects such as Sprites store AnimationChainLists, simplifying the process of setting which AnimationChain is currently used.
FlatRedBall.Content.AnimationChain.AnimationChainListSave - The "save" file for AnimationChainList files. This can be saved to and loaded from .achx files, and can also be converted to and from AnimationChainLists. For more information, see the FlatRedBall File Types wiki entry.
FlatRedBall.Graphics.Animation.IAnimationChainAnimatable - The interface that defines properties and members for objects which can be animated by AnimationChains. See this article for information on how to set animations on objects such as Sprites.
Additional Information
FlatRedBall.Sprite.PixelSize - PixelSize can be used to reactively set scale based off of a changed Texture resulting from playing an AnimationChain.
Did this article leave any questions unanswered? Post any question in our forums for a rapid response.
Last updated