Python精灵模块的saveshape指令

所有命令 单独命令 屏幕命令 角色命令

角色命令 >> Python精灵模块的saveshape指令

简介:保存角色当前造型图到磁盘。
例子:
import time
from sprites import Sprite,Key

bug = Sprite()
bug.scale(3)
bug.say("按空格键并松开保存我的造型")
screen = bug.getscreen()

space = Key("space")        # 实例化空格键
screen.listen()             # 监听按键检测

# 当没有按下并松开空格键,则一直刷新屏幕
while not space.downup():screen.update()
filename = str(time.time()).split('.')[-1] + ".png"
bug.saveshape(filename)    # 保存造型

bug.say("保存完毕" + filename)
screen.mainloop()

writed by lixingqiu 关注"异编程"微信公众号,获取更多关于Python精灵模块的咨讯: