from sprites import Sprite,Key
bug = Sprite()
screen = bug.getscreen()
bug.ondrag(None) # 让角色不可拖曳
bug.say("现在我不能被拖曳")
bug.say("按下并松开空格键我就能被拖曳了")
space = Key("space") # 实例化空格键
screen.listen() # 监听按键检测
# 当没有按下并松开空格键,则一直刷新屏幕
while not space.downup():screen.update()
bug.draggable()
screen.mainloop()
|