-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chapter 4 updating HUD on level changes #28
Comments
In order to support HUD updates during level changes, I switched from the signal based method to the Singleton or global variable method. In the game_state.gd script, I added these two global variables: Then I changed the level base script (level_base.gd) to update the score:
Then updated the player.gd script:
and commented out this stuff in the player.gd script:
And, finally, I updated main.gd with this:
|
Hi mrwnphs, Thank you for bringing this issue to our attention. We appreciate your detailed feedback. @cbscribe Could you please look into this issue and provide assistance? Your expertise will be invaluable in resolving the reader's concern. Thank you for your help! |
I got the code to allow the player to get to new levels. But, the score and life count resets when I go to each new level. I have spent hours trying to resolve the problem. I did find a workaround, but it feels like a bad practice. I ended up adding global variables to the GameState script and I update the HUD through the HUD scene's _process function. Maintaining the score and life count via global variables seems like a reasonable thing to do. But updating the HUD via the _process function feels wasteful- why update the HUD score repeatedly when it hasn't changed?
I don't think that the code in the tutorial in Chapter 4 addresses the score and life count during level changes, but I am open to any thoughts or advice.
The text was updated successfully, but these errors were encountered: