gdquest-demos / godot-3-beginner-2d-platformer

Learn to create a 2d platform game with the Godot game engine. This is a beginner programming tutorial.
MIT License
365 stars 96 forks source link

Issue: lose all score when retry level #38

Open PartTimeCode opened 4 years ago

PartTimeCode commented 4 years ago

Not sure if this has been addressed but I notice in my game after completing a couple of levels and I die and retry, all score is lost from previous levels, I fixed this by adding another variable to PlayerData "level_score" with a setget and make ememys and coins add there score to this, then I add the level score to the total score in the portal and make the user interface add the scores for display "score.text = "Score: %s" % str(PlayerData.score+PlayerData.level_score)"

now when I die I only lose the score for that level.

Fantastic tutorial BTW

Kaiser11235 commented 4 years ago

@PartTimeCode could you show the changes made to "PlayerData.gd"? I see you put the change to the %s for game interface score but I am not sure exactly how I am supposed to code the function for level_score so that it actually only takes the totals from that specific scene.