Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | crow_dev |
I’m trying to create a score to make a pong game but the player’s score starts at 2 and the enemy’s at 1 when I put 0 in the variables
extends Node
var playerscore = 0
var oponentscore = 0
func _on_meta_derrota_body_entered(body):
$pelota.position = Vector2(640, 360)
$oponent.position = Vector2(1243, 364)
$jugador.position = Vector2(44, 364)
oponentscore += 1
get_tree().call_group(‘pelota’ , ‘stop_pelota’)
$Timer.start()
func _on_meta_victoria_body_entered(body):
$pelota.position = Vector2(640, 360)
$jugador.position = Vector2(44, 364)
$oponent.position = Vector2(1243, 364)
playerscore += 1
get_tree().call_group(‘pelota’ , ‘stop_pelota’)
$Timer.start()
func _process(delta):
$playerscore.text = str(playerscore)
$oponentscore.text = str(oponentscore)
$Timer.text = str(int($Timer.time_left))
func _on_Timer_timeout():
get_tree().call_group(‘pelota’ , ‘restart_pelota’)