DPSF by Daniel Schroeder

<PackageReference Include="DPSF" Version="2.5.0" />

.NET API 168,448 bytes

 Animations

public class Animations
Class to hold a List of Animations and the texture coordintes of the Pictures used by the Animations. To start, Create Picture's of all images that will be used in any Animations. Then Create an Animation by specifying the order of the Picture IDs to go through, and the speed to flip through them at (i.e. frame-rate).
public int CurrentAnimationID { get; set; }

Get / Set the Current Animation being used. The Animation is started at its beginning.

NOTE: If an invalid Animiation ID is given when Setting, the Animation will not be changed.

NOTE: If an Animation has not beeng set yet when Getting, -1 is returned.

public bool CurrentAnimationIsDonePlaying { get; }

Get if the Current Animation is Done Playing or not (i.e. Its Number Of Times Played is greater than or equal to its Number Of Times To Play). Returns true even if no Animation has been set to Play yet.

public int CurrentAnimationsNumberOfTimesPlayed { get; set; }

Get / Set the Number of times the Current Animation has Played already.

NOTE: If no Animation has been set yet, Get returns -1, and Set doesn't change anything.

public int CurrentAnimationsNumberOfTimesToPlay { get; set; }

Get / Set the Number of times the Current Animation should Play (it replays when the end of the Animation is reached). Specify a value of zero to have the Animation repeat forever.

NOTE: If no Animation has been set yet, no changes are made when Setting, and -1 is returned when Getting.

Get / Set the Current Index in the Current Animation's Picture Rotation Order.

NOTE: If no Animation has been set yet, Get returns -1, and Set doesn't change anything (as well as if the specified Index is invalid).

public float CurrentAnimationsPictureRotationTime { get; set; }

Get / Set how much Time should elapsed before switching frames in the Current Animation.

NOTE: If no Animation has been set yet, zero will be returned.

public Rectangle CurrentPicturesTextureCoordinates { get; }

Get the Rectangle representing the Texture Coordinates of the Picture in the Animation that should be displayed at this point in time

public bool Paused { get; set; }

Get / Set if the Animation should be Paused or not. If Paused, the Animation will not be Updated.

public float TimeRequiredToPlayCurrentAnimation { get; }

Gets the amount of Time (in seconds) required to play the Current Animation.

NOTE: If no Animation has been played yet, zero is returned.

Gets the amount of Time (in seconds) required to play the remainder of the Current Animation.

NOTE: If no Animation has been played yet, zero is returned.

public Animations()

public bool AnimationIDIsValid(int iAnimationID)

Returns true if the given Animation ID is valid (i.e. An Animation with the same ID exists).

public void CopyFrom(Animations cAnimationToCopy)

Copies the given Animations data into this Animation

public int CreateAnimation(List<int> cPictureRotationOrder, float fPictureRotationTime, int iNumberOfTimesToPlay)

Creates a new Animation and returns the Animation's unique ID.

NOTE: Returns -1 if an invalid Picture ID was specified in the PictureRotationOrder.

NOTE: Be sure to Create the Pictures before creating the Animation.

public int CreateAnimation(int[] iaPictureRotationOrder, float fPictureRotationTime, int iNumberOfTimesToPlay)

Creates a new Animation and returns the Animation's unique ID.

NOTE: Returns -1 if an invalid Picture ID was specified in the PictureRotationOrder.

NOTE: Be sure to Create the Pictures before creating the Animation.

public int CreatePicture(Rectangle sTextureCoordinates)

Creates a Picture that can be used in a Animation, and returns its unique ID. A Picture can be used multiple times in an Animation.

public int CreatePicturesFromTileSet(int iTotalNumberOfPictures, int iPicturesPerRow, Rectangle sFirstPicture)

Automatically creates the specified Total Number Of Pictures. All pictures are assumed to have the same width and height, as specified in the First Picture rectangle. Also, the First Picture is assumed to be at the top-left corner of the Tileset.

Pictures are created in left-to-right, top-to-bottom order. The ID of the first Picture created is returned, with each new Picture created incrementing the ID value, so the last Picture created will have an ID of (returned ID + (Total Number Of Pictures - 1)).

public int GetAnimationsNumberOfTimesToPlay(int iAnimationID)

Returns the Number of times the given Animation ID is set to Play. Zero means the Animation will repeat forever.

NOTE: If the given Animation ID is invalid, -1 is returned.

public float GetAnimationsPictureRotationTime(int iAnimationID)

Returns how much Time (in seconds) should elapse before switching frames in the Animation.

NOTE: Returns zero if the specified Animation ID is not valid.

public Rectangle GetPicturesTextureCoordinates(int iPictureID)

Returns the Rectangle representing the Texture Coordinates of the specified Picture.

public bool PictureIDIsValid(int iPictureID)

Returns true if the given Picture ID is valid (i.e. A Picture with the same ID exists).

public void SetAnimationsNumberOfTimesToPlay(int iAnimationID, int iNewNumberOfTimesToPlay)

Sets the Number of times the given Animation ID should Play (it replays when the end of the Animation is reached). Specify a value of zero to have the Animation repeat forever.

NOTE: If the given Animation ID is invalid, no changes are made.

public void SetAnimationsPictureRotationTime(int iAnimationID, float fNewPictureRotationTime)

Sets how much Time should elapse before switching frames in the Animation

public void SetCurrentAnimationAndPositionInAnimation(int iAnimationID, int iPictureRotationOrderIndex)

Sets the Current Animation being used, as well as what index in the Animation's Picture Rotation Order the Animation should start at.

NOTE: If the specified Animiation to use is not valid, the Current Animation will not be changed, and if the specified Picture Rotation Order Index is not valid, the Animation will start from the beginning of the Animation.

public float TimeRequiredToPlayAnimation(int iAnimationID)

Returns the amount of Time required to play the specified Animation.

NOTE: If an invalid AnimationID is specified, zero is returned.

public void Update(float fElapsedTime)

Updates the Animation according to how much time has elapsed