public void PlayAnimation(string Name) { //code to actually switch your animation state to the animation name specified that's stored in animList _currentAnimation = _animList.Find(item => item.name.Contains(Name)); if (_currentAnimation != null) { //Store the number of frames in the animation _animationFrames = _currentAnimation.frames.Length; //Decide whether to flip the gfx or not if (_currentAnimation.flipX == true) { _spriteRenderer.flipX = true; } else { _spriteRenderer.flipX = false; } if (_currentAnimation.flipY == true) { _spriteRenderer.flipY = true; } else { _spriteRenderer.flipY = false; } } }
public void AddAnimation(string Name, int[] Frames, float FrameRate = 30, bool Looped = true, bool FlipX = false, bool FlipY = false) { RetroSpriteAnimation newAnimation = new RetroSpriteAnimation(); newAnimation.name = Name; newAnimation.frames = Frames; newAnimation.frameRate = 1 / FrameRate; newAnimation.looped = Looped; newAnimation.flipX = FlipX; newAnimation.flipY = FlipY; _animList.Add(newAnimation); }