Microsoft MakeCode

Loop Running Behind Dialog

I have an odd issue in a game I am making, and have managed to reproduce the error with some test code.

The first time through my game, I present the user with some dialog and then once they clear it a loop runs creating some sprites. Once all the sprites are destroyed the dialog is represented, but the second time around the loop actually runs before the dialog box is cleared.

I’m not sure why this is occurring nor how to fix it. Any help would be appreciated!

1 Like

Thank you so much for making such a small repro program!

The issue here is that you’re placing a pause block inside of an on game update. All the code in the game update loop needs to run before the screen can be drawn, so the code is actually running correctly even though it doesn’t look like anything is happening.

In general, if you want to pause during a game update you should use the forever block instead. It’s similar to the game update, but it’s okay to block in it!

The forever block is in the loops category

isnt that phrase uses every letter in the alphabet without using the same letter

Ah ha! Thanks so much :slight_smile: it’s working now.