第 7 步:让我们更改默认代码以自定义我们的碰撞事件。

  • 单击碰撞事件内的代码编辑器
  • 删除行: ···· spritego_to( 0 , 0 ) ¬
  • 现在我们的精灵将留在原地,而另一个精灵将“隐藏”,所以看起来我们的精灵捡到了它!

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

stage.set_background("winter") sprite = codesters.Sprite("snowman") sprite.set_size(.5) sprite.pen_down() sprite.glide_to(5, -6) def collision(sprite, hit_sprite): sprite.go_to(0,0) hit_sprite.hide() # add any other actions... sprite.event_collision(collision)
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)