public static Normalize ( Vector2 &value, Vector2 &result ) : void | ||
value | Vector2 | Source vector. |
result | Vector2 | [OutAttribute] Normalized vector. |
Результат | void |
public static void Normalize(ref Vector2 value, out Vector2 result)
{
float num = value.X * value.X + value.Y * value.Y;
float num2 = 1f / (float)Math.Sqrt((double)num);
result.X = value.X * num2;
result.Y = value.Y * num2;
}
/// <summary>Determines the reflect vector of the given vector and normal.</summary>
public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Vector2 direction = new Vector2(speedX, speedY); direction.Normalize(); position += direction * item.width; return true; }