Browse Source

Merge pull request #6895 from rm-code/feature/fix-capitalization

C#: Fix capitalization of vector properties X and Y
Rémi Verschelde 2 years ago
parent
commit
02d743a243
1 changed files with 10 additions and 10 deletions
  1. 10 10
      getting_started/first_2d_game/03.coding_the_player.rst

+ 10 - 10
getting_started/first_2d_game/03.coding_the_player.rst

@@ -206,22 +206,22 @@ which returns ``true`` if it's pressed or ``false`` if it isn't.
 
 
         if (Input.IsActionPressed("move_right"))
         if (Input.IsActionPressed("move_right"))
         {
         {
-            velocity.x += 1;
+            velocity.X += 1;
         }
         }
 
 
         if (Input.IsActionPressed("move_left"))
         if (Input.IsActionPressed("move_left"))
         {
         {
-            velocity.x -= 1;
+            velocity.X -= 1;
         }
         }
 
 
         if (Input.IsActionPressed("move_down"))
         if (Input.IsActionPressed("move_down"))
         {
         {
-            velocity.y += 1;
+            velocity.Y += 1;
         }
         }
 
 
         if (Input.IsActionPressed("move_up"))
         if (Input.IsActionPressed("move_up"))
         {
         {
-            velocity.y -= 1;
+            velocity.Y -= 1;
         }
         }
 
 
         var animatedSprite2D = GetNode<AnimatedSprite2D>("AnimatedSprite2D");
         var animatedSprite2D = GetNode<AnimatedSprite2D>("AnimatedSprite2D");
@@ -297,8 +297,8 @@ the ``_process`` function (make sure it's not indented under the `else`):
 
 
         Position += velocity * (float)delta;
         Position += velocity * (float)delta;
         Position = new Vector2(
         Position = new Vector2(
-            x: Mathf.Clamp(Position.x, 0, ScreenSize.x),
-            y: Mathf.Clamp(Position.y, 0, ScreenSize.y)
+            x: Mathf.Clamp(Position.X, 0, ScreenSize.X),
+            y: Mathf.Clamp(Position.Y, 0, ScreenSize.Y)
         );
         );
 
 
  .. code-tab:: cpp
  .. code-tab:: cpp
@@ -350,17 +350,17 @@ movement. Let's place this code at the end of the ``_process()`` function:
 
 
  .. code-tab:: csharp
  .. code-tab:: csharp
 
 
-        if (velocity.x != 0)
+        if (velocity.X != 0)
         {
         {
             animatedSprite2D.Animation = "walk";
             animatedSprite2D.Animation = "walk";
             animatedSprite2D.FlipV = false;
             animatedSprite2D.FlipV = false;
             // See the note below about boolean assignment.
             // See the note below about boolean assignment.
-            animatedSprite2D.FlipH = velocity.x < 0;
+            animatedSprite2D.FlipH = velocity.X < 0;
         }
         }
-        else if (velocity.y != 0)
+        else if (velocity.Y != 0)
         {
         {
             animatedSprite2D.Animation = "up";
             animatedSprite2D.Animation = "up";
-            animatedSprite2D.FlipV = velocity.y > 0;
+            animatedSprite2D.FlipV = velocity.Y > 0;
         }
         }
 
 
  .. code-tab:: cpp
  .. code-tab:: cpp