Unit 3 lesson 17 code help

[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.]

I had a student generate this for the Interactive Card project at the end of Unit 3 Chapter 1: https://studio.code.org/projects/gamelab/mHBfm-SffZm88lQzcm6tinK2_5qoIL_8pzzlKtgWjMg

They (and I) expected that each ball would disappear when clicked and then when a total of 3 clicks was recorded the net would become visible with the 3 balls “in” it.

The balls do not disappear when clicked.

I pared the code way down to try a variety of things. I changed the .visible = false to sprite.tint and sprite.rotation and was able to get changes. .visible continued to do nothing.

@william.warren, This is a bit tricky, but … since your student drew the background outside of the draw loop (including the rectangle that is the grass), the background is drawn exactly once. Then, the balls are drawn (above the background) and then the draw loop executes the rest of the code.

When the balls are clicked, they should become invisible, however, that only happens by having the background drawn again to cover up the original instance of the balls. Since the background isn’t redrawn to cover up the original balls, they don’t disappear. They are no longer drawn, but the original drawing isn’t covered up.

The solution is to put the background (and rectangle) blocks inside the draw loop.

Hope this helps!

Mike

2 Likes