Unit 6 Lesson 9

[ So the student is trying to get his play to move smoothly up the screen and has tried using the counter pattern but we are having difficulty getting it to function properly when the button is pushed it just jumps to a spot. We arent quite sure how to make it just move up the screen ]

Link to the project or level: https://studio.code.org/projects/applab/-yOwrj76CHtGVmkNJESC3B0p1Mw9tiKiOl3WJDsH2mU
What I expect to happen: the image31 needs to move up the screen after the onboard button is pused
What actually happens: It just jumps to a new position or doesnt move at all
What I’ve tried: inputing the counter pattern and updating the ID, putting the variable inside the loops.

Hi Kayla!

This is a task that’s easier to do in GameLab with the draw() loop, but a little trickier in AppLab which uses events to control the program rather than a continually running loop. If at all possible, I’d try to direct this student to having an event (like a button click) move the person up the screen a little bit at a time rather than automatically. They’re on the right track with using the counter pattern, but would need to put that inside one of their event functions instead of outside the code. An outline of their code would look like:

  • get the y value using getProperty()
  • Use the counter pattern to increase the value
  • set the new y value using setProperty()

If your student is determined to do this automatically similar to GameLab, they’d have to investigate some of the timing blocks in the Control section of the toolbox (for example: setTimeout() and timedLoop()). These blocks are beyond the scope of the curriculum, but they do have documentation and examples for them to investigate on their own.

Hope that helps!
Dan - Code.org Curriculum Writer