Python精灵模块的contain是否包含指令

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

角色命令 >> Python精灵模块的contain是否包含指令

文字,圆点,线条,图章都是一个个的项目,都有编号。 这个命令判断角色是否包含某item。
例子:

from sprites import Sprite,mouse_pos

bug = Sprite()
screen = bug.screen
w = bug.write('编程')
bug.fd(202)
bug.randomcolor()
d = bug.dot(50)
bug.addy(250)
z = bug.stamp()
bug.goto(100,200)
bug.pendown()
bug.pensize(10)
bug.fd(10)
line = bug.currentLineItem
bug.penup()
bug.scale(2)
while True:
    mx,my = mouse_pos()
    bug.goto(mx,my)
    if bug.contain(w):screen.title('完全包括文字')
    elif bug.contain(z):screen.title('完全包括图章')
    elif bug.contain(d):screen.title('完全包括圆点')
    elif bug.contain(line):screen.title('完全包括线条')
    else:screen.title('')
writed by lixingqiu 关注"异编程"微信公众号,获取更多关于Python精灵模块的咨讯: