File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
getting_started/first_2d_game Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -276,7 +276,7 @@ movement. Let's place this code at the end of the ``_process()`` function:
276276 elif velocity.y != 0:
277277 $AnimatedSprite2D.animation = "up"
278278
279- # Allow the character to flip in both directions
279+ # Allow the character to flip in both directions.
280280 if velocity.x != 0:
281281 # See the note below about the following boolean assignment.
282282 $AnimatedSprite2D.flip_v = false
@@ -289,13 +289,22 @@ movement. Let's place this code at the end of the ``_process()`` function:
289289 if (velocity.X != 0)
290290 {
291291 animatedSprite2D.Animation = "walk";
292+
293+ }
294+ else if (velocity.Y != 0)
295+ {
296+ animatedSprite2D.Animation = "up";
297+ }
298+
299+ # Allow the character to flip in both directions.
300+ if (velocity.X != 0)
301+ {
292302 animatedSprite2D.FlipV = false;
293303 // See the note below about the following boolean assignment.
294304 animatedSprite2D.FlipH = velocity.X < 0;
295305 }
296- else if (velocity.Y != 0)
306+ if (velocity.Y != 0)
297307 {
298- animatedSprite2D.Animation = "up";
299308 animatedSprite2D.FlipV = velocity.Y > 0;
300309 }
301310
You can’t perform that action at this time.
0 commit comments