Unit 3, Lesson 17 Project
The student would like the “try again” message to appear for a certain number of seconds (about 3 seconds) when clicked.
What currently happens is if the present is clicked, “try again” shows up for a split second and goes away. Same thing for when the correct present is clicked, the “merry christmas” message only shows up for a split second.
Is there a way to set up a certain number of seconds for these messages to appear, but still make the present disappear?
You could use a variable to store the data that it has been clicked and make the text appear then make a timer for how long it should appear.
What would the variable and timer look like? This is my first time teaching this course and need help! I know the basics to follow the lessons, but when students ask for things beyond, I get lost
I’m not too familiar with Gamelab, but what I did was:
showText = true;
showText = false;
- In each of your
mousePressedOver(present1) if statements, I replaced the first three lines with a call of our function, so just
- In the draw loop - near the top - I added these lines of code (so I essentially moved them out of all the if statements and into just three lines!)
if(showText)text("Try Again", 100, 100);
- Finally, so that it doesn’t show when the user clicks the right present, you can add
showText = false; with the code where the user wins
Here’s the code if you want to take a look at it. I tried adding some comments and arrows so it’s a little easier to see what I changed.
Good luck with your class!
Thank you very much! That is very helpful.