Flappy bird score increase

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By toryG

I am making a game similar to Flappy bird but I want the score to increase when it passes collisionshape2d. Can you help me?

:bust_in_silhouette: Reply From: exuin

I assume the collisionshape2d is a child of the area2d. If you don’t have another area2d on the player, add one too. Make a score variable in the player script. Connect the “area_entered” signal on the player to itself. In the function that the signal connects to, check if the area entered is the one that increases the score if you have more than one kind of area2d. If it is, increase the score variable. I’m guessing you want to display the score, so you’ll probably have to update the text of a label too by converting the score into a string using str().