Migration of Animation Code to External Library

Created the AnimationLibrary library to hold both Animation and AnimatedSprite.
This commit is contained in:
quinnvoker
2018-11-17 11:24:20 -08:00
parent e14c1627cc
commit fee1757862
6 changed files with 219 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
using MonoGame.Extended.TextureAtlases;
namespace QURO.AnimationLibrary
{
public class Animation
{
public string Name { get; set; }
public bool IsLooping { get; set; }
public float Delay { get; set; }
public TextureRegion2D[] Frames { get; set; }
public bool IsStillImage => Frames.Length <= 1;
public Animation() { }
public Animation(string name, TextureAtlas textureAtlas, string[] frameNames, float delaySetting = 0.2f, bool willLoop = false)
{
Name = name;
Frames = new TextureRegion2D[frameNames.Length];
for (int index = 0; index < frameNames.Length; index++)
{
Frames[index] = textureAtlas.GetRegion(frameNames[index]);
}
IsLooping = willLoop;
Delay = delaySetting;
}
}
}