14 步:让我们设置当球员投篮时会发生什么。

碰撞事件让计算机知道当两个精灵碰撞时要做什么。

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

stage.set_background("halfcourt") sprite = codesters.Sprite("player1") sprite.go_to(-175, -150) net = codesters.Sprite("basketballnet") net.go_to(215, 175) stage.set_gravity(10) sprite.set_gravity_off() def click(sprite): ball = codesters.Sprite("basketball") ball.go_to(-175, -125) ball.set_x_speed(10) ball.set_y_speed(10) # add other actions... sprite.event_click(click) stage.disable_right_wall()
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)