第 9 步:让我们填写add_ball()函数。

  • 单击图形。去并将Soccer Ball拖到文档字符串下方。
  • 将精灵的名称从sprite更改为ball
  • 并将Set y Speed拖到下一行。将sprite更改为ball
  • set_y_speed()括号内的数字更改为-8

To navigate the page using the TAB key, first press ESC to exit the code editor.

def set_stage(): """ Sets up the stage for the game """ stage.set_background("soccerfield") stage.disable_floor() def add_player(): """ Adds a player to the stage for the user to control """ player = codesters.Sprite("player1") player.go_to(0, -155) return player def add_ball(): """ Adds a ball to the stage and sets its attributes """ def main(): """ Sets up the program and calls other functions """ set_stage() player = add_player() main()
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)