Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Siddharth Pushkar |
I have made a game where you move a ball, collect coins and escape the enemies.
if you collect all 10 coins your scene will change to You Win screen But if you touched any enemy or entered any enemy body your scene will change to Game Over screen.
I want to assign a key on the keyboard (Like Shift + D) which when I press, It Disables the function or code of line in which when the ball enters the enemy body the scene changes to Game Over.
func _on_enemy_body_entered(body):
if body.name == "Ball":
get_tree().change_scene("res://Demo menu screen/Gameover.tscn")
# I want to disable this line of code or function when a key is pressed
I have never tried something like ‘shift D’ with two keys , but could you not just make a variable true or false like ‘var gameover = true’ set it to false if a key is pressed , then change 'if body.name==“Ball” to “if gameover and body.name == “Ball”” then at the end of the function “gameover = true”
ArthurER | 2020-10-03 03:46
Code and show me
Siddharth Pushkar | 2020-10-03 03:53