I need another pair of eyes on this - just can’t figure out why when we click on an orange it adds more than one to the clicks variable and then her basket pops up too soon. Help me please!!
https://studio.code.org/projects/gamelab/L2Fm7j0Kdsgg-1f3Zqi-L7sfo712UMv5SkPWiCM9W9k
Emily,
Seems to me, not knowing the full intent of the project, that the variable continues to increase rapidly when over the orange and clicked. I added a console log
block and one click on an orange put the click
variable at 3 and 4, which would cause issues with the basket popping up when click variable reaches 5. You could have the orange disappear on a click and then if all the oranges = false then the basket would appear.
Hope that helps!
Brad
Thanks so much for the response. I will give her this suggestion tomorrow. We had the console log on there and could see the problem, we’re just confused because she used this program given as an example from code.org as the inspiration for her project. It seems like hers is set up the exact same way but isn’t working…it’s just driving us crazy. Something simple we’re missing, I’m sure?
Another way to do it would be to move the orange out of the way once the mouse is pressed over it. Like move it off of the screen so the next time through the draw loop, the mouse could not be pressed over it and thus the counter would not increase beyond one per “click”.
if (mousePressedOver(orange1)) {
click = click + 1;
orange1.visible = false;
//move that orange!
orange1.x = -300 ;
}
Yeah, the flowers get moved to the vase when they are clicked, which is why it’s not as much of a problem for the flower exemplar. You can get a funny bug, though, if you move one flower over, then start clicking where you know it’s going to be.
Elizabeth