Ví dụ: Giá trị amount sẽ giao động theo thời gian (nằm trong khoảng 0.0f -> 1.0f) -> Giá trị c giao động theo thời gian (0.0f -> 10.0f)
Code:
public override void Update(GameTime gameTime) { float amount = Math.Sin(gameTime.TotalGameTime.TotalSeconds)*0.5f + 0.5f; // Hàm sin này có giá trị giao động từ 0.0f -> 1.0f float c = MathHelper.Lerp(0.0f, 10.0f, amount); }
Leave a comment: