Debugging Lesson 17

A student of mine is trying to create a program using counters. The idea is to collect all 4 tokens and these are being tracked using a counter. Once the counter equals 4 the Treasure Chest Opens.
We are also making sure that the token in destroyed once it is collected (as we do not want to collect the same token 4 times.)
However, the problem we are having is that the counter is not updating correctly. Any help would be greatly appreciated.



When I tested it, I noticed that the counter goes up by more than 1 each time a sprite is clicked. So, I created a watcher to watch purple.x

When I clicked on purple, it disappeared (due to the destroy block), but I noticed that purple.x still existed and updated, so I think the documentation for destroy may not be fully accurate. It appears to hide the object, but it still exists.

Here’s a different option that I tested and that does work.

Instead of using purple.destroy(), I used purple.y=purple.y+2000;

This immediately moved the purple object several thousand pixels below the screen and the counter only updated by 1.

This may be a workaround for you.

Good luck!



Hello! Mike,
Thanks so much for all your help. I so appreciate the work around. I was able to help my student.