- Godot Engine Game Development Projects
- Chris Bradfield
- 105字
- 2021-06-18 18:51:28
Starting and Ending the Player's Movement
When the game starts, the main scene will need to inform the player that the game has begun. Add the start() function as follows, which the main scene will use to set the player's starting animation and position:
func start(pos):
set_process(true)
position = pos
$AnimatedSprite.animation = "idle"
The die() function will be called when the player hits an obstacle or runs out of time:
func die():
$AnimatedSprite.animation = "hurt"
set_process(false)
Setting set_process(false) causes the _process() function to no longer be called for this node. That way, when the player has died, they can't still be moved by key input.