App Lab Image Location

[App Lab -]

Good afternoon,

My student is trying to have an image move when the healthy or unhealthy button and then when it gets to the edge switch screens. Can anyone point us in the right direction?

Thanks so much!

Johnna Costanza


You have a good start by defining x. From there, I will break down the problem as I see it and see if that helps you complete the task.

  • First, the x variable should probably just be initialized or set equal to 0 at the beginning of the code. The variable does not really have a function at the beginning so setting it to equal just initializes it and gets it ready to be used later.
  • Most of the action will then take place in the buttons. So, inside the healthy button event you will set x equal to the current position of the image. There is a getXPosition block for this. Remember that x has been declared so you don’t need a var. You’ll just say x = getXPosition.
  • Next, set the x position of the image so that each time you click the button it moves along the x axis. To do this, there is a setProperty block. Using this block, you would set the x property of the image to the counter pattern of x = x + 1 (or any number depending on how fast you would like it to move). So, the counter pattern of x=x+1 goes in the final property of the setProperty block.
  • The unHealthy button would be the exact same except the counter pattern would subtract instead of add.

I hope I understood the question and this guides you to moving your image.
Good luck! :slight_smile:


Thank you very much for your help!