Microsoft.Xna.Framework.Vector2.Lerp C# (CSharp) Method

Lerp() public static method

Performs a linear interpolation between two vectors.
public static Lerp ( Vector2 value1, Vector2 value2, float amount ) : Vector2
value1 Vector2 Source vector.
value2 Vector2 Source vector.
amount float Value between 0 and 1 indicating the weight of value2.
return Vector2
        public static Vector2 Lerp(Vector2 value1, Vector2 value2, float amount)
        {
            Vector2 result;
            result.X = value1.X + (value2.X - value1.X) * amount;
            result.Y = value1.Y + (value2.Y - value1.Y) * amount;
            return result;
        }
        /// <summary>Performs a linear interpolation between two vectors.</summary>

Same methods

Vector2::Lerp ( Vector2 &value1, Vector2 &value2, float amount, Vector2 &result ) : void

Usage Example

コード例 #1
0
ファイル: Coin.cs プロジェクト: wynaut-wastaken/ProjectTC
 public override void step()
 {
     Velocity.Y += FallSpeed;
     if (Collides(position + Vector2.UnitY))
     {
         Velocity.Y  = 0;
         position.Y  = (float)Math.Floor(position.Y);
         Velocity.X /= 1.2f;
     }
     Velocity.X /= 1.1f;
     if (Collides(position + Velocity))
     {
         Velocity = Vector2.Zero;
     }
     position += Velocity;
     if (Vector2.Distance(Player.LocalClient.position, position) <= 3)
     {
         position = Vector2.Lerp(position, Player.LocalClient.position, 0.1f);
     }
     if (Vector2.Distance(Player.LocalClient.position, position) <= 0.3f)
     {
         SoundManager.PlaySound(SoundManager.SfxCoinPickup);
         destroy();
     }
 }