Game Over Screen Lesson - Bug @ 11:17

Hello,

I notice at around 11:17 of the video there is an error. The score on the UI top left displays 300 but the menu displays 200. This is fixed later when the timer is added.

I’m guessing this is something to do with the order in which the code is executed and by adding the timer it resolves the order?

Can someone explain the order in the code and why this bug happens if the timer is not added?

Thank you.

hi,

not 100% sure, but as you say its probably down to the execution order where the game over screen is instantiated and run, but before the hud.setscore has had time to complete.

if I add a print statement when the hud.setscore is called and another when the gameover screen is updated, and then die 3 times i get the following output

image

having the small timer there, just ensures that that current frame is processed with the enemy dying and updating the score variable completely and the game over screen is then called.

sorry i cant be more precise in that, but i couldnt think of a better explanation :frowning:

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms