Say I want, in code, pause the playback of a sprite animation at frame 11. Hold for a while, then rewind 3 frames, at a set frame rate, then pause again, then move forward 1 frame, pause... etc.. that sort of things. Is it possible in SpriteManager 2?
I believe so but you could ask Brady. firstname.lastname@example.org
I use both SpriteManger2 and EZGui and highly recommended them.
Here's a relevant snippet from the documentation:
Playing Animations There are several ways to play animations on a sprite. You can play them by name, by index, or by reference. The fastest method is by reference, and a close second is by index. However, most of the examples you will find in this documentation will use the name method because it is easier to read and simpler to understand.
There are two main method categories which will play an animation: PlayAnim() and DoAnim(). The difference between these two is that PlayAnim(), anytime it is called, will re-start the animation at the first frame (or frame specified). DoAnim(), on the other hand, will only start an animation if that same animation is not already running. It is therefore a good idea to use DoAnim() in places where you just know that a certain animation ought to be running if it isn't already but don't want to have to check first. Use PlayAnim() in places where you know the animation should always start over, or start from a particular frame.
Both PlayAnim() and DoAnim() have versions which accept the animation's name, index, or reference as arguments. Some examples of these are shown below ("sprite" in the code below, is assumed to reference a Sprite or PackedSprite script).
// Play "walk" animation: sprite.PlayAnim("walk");
// Play "walk" animation if it isn't playing already: sprite.DoAnim("walk");
// Play the animation at index 3: sprite.PlayAnim(3);
// Play the animation referenced in the variable walkAnim: sprite.DoAnim(walkAnim);
In addition to these, the PackedSprite class also has versions of each which also accept an additional frame number argument. This second argument is the 0-based index of the desired frame on which the animation should start playing. Some examples: NOTE: These versions are only available on PackedSprites
// Play "walk" animation, starting at frame 3: sprite.PlayAnim("walk", 3);
// Play animation at index 2, starting with frame 1: sprite.DoAnim(2, 1);
// Play animation referenced by walkAnim, starting with frame 5: sprite.PlayAnim(walkAnim, 5); Stopping and Pausing
You may also stop and pause playback of an animation using the StopAnim() and PauseAnim() methods, and can unpause using UnpauseAnim():
// Pause playback of the current animation: sprite.PauseAnim();
// Resume playback: sprite.UnpauseAnim();
// Stop the animation entirely: sprite.StopAnim();
Posing You may have a sprite that instead of, or in addition to, using animation, it uses a series of "poses" depending on its state. An example would be an overhead view of an airplane that shows the airplane at various angles of banking depending on how steep the player is turning. For situations like this, you wouldn't want to play an animation but you can't get by with only one static frame either. In this situation you can use multiple, single-frame animations and simply "play" each animation that is needed for the particular pose. This will effectively change the frame being displayed. Alternatively, you can store the entire range of "poses" in a single animation, and simply play the animation starting at a specific frame, and then immediately pause the animation, like so:
// Frame 4 contains our desired "pose": sprite.PlayAnim("Poses", 4);
// Immediately pause here: sprite.PauseAnim();
answered Mar 15 '11 at 10:44 PM
Yes. There is a version of PlayAnimInReverse() which accepts, as its second argument, the frame at which to start playing. So you can pause playback at any desired point, and then when you decide to go in reverse, can use PlayAnimInReverse() to start playing backwards at the frame where you paused.
answered Mar 16 '11 at 08:58 PM