CSD Unit 3, Lesson 17 Create Your Own Card

A student of mine is making a card. The card has a wrapped present and some text telling the user to click the present. She wants the following to happen:

1 - Click on the gift in the card

AND

2 - Have the present turn into a ghost

AND

3 - Have the text disappear

So far, so good - a simple: If MouseDown THEN Present Visible = False and Ghost Visible = True.

But the student also wants:

4 - Text to disappear with the mouse down

AND

5 - Text to stay gone when the mouse is up again.

The student got the text to disappear and ghost to appear when she clicked, but when she lifted her finger from the mouse, the text came back.

When she wrote IF MOUSE UP, THEN TEXT VISIBLE = FALSE, the text disappeared altogether.

What is the actual command to make the text disappear since text is neither a sprite nor a variable?

Thank you very much.

Gary Ellis
Teacher

I’m wondering if a nested “if statement” would work, something like this:
If MouseDown
present gone
ghost appears
text disappears
If Mouse Up - same code to make text disappear as above (this if statement would be inside the first one so it only happens if the mouse goes down first)

If that works - cool! If not can you get the share link, so I can look at the code?
We can help better if you share the link. In the upper left click the share button and that will give you a shareable link.

Thank you very much. I would share the code except that I think the student has deleted a lot. I’ll see if she reconstructs it and then post it here.

I like your suggestion. I just don’t know how to write “text disappears” because it is neither a variable nor sprite, correct? How do you specify the text in the nested IF/THEN?

Thank you!

Gary

OK, I tried to create some code and completely botched it. Here is what I did:

Thank you for your help!

Gary

PS I didn’t know how to place “text” in “text.visible =false.”

I misunderstood and thought that the student had made the text disappear using some work around.

There is not a text.visible command because as you know it’s not a variable or sprite. There are some ways to make it seem to disappear. One of the easiest ways is to move the text off the screen to make it seem to disappear. (location would be greater than 300 for the x or y coordinate.)

I’ll take a look at the code later and try some things but wanted to get this idea to you sooner.

Hope this helps ~ CeciliaZ

1 Like

Thank you, Cecilia.

The student’s code (which I can’t find at the moment - hence, my attempt) did cause the text to disappear when the mouse was down, although I can’t think how.

Gary

I had another thought, but without seeing the code, I’m not sure if this could be the problem. There are different commands when pressing the mouse that interact differently. Depending on what she is using, switching from MouseDown to MouseWentDown might also solve the problem.

This is a great post that helps explain the difference. It refers to keys, but the same applies to the mouse. keyDown VS. keyWentDown

Can the student try some of the solutions suggested and see how they work?

Let me know if any of those solutions work or if you have any more questions. Thanks for all you do to help your student be successful. ~Cecilia

One other thing i’ve done in the past is to declare the text itself as a variable and then you can change the variable itself when need to be an empty string (ie. “”).

Here’s an example.

When the mouse is down, the text changes to be “” (nothing), so it disappears. If you wanted the text to stay hidden, you just remove the “else” part of the “if” statement.

Mike

2 Likes