Making Text Visible and Invisible

My student has a game in which there is a present and some text stating that you have to shake your mouse to get a present. He has a counter that shows you the unwrapped gift in a new scene after 10 seconds (I’m not sure that you even have to shake the mouse to reveal the gift).

My student wants the initial text to disappear, and when Counter2 is less than 17, he wants new text to appear congratulating the person for winning a car. The problem is that the second batch of text does not appear.

I wondered if he could use text.visible just as you would with a sprite, but apparently not.

I wondered if you could make the text a variable and use .visible, but the student said that you can’t use it unless it’s a sprite.

CSD UNIT 3 LESSON 17 BUBBLE 7 (OR 4 - SAME CODE!?)

[Game Lab - Code.org]

Thank you very much for your help!

Gary Ellis

@gellis1,

They are correct. text.visible isn’t a possibility here in game lab, but there are work arounds.

I like setting my text as a variable var phrase = ""; (which sets the variable phrase to be an empty string of text.

Then, in the conditional block, you have some code that says if the counter is less than 17, phrase = “Congratulations! You won the car!”

This replaces the empty text with some real text and it shows up.

There was a thread just last week with some other options if you want to look at that.

Good luck!

Mike

1 Like

The link to the code should work now.

The student tried your suggestion, but couldn’t make it work. He was also trying to be able to alter text size and location, but couldn’t figure out how.

Thanks for your help!

Gary

@gellis1,

I don’t see that there are any text blocks in the project. Have him add the text and try what he can do and we can perhaps help if it isn’t working after that…

Right now, he had multiple counters, but isn’t using any of them, so I’m not fully clear what he intends to happen.

Happy to look at it again if he tries and can’t get it to work!

Mike

Thank you very much, Mike. I appreciate all the help you’ve given me over the past few years. In this case, the student spent about a week trying to get things to work, and yesterday he finally gave up and in the process took out the text. I gave him a copy of what you said, however, in case he could muster the energy to give it one more shot.

Gary

2 Likes