public AnimatedSprite(Texture2D texture, Vector2 size, int frameCount, int frameLength) : base(texture, size) { FrameCount = frameCount; FrameLength = frameLength; _timer = new Timer { Length = frameLength }; _timer.OnComplete += Tick; }
public AnimatedSprite(SpriteSheet spriteSheet, int frameCount, int frameLength) : base(spriteSheet) { FrameCount = frameCount; FrameLength = frameLength; _timer = new Timer { Length = frameLength }; _timer.OnComplete += Tick; }
protected virtual void Tick(Timer timer) { timer.Reset(); CurrentFrame++; if (CurrentFrame >= FrameCount) { CurrentFrame = 0; OnComplete?.Invoke(); } Index = CurrentFrame; }