public void Reset() { CurrentDirection = SpriteAnimDirection.Forward; CurrentFrame = 0; CurrentFrameTime = 0; State = SpriteAnimState.Paused; }
public void Update(GameTime gameTime) { if (State != SpriteAnimState.Playing) { return; } CurrentFrameTime += gameTime.ElapsedGameTime.TotalMilliseconds; if (CurrentFrameTime < TargetFrameTime) { return; } CurrentFrameTime = 0; switch (CurrentDirection) { case SpriteAnimDirection.Forward: CurrentFrame++; if (CurrentFrame == NumFrames) { if (PingPong && NumFrames > 1) { CurrentDirection = SpriteAnimDirection.Reverse; CurrentFrame -= 2; } else { CurrentFrame = 0; } } break; case SpriteAnimDirection.Reverse: CurrentFrame--; if (CurrentFrame == -1) { if (PingPong && NumFrames > 1) { CurrentDirection = SpriteAnimDirection.Forward; CurrentFrame = 1; } else { CurrentFrame = NumFrames - 1; } } break; default: throw new ArgumentOutOfRangeException(); } }
public SpriteAnim(Texture2D sheet, int row, int numframes, int width, int height, double frametime) { SpriteSheet = sheet; Offset = new Vector2(sheet.Width,sheet.Height)/2f; NumFrames = numframes; SheetRow = row; CellWidth = width; CellHeight = height; CurrentFrame = 0; CurrentFrameTime = 0; TargetFrameTime = frametime; Loop = true; PingPong = false; CurrentDirection = SpriteAnimDirection.Forward; State = SpriteAnimState.Paused; }
public SpriteAnim(Texture2D sheet, int row, int numframes, int width, int height, double frametime) { SpriteSheet = sheet; Offset = new Vector2(sheet.Width, sheet.Height) / 2f; NumFrames = numframes; SheetRow = row; CellWidth = width; CellHeight = height; CurrentFrame = 0; CurrentFrameTime = 0; TargetFrameTime = frametime; Loop = true; PingPong = false; CurrentDirection = SpriteAnimDirection.Forward; State = SpriteAnimState.Paused; }
public void Update(GameTime gameTime) { if (State != SpriteAnimState.Playing) return; CurrentFrameTime += gameTime.ElapsedGameTime.TotalMilliseconds; if (CurrentFrameTime < TargetFrameTime) return; CurrentFrameTime = 0; switch(CurrentDirection) { case SpriteAnimDirection.Forward: CurrentFrame++; if (CurrentFrame == NumFrames) { if (PingPong && NumFrames > 1) { CurrentDirection = SpriteAnimDirection.Reverse; CurrentFrame -= 2; } else CurrentFrame = 0; } break; case SpriteAnimDirection.Reverse: CurrentFrame--; if (CurrentFrame == -1) { if (PingPong && NumFrames > 1) { CurrentDirection = SpriteAnimDirection.Forward; CurrentFrame = 1; } else CurrentFrame = NumFrames-1; } break; default: throw new ArgumentOutOfRangeException(); } }
public void Reset() { CurrentDirection = SpriteAnimDirection.Forward; CurrentFrame = 0; CurrentFrameTime = 0; }
public void Reset() { CurrentDirection = SpriteAnimDirection.Forward; CurrentFrame = 0; CurrentFrameTime = 0; }
public void Reset() { CurrentDirection = SpriteAnimDirection.Forward; CurrentFrame = 0; CurrentFrameTime = 0; State = SpriteAnimState.Paused; }