[Posts in the debugging category need to have the following pieces of information included in order to help other teachers or our moderator team best help you. Feel free to delete everything in brackets before posting your request for debugging help.]
*Link to the project or level:
I am creating an interactive card. I am showing and hiding text. The card works fine through Scene 2. What I need to have happen for Scene 3 is the green present disappears and so do the instructions. (I am going to add additional text here.) The green present disappears, but the the red present reappears and with it, the text for that Scene. I have it set to click the spacebar. The green present disappears as it is supposed to and the coal appears; however, so does the red present. It reverts to scene 2.
I have looked through the code trying to figure out why Scene 2 is coming up again and I can’t figure it out
The link you pasted is just to the level. To share your code, make sure to use the link provided with the blue SHARE button.
Here is a great post on how to hide text. It sounds like you were successful in doing this in scene 2 but it isn’t staying hidden - is this correct? With 3 scenes, I am wondering if you need another variable such as text3Visible?
If the linked forum post isn’t helping, use the share link to share your project so others can take a look. good luck!
~Michelle
Ah yes. It is a fun card with lots going on:) I think the main cause of the present showing at the wrong time is there are many conflicting if statements. For example, when line 53 (if clicks >=20) is true it is also possible that line 70 is true (if clicks >=25). And, present.visible == false when clicks is >=20 but present.visible == true when present2.y>200 and both of these are essentially true at the same time.
My suggestion is to plan out what should be true for each of your scenes and set your variables and if statements accordingly. I am guessing you also need to use && for multiple things to be true at the same time. I am not really sure what stops and starts your scenes but for example:
scene =1
if (mouseWentDown(“leftButton”)) {
click = click + randomNumber(1, 5);
}
if (present.visible && clicks >=20 && clicks <=25){
present.visible = false;
scene=2;
anything else that should happen
}
The && block is in the MATH section. I think planning your ifs and using && will help to make sure only one if statement is true at the same time.
Yes. Your variables are all global meaning they are declared at the top of your code outside any function or event. So, no matter how the value changes, they apply to the entire program.
I suggest using the watcher in the lower right of your program to follow all of your conditions. This will help you decide when one condition is true and another false. Just enter the variable or condition name and hit the “+” sign and watch the values as you run the program.
The sound block can be tricky! Although you set loop to false in the code block, because the condition remains true (clicks >=20), it repeatedly plays the sound. The solution in this post creates a sound variable that starts at 0 (line 6). As soon as the condition that should stop the sound occurs (line 10), the sound variable is incremented/changed (line 16) so that the condition to play the sound is no longer true (line 18).