Skip to content
Open
Changes from 1 commit
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
15 changes: 12 additions & 3 deletions getting_started/first_2d_game/03.coding_the_player.rst
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ movement. Let's place this code at the end of the ``_process()`` function:
elif velocity.y != 0:
$AnimatedSprite2D.animation = "up"

# Allow the character to flip in both directions
# 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
Expand All @@ -289,13 +289,22 @@ movement. Let's place this code at the end of the ``_process()`` function:
if (velocity.X != 0)
{
animatedSprite2D.Animation = "walk";

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

}
else if (velocity.Y != 0)
{
animatedSprite2D.Animation = "up";
}

# Allow the character to flip in both directions.
if (velocity.X != 0)
{
animatedSprite2D.FlipV = false;
// See the note below about the following boolean assignment.
Comment on lines 302 to 303
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
animatedSprite2D.FlipV = false;
// See the note below about the following boolean assignment.
// See the note below about the following boolean assignment.
animatedSprite2D.FlipV = false;

Or flip the order above in GDScript

animatedSprite2D.FlipH = velocity.X < 0;
}
else if (velocity.Y != 0)
if (velocity.Y != 0)
{
animatedSprite2D.Animation = "up";
animatedSprite2D.FlipV = velocity.Y > 0;
}

Expand Down