Hi! One of my students is trying to use a while loop under the “on A button pressed” event handler. When the condition countdown > 0 is true, he wants the camera to shake. When he adds in the loop and presses the A button, the code stops running. Any ideas on how to get this loop to run properly? Thank you!
1 Like
while (true)
has no exist condition, so it’ll stay in that forever. If he wants the loop to stop when countdown is no longer >= 0, he’d want something like this:
but in this case there wouldn’t be that much of a difference, because the countdown running out means the game over screen will pop up. Having the loop in the ‘on a pressed’ itself also has some behavior associated with it; on a pressed will only run one at a time, but from the current game it doesn’t seem like an issue (and we could work around if needed).
What would he like to see change in the game behavior wise?
1 Like