STEP 12: Hm. We want our ball to move, not our soccer player!

We can use a sprite's variable name to assign actions to a sprite. This is called dot notation.

  • In your .set_x_speed(5) command, change the name in front from sprite to ball.
  • Click Run. Now, your ball should be bouncing horizontally back and forth on the stage.

Not started reading
microbit = codesters.Microbit() microbit.show_string("hello") stage.set_background("soccerfield") sprite = codesters.Sprite("athlete2") sprite.move_down(150) def button_a(): sprite.move_left(50) microbit.event_button_a(button_a) def button_b(): sprite.move_right(50) microbit.event_button_b(button_b) ball = codesters.Sprite("soccerball") sprite.set_x_speed(5)
Not started