File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
getting_started/first_2d_game Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -271,16 +271,22 @@ movement. Let's place this code at the end of the ``_process()`` function:
271271
272272.. tabs ::
273273 .. code-tab :: gdscript GDScript
274+ # to allow the
275+
274276
277+
275278 if velocity.x != 0:
276279 $AnimatedSprite2D.animation = "walk"
277- $AnimatedSprite2D.flip_v = false
278- # See the note below about the following boolean assignment.
279- $AnimatedSprite2D.flip_h = velocity.x < 0
280280 elif velocity.y != 0:
281281 $AnimatedSprite2D.animation = "up"
282- $AnimatedSprite2D.flip_v = velocity.y > 0
283282
283+ # Allow the character to flip in both directions
284+ if velocity.x != 0:
285+ # See the note below about the following boolean assignment.
286+ $AnimatedSprite2D.flip_v = false
287+ $AnimatedSprite2D.flip_h = velocity.x < 0
288+ if velocity.y != 0:
289+ $AnimatedSprite2D.flip_v = velocity.y > 0
284290 .. code-tab :: csharp
285291
286292 if (velocity.X != 0)
You can’t perform that action at this time.
0 commit comments