Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions getting_started/first_2d_game/03.coding_the_player.rst
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,18 @@ movement. Let's place this code at the end of the ``_process()`` function:

.. tabs::
.. code-tab:: gdscript GDScript

if velocity.x != 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if velocity.x != 0:
if velocity.x != 0:

$AnimatedSprite2D.animation = "walk"
$AnimatedSprite2D.flip_v = false
# See the note below about the following boolean assignment.
$AnimatedSprite2D.flip_h = velocity.x < 0
elif velocity.y != 0:
$AnimatedSprite2D.animation = "up"
$AnimatedSprite2D.flip_v = velocity.y > 0

# Allow the character to flip in both directions
if velocity.x != 0:
# See the note below about the following boolean assignment.
$AnimatedSprite2D.flip_v = false
$AnimatedSprite2D.flip_h = velocity.x < 0
if velocity.y != 0:
$AnimatedSprite2D.flip_v = velocity.y > 0

.. code-tab:: csharp

Expand Down