Jelajahi Sumber

Update physics_introduction.rst (#7360)

Co-authored-by: Raul Santos <[email protected]>
VestedGrammar 2 tahun lalu
induk
melakukan
50f8f10250
1 mengubah file dengan 4 tambahan dan 4 penghapusan
  1. 4 4
      tutorials/physics/physics_introduction.rst

+ 4 - 4
tutorials/physics/physics_introduction.rst

@@ -286,19 +286,19 @@ For example, here is the code for an "Asteroids" style spaceship:
         private Vector2 _thrust = new Vector2(0, -250);
         private float _torque = 20000;
 
-        public override void _IntegrateForces(Physics2DDirectBodyState state)
+        public override void _IntegrateForces(PhysicsDirectBodyState2D state)
         {
             if (Input.IsActionPressed("ui_up"))
-                AppliedForce = _thrust.Rotated(Rotation);
+                state.ApplyForce(_thrust.Rotated(Rotation));
             else
-                AppliedForce = new Vector2();
+                state.ApplyForce(new Vector2());
 
             var rotationDir = 0;
             if (Input.IsActionPressed("ui_right"))
                 rotationDir += 1;
             if (Input.IsActionPressed("ui_left"))
                 rotationDir -= 1;
-            AppliedTorque = rotationDir * _torque;
+            state.ApplyTorque(rotationDir * _torque);
         }
     }