` i have a button to start the game, when it first clicked it works normaly and started the game. but when the button appears again after game over it can be pressed but it doesn’t work
here’s the code of the ui scene:
Ok, i took a look on your code and found the reason you code doesn’t work:
# Basket.gd
func _process(delta):
if is_playing == true:
max_coins = max(max_coins,coins)
speed = max_coins*2 + 100
move_local_x(-speed*delta)
if position.x < 0:
set_start_position()
# The reason your code doesn't work is because you're
emitting the game over signal over and over again here,
you don't reset your coins counting when the game restarts
so this will trigger again after you restart the game.
if coins < 0:
game_over.emit()
$CollisionShape2D.disabled = false
#print("playing")
else:
hide()
#print("not playing")
#$CollisionShape2D.disabled = true
# World.gd
func _on_labels_start():
# You need to restart you coin counter here, otherwise the
# game over signal will be triggered again
$Basket.coins = 10
$Basket.is_playing = true
$Basket.show()
$BasketBall.is_playing = true
$BasketBall.show()
print("start recived")