Now setup the animations for the Frog:
Now setup the animations for the Frog:
We need access to the AnimatedSprite2D and its functions.
We need access to the AnimatedSprite2D and its functions.
Create an onready reference variable for the AnimatedSprite2D.
Create an onready reference variable for the AnimatedSprite2D.
We want to flip / mirror the sprite to look in the direction the player is facing
We want to flip / mirror the sprite to look in the direction the player is facing
Do this my MOVING the direction variable from the run function
Do this my MOVING the direction variable from the run function
To the top of the player script.
To the top of the player script.
Now create a new function to flip the animations
Now create a new function to flip the animations
depending on the value of the direction variable.
depending on the value of the direction variable.
-1 = LEFT
-1 = LEFT
+1 = RIGHT
+1 = RIGHT
Create a new function called animate
Create a new function called animate
If the player is not moving we play idle
If the player is not moving we play idle
If the player is on the floor and moving up play jump
If the player is on the floor and moving up play jump
If the player is moving down play fall
If the player is moving down play fall
if the player is moving left or right and not jumping play run
if the player is moving left or right and not jumping play run
Double-jump and wall-slide will require their own functions.
Double-jump and wall-slide will require their own functions.