Text does not show up in student project

I have a couple students whose text in their interactive cards are not showing up despite being drawn in the draw loop after the background. If we remove the background the text shows up but not otherwise. Any thoughts? I can copy the code here if that would help.

The text elements need to be drawn last after the sprites are drawn. If the sprites are in the same position as the text, they overlap the text. Try changing the order of the commands.

1 Like

If mmathews suggestion doesn’t help, and you could share a link to the shared project, I’m sure one of us would be happy to look at it. :slight_smile:

1 Like

Here’s the link:

She has tried with the text in the draw loop, and outside of it. If we remove the background (found in the animation library under background) then you can see the text.

@ccagle

Hi Chantal,

The reason the text isn’t showing up is because it’s outside the draw loop. Game Lab runs all of the code outside the draw loop, then runs the code inside the draw loop over and over.

In the program you linked, the text is written, then the draw loop code runs and draws a background over it (many times, no less). If you put the text inside the draw loop (but after the background command), then the text will be redrawn right after the background is drawn every time, and you will be able to see it.

Elizabeth

There’s no background being drawn in the draw loop. She tried the text in the draw loop again - we’d tried it before - but it still doesn’t work. Here’s the link to that

@ccagle

Hi Chantal,

Thanks for the follow up. In the code that you just sent, the text is getting covered up by both the grass sprite and the sun sprite. (I’m sorry, I was referring to the grass sprite as the “background” in my previous post.)

No matter what you do to the sprites, they do not get drawn to the screen until you run the “drawSprites” command. Because this command is being run in the draw loop after you draw the text, the sprites are being drawn over the text. If you put the text commands after the “drawSprites” command inside the draw loop, the text will be drawn after the sprites and will be visible.

Here’s the same program with the text drawn after the sprites are drawn: https://studio.code.org/projects/gamelab/ZfGa7thwy7tdPd__Awml3X1nxvOvn5Hyn0T9VYzzYJg

The student will still probably want to move the text, but you can see that this time it appears over the grass and sun sprites because I switched the order of the commands in the draw loop.

Elizabeth

1 Like

Yeah! Thank you! That solved the problem. She will be so glad. She’s really been doing great and this stumbling block has been frustrating. And now I’m a bit smarter too!

This helped me too- thank you :slight_smile:

1 Like

I’m so glad you found something helpful on the forum! Welcome!