Text on screen during draw loop?

My students are working on the interactive card project for U3 L18, and I’m wondering what is the best way is to keep a message displayed on the screen within a draw loop once it is triggered by button or mouse input?

Students are familiar with the keyDown and mouseDown commands, but that only works while the user holds the key down. I thought keyWentDown would be a step in the right direction, but it only works until the draw loop updates.

Here’s a working example of what I currently have, where the intended behavior is for the message to stay on the screen after pressing ‘m’ while the program runs.

I suppose I could do something like a simple Boolean variable, but wonder if I’m missing something with the yellow blocks.

Check out this thread to see if it helps

@jdiodato,

I agree with you that using a boolean is a decent solution in this situation. The nature of the drawSprites block does completely erase the screen. Another possibility is intializing the message screen as a message with no content or with the content “” so until the button is pressed, it is displaying the message, but it’s an empty message. Then, when the button is pressed, the string could be replaced with an actual text message and in that situation, the message would now be redrawn with the actual content inside.

There may even be a third way to do it, but those are the ones I’ve seen and used before.

Mike