U3 L28 Design a Game Help - clicking and changing backgrounds

Need some help with a student’s project and I’m not sure how to help him. Thank you very much in advance for anyone who can give some input on how to get these backgrounds clickable and displaying only one background at a time and making the other ones not visible.

Here is the link to student’s project: Game Lab - Code.org

Students wants to be able to click on a door and for it to change to a different background, making the original background invisible and the new background visible.

Using .visible with the background does not work and gives the red error.

Student has tried to put all the backgrounds as visible and created conditional statement when door is clicked.

Hi @msima,

Fun game. I think the key the to solving this is to break down the problem step-by-step. Also, I notice that Door1 and Door3 are the doors displayed vs Door1 and Door2 (I’m just mentioning this as I break down the issue as I see it below):

  • In the draw loop, the main scene is start(). In my mind - that is the only function running. If the red is needed, then add it to start().
  • In start, if Door1 is clicked/mousePressOver(Door1), then Screenchange = 1 (you don’t need the counter pattern here as I see it) AND run the background1() function.
  • if Door2 is clicked, then Screenchange = 3 AND run the death() function.

Not sure this is everything as intended but it should provide a path where the scenes can be adjusted as intended. When it is coded this way, the function changeScreenVAR is not needed. Also, not sure why the sprite.visible blocks were not working. They should absolutely work as long as the sprite variables were declared and the animations were set.

I hope this helps
~Michelle