Unit 5 Lesson 2 Bubble 14


#1

Mar 4, 07:19 PST

I added the code from a students assignment. I know I should be able to find the problem but it is not popping out to me and the example for this assignment does not make it very clear. When she clicks the object, it reads that she has clicked the background and the object. The lesson also did not allow her to name her background screen at bubble 14 but the program gave her two names for it. Just wondering if you could look at if for me. Or if you would need more info as well to figure out what is going on.

onEvent(“image1”, “click”, function(){
setPosition(“image1”, randomNumber(0, 320), randomNumber(320, 0));
console.log(“Heart Clicked”);
});
onEvent(“StartBtn”, “click”, function(){
setScreen(“GameScreen”);
});
onEvent(“GameScreen”, “click”, function(event) {
console.log(“Background Clicked”);
});
onEvent(“GameScreen”, “click”, function(event) {
console.log(“GameScreen clicked!”);
});


#2

That’s always the case. A click on any object on the screen also counts as clicking on the screen. The way around this is to add an image and have that image cover the entire screen. If there is a button or another image on top of it, when they click on that it won’t count it as a click on the background image. Look at this example: https://studio.code.org/projects/applab/WyRjJDltdjqkrbOlgxRp56UMxdVQcN30m-t6Skkvnzw

Both screens look the same but in screen1 the image is the screen. In screen2 the image in a separate design element inserted on the screen. Every time you click on the button on screen1 it registers as a click on on the button and the screen. If you click on the button on screen2 it shows a click on the button but not the image (click off the button and it will count as a click on the image).

I know it’s confusing but I hope that helps.


#3

I think I know what you are talking about but I am not sure that I know exactly how to describe it to my student on code.org. I guess I will give it another try tomorrow.


#4

The bottom line is “You can’t use click on the screen as an indication that the user missed clicking on an object. You must insert an image that covers the screen and use that”


#5

she has done that, and it still reads as if she has clicked both the screen and the heart image when she clicks the heart. it is not distinguishing between the top image and bottom/background image. when she clicks the heart it reads as both have been clicked and we cannot figure out why.


#6

Can you have her click “share” and post the link here?


#7

I will try and have her do that this morning once school starts.


#8

https://studio.code.org/projects/applab/Oz1dm6_A96_Mzc-l5fQEdBsZ_e8dn5qMd9GcwhTnQro

Here is the link. We are going to take a look at it right now and see if we can see where we went wrong.


#9

We finally figured it out. Thanks for sharing the example.