Unit 3 lesson 17 interactive card - mouse input

The student working on this code would like to click on the bear or panda and have the sprite move as the mouse moves. So far, we get the sprite to move but it will not continue moving with the mouse. How can I help this student move forward? Any suggestions are appreciated.

[Code.org - Game Lab]

@heath.kelley If you were to use mouseIsOver(Panda) instead of mouseIsPressedOver(Panda), that would allow your code to execute as long as the mouse is over the Panda, however, you might want to start contact by clicking.

In that case, you would probably want to have some kind of variable that starts off being false (ie. var sticky=false;)

Then, have the MouseIsOverPanda only work if sticky is true, so you click once to make sticky true and then it will follow the mouse.

That’s some pseudocode and there may be another way to do the same thing, but that should work.