Exemple #1
0
 private void UpdatePosition(float dt)
 {
     if (this.IsLockedToInputPosition)
     {
         this.CurrentPositionPercent = this.DestPositionPercent;
     }
     else
     {
         float speed = 0.25f * 60 * dt;
         this.CurrentPositionPercent = GameUtilities.MoveTowards(this.CurrentPositionPercent, this.DestPositionPercent, speed);
         const float min_diff = 0.01f;
         float       diff_x   = Math.Abs(this.CurrentPositionPercent.X - this.DestPositionPercent.X);
         float       diff_y   = Math.Abs(this.CurrentPositionPercent.Y - this.DestPositionPercent.Y);
         if (diff_x <= min_diff && diff_y <= min_diff)
         {
             this.IsLockedToInputPosition = true;
         }
     }
     this.Position = this.CalculatePositionFromPercent(this.CurrentPositionPercent);
 }