//public IEnumerable<TextureRegion2D> Frames //{ // get { return _frames; } //} //public IEnumerable<string> Animations //{ // get { return _animations.Keys.OrderBy(i => i); } //} //public int AddFrame(TextureRegion2D textureRegion) //{ // var index = _frames.Count; // _frames.Add(textureRegion); // if (Sprite != null && Sprite.TextureRegion == null) // Sprite.TextureRegion = textureRegion; // return index; //} //public bool RemoveFrame(TextureRegion2D textureRegion) //{ // return _frames.Remove(textureRegion); //} //public bool RemoveFrame(string name) //{ // var frame = GetFrame(name); // return RemoveFrame(frame); //} //public void RemoveFrameAt(int frameIndex) //{ // _frames.RemoveAt(frameIndex); //} //public TextureRegion2D GetFrameAt(int index) //{ // return _frames[index]; //} //public TextureRegion2D GetFrame(string name) //{ // return _frames.FirstOrDefault(f => f.Name == name); //} //public SpriteSheetAnimation AddAnimation(string name, int framesPerSecond, int[] frameIndices) //{ // if (_animations.ContainsKey(name)) // throw new InvalidOperationException(string.Format("Animator already contrains an animation called {0}", name)); // var animation = new SpriteSheetAnimation(name, framesPerSecond, frameIndices); // _animations.Add(name, animation); // return animation; //} //public SpriteSheetAnimation AddAnimation(string name, int framesPerSecond, int firstFrameIndex, int lastFrameIndex) //{ // var frameIndices = new int[lastFrameIndex - firstFrameIndex + 1]; // for (var i = 0; i < frameIndices.Length; i++) // frameIndices[i] = firstFrameIndex + i; // return AddAnimation(name, framesPerSecond, frameIndices); //} //public bool RemoveAnimation(string name) //{ // SpriteSheetAnimation animation; // if (!_animations.TryGetValue(name, out animation)) // return false; // if (_currentAnimation == animation) // _currentAnimation = null; // _animations.Remove(name); // return true; //} public void PlayAnimation(SpriteSheetAnimation animation, Action onCompleteAction = null) { if (!_animationGroup.Contains(animation)) { throw new InvalidOperationException("Animation does not belong to this animator"); } PlayAnimation(animation.Name); }
public SpriteSheetAnimation Play(string name, Action onCompleted = null) { if ((_currentAnimation == null) || _currentAnimation.IsComplete || (_currentAnimation.Name != name)) { _currentAnimation = _animationFactory.Create(name); _currentAnimation.OnCompleted = onCompleted; } return(_currentAnimation); }
public void PlayAnimation(string name, Action onCompleteAction = null) { if (_currentAnimation != null && _currentAnimation.Name == name && IsPlaying) { return; } _currentAnimation = _animationGroup.GetAnimation(name); _frameIndex = 0; _onCompleteAction = onCompleteAction; IsPlaying = true; }
public bool Contains(SpriteSheetAnimation animation) { return(_animations.ContainsValue(animation)); }
public void SetAnimation(string name) { _currentAnimation = _animations[name]; }
public void AddAnimation(string name, int[] frameIndices) { var animation = new SpriteSheetAnimation(name, frameIndices); _animations.Add(name, animation); }
public bool Contains(SpriteSheetAnimation animation) { return _animations.ContainsValue(animation); }