CSD Unit 3:Lesson 14 Interactive Card

One of my students is having a problem with the .visible command. He wants the door to disappear when the mouse button is clicked. He has it set so if the condition is met (mousebutton down) then door.visible=false but the door won’t disappear. Any ideas?

Here’s a link to his project.

https://studio.code.org/projects/gamelab/n8Xrz1OzR72yHJ3CfNNGVCMRpdCgssYE1J3cU0somBw

@ccagle

Hi Chantal,

In the if statement, the door disappears when the mouse goes down, but then it is immediately made visible again on the next iteration of the draw loop, because the mouse didn’t go down the next time. If you remove the “else make the door visible again” part of the code, the door should stay invisible. When exactly did the student want the door to be visible again?

Elizabeth

We tried that and the door never becomes invisible at all. See my remixed example below. I’m not sure what his next step is because we’ve been stuck on making the door disappear!

Okay, I see the problem now. You’re actually just still seeing the door from when the sprite was visible before in the draw loop, because you’re not covering up the old sprites. (The house sprite has a gap where the door should be, so the old door from previous iterations of the draw loop is showing through, even though it’s not visible in the current iterations of the draw loop).

At the beginning of the draw loop, add a background("black") or background("white") to your code, and it should work.

Elizabeth

1 Like

Great! I’ll pass this on to the student on Monday. He’s going to be glad to move on as this has been frustrating him. You are a big help!

1 Like