• 中,将 Add Value 拖动到 left_key() 事件内部。

确保指令前面有一个绿色区块 ····

  • 将变量更改为 left_count

每次按下向左键时,这个指令将向left_count 的值添加 1

例如,如果玩家按向左键三次,则left_count 的值将为 3

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

stage.set_background("halfcourt") sprite = codesters.Sprite("player4") sprite.go_to(215, -175) net = codesters.Sprite("basketballnet") net.go_to(215, 175) ball = codesters.Sprite("basketball") x = random.randint(-100, 150) ball.go_to(x, -25) stage.set_gravity(10) stage.set_bounce(.8) ball.set_gravity_off() net.set_gravity_off() left_count = 0 down_count = 0 def left_key(): ball.move_left(10) # add other actions... global left_count stage.event_key("left", left_key)
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)