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

Lerp() public static method

public static Lerp ( float value1, float value2, float amount ) : float
value1 float
value2 float
amount float
return float
        public static float Lerp(float value1, float value2, float amount)
        {
            return value1 + (value2 - value1) * amount;
        }
        public static float Barycentric(float value1, float value2, float value3, float amount1, float amount2)

Usage Example

Esempio n. 1
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            var dt = gameTime.ElapsedGameTime.TotalMilliseconds;

            // Tween to target Y positions
            Users.ForEach(user =>
            {
                user.Y = MathHelper.Lerp(user.Y, user.TargetYPosition, (float)Math.Min(dt / 120, 1));

                // Tween X Position based on if the scoreboard is hidden
                if (ConfigManager.ScoreboardVisible.Value)
                {
                    var target = Team == MultiplayerTeam.Red ? 0 : WindowManager.Width - user.Width;
                    user.X     = MathHelper.Lerp(user.X, target, (float)Math.Min(dt / 120, 1));
                }
                else
                {
                    var target = Team == MultiplayerTeam.Red ? -user.Width - 10 : WindowManager.Width + user.Width + 10;
                    user.X     = MathHelper.Lerp(user.X, target, (float)Math.Min(dt / 90, 1));
                }

                user.Visible = user.X >= -user.Width + 10;
            });

            // Lerp team banner in and out
            if (TeamBanner != null)
            {
                var target = Team == MultiplayerTeam.Red ? 0 : WindowManager.Width - TeamBanner.Width;
                TeamBanner.X = MathHelper.Lerp(TeamBanner.X, target, (float)Math.Min(dt / 120, 1));
            }

            base.Update(gameTime);
        }
All Usage Examples Of Microsoft.Xna.Framework.MathHelper::Lerp