public void Play(string name, bool loop) { if (CurrentSequence != null) { if (!IsPlaying) { IsPlaying = true; } if (name == CurrentSequence.Name && IsLooped == loop) { return; } } IsLooped = loop; var sequence = (from s in Sequences where s.Name == name select s).SingleOrDefault(); if (sequence != null) { IsPlaying = true; CurrentSequence = sequence; CurrentElapsedTime = 0; CurrentFrameIndex = sequence.StartFrame; } else { CurrentSequence = null; Stop(true); } }
public override void LoadContent() { base.LoadContent(); if (BasicEffect == null) { BasicEffect = new BasicEffect(Game.GraphicsDevice); BasicEffect.World = Matrix.Identity; BasicEffect.PreferPerPixelLighting = true; } // Load our Sprite Sheet) if (Texture == null || Texture.IsDisposed) { if (!string.IsNullOrEmpty(AssetName) && GameScreen != null && ContentManager == null) { Texture = GameScreen.Content.Load <Texture2D>(Path.GetFileNameWithoutExtension(AssetName)); } else if (!string.IsNullOrEmpty(AssetName) && ContentManager != null) { Texture = ContentManager.Load <Texture2D>(Path.GetFileNameWithoutExtension(AssetName)); } else if (!string.IsNullOrEmpty(AssetName)) { Texture = Game.Content.Load <Texture2D>(Path.GetFileNameWithoutExtension(AssetName)); } } // Display our first frame of our first sequence out the gate if (Sequences.Count > 0 && CurrentSequence == null) { CurrentSequence = Sequences[0]; } }