Make text appear and stay on screen

I have a student who is trying to have text appear on screen after clicking the mouse button and stay there. Right now, the text will appear but does not stay on the screen. This is her current code: https://studio.code.org/projects/gamelab/ZGradt40NzJNx9U8vMh9JXg6F6j_A7O7q76aloz73aQ

Any suggestions?

My workaround for her right now is to create a sprite with the same color as the background and cover the text. Then control the sprite’s visibility with the click, but there has to be an easier way.

Good idea for an interactive card! I’m sure there are a number of ways to do this.

My solution was to create a variable called gender that is set to “” at the beginning of the program (var gender=""). Then, at the same place you draw the background, have it display the text in blue and size 50. When the program starts, it will display nothing because there is no value to it.

Then, in the if loop, change the value of gender to equal “Boy” and now, everytime the background is drawn, it will “redraw” the text as well.

Here’s a link to my version if you are interested …

Mike

1 Like

Thank you, Mike! That’s exactly what we were looking for. I never think to use variables in the text block for things like that. Great idea!

1 Like