SpriteAnimateJustAFewTimes Method |
Start a new animation. It will complete the animation the number of times you specify.
For example, if your sprite is walking, and one animation is one step, specifying 4 here
will result in your sprite taking 4 steps and then the animation stops. You will want
to make sure you are checking for when the animation stops, using the
SpriteAnimationComplete event,
checking the
AnimationDone flag.
Namespace:
SpriteLibrary
Assembly:
SpriteLibrary (in SpriteLibrary.dll) Version: 1.0.0.6 (1.0.0.6)
Syntaxpublic void AnimateJustAFewTimes(
int WhichAnimation,
int HowManyAnimations,
int AnimationFrameToEndOn = -1
)
Parameters
- WhichAnimation
- Type: SystemInt32
The animation index you want to use - HowManyAnimations
- Type: SystemInt32
The number of animations to do before it stops - AnimationFrameToEndOn (Optional)
- Type: SystemInt32
Once the animation has finished, display this animation frame.
-1, or any number that is not an actual frame, will show the last frame of the animation.
Examples
This code creates a new dragon, puts him on the screen, points him a direction, and tells him to
move. Finally, it tells it to cycle through a few animations.
Sprite NewSprite = MySpriteController.DuplicateSprite("Dragon");
NewSprite.AutomaticallyMoves = true;
NewSprite.SetSpriteDirectionDegrees(90);
NewSprite.PutBaseImageLocation(new Point(startx, starty));
NewSprite.MovementSpeed = speed;
NewSprite.AnimateJustAFewTimes(0,3);
See Also