Adding Text Over Stages in Game Lab - Issues

gamelab

#1

This seems like an issue of order in which the text is called into the program over the stage. However, I have tried a couple different things and have not been able to make it work when called in after a condition is meet. Likely user error but any help would be useful for me. Thanks!

Here is a link to the code:Interactive Card


#2

@vchiaramonte

Hi Vinny,

The program seems to work for me. Can you explain what you want it to do that it’s not doing yet?

Thanks,
Elizabeth


#3

After reading what I wrote, I wasn’t very clear. I am having trouble with text overlaying sprites and stage images. My students are as well. I have been playing with the programs to figure out where I am going wrong.

I’m having a problem with text not being on the top of things. This text is not showing up anywhere. I assume, I am doing something wrong?


#4

@vchiaramonte
Hi Vinny,

There are a two things that are going on with the text that are making it hard to appear.

Because the “text” command you circled is inside a conditional, it’s only drawn when the mouse is clicked (and not drawn on frames when it’s not clicked). That means that once you let go of the mouse, when the draw loop is called again, the text will be covered up with the giant “stage” picture that is now visible. This is different from the way that the “stage” and “monster” sprites work in the program, because with those, you set them to visible inside the conditional, but they are actually drawn outside the conditional with the “drawSprites” command.

To solve that first problem, you may want to create a “textVisible” variable that is set to true when the mouse is clicked, and then check that it’s true before drawing the text. This will make the text behave more like the sprites do.

The second reason that you can’t see the text is that even within the draw loop it is going to be covered up with the “stage” sprite because “drawSprites” is called after the text is drawn.

Here’s an example of something that might work: https://studio.code.org/projects/gamelab/St40qXoqeNmR5aPkM9FC_bShQLY3yLPfFjnhYLo5Q5o

A hacky solution would be to just make the text into a sprite in the animation tab. There are some other ways to do it, but they use commands that are not in the course.

This might seem overly complicated, and I think that’s because the type of behavior that you want from your program is probably better suited to AppLab. GameLab is a little bit better with movement and interaction between sprites, and AppLab is a little better with things like this. Unfortunately, I think the draw loop is kind of getting in your way here.

Let me know if there’s anything else. I know this post is a little long winded.

Elizabeth