Python精灵模块的collide_others碰到其它角色指令

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

角色命令 >> Python精灵模块的collide_others碰到其它角色指令

简介:角色的碰到其它角色。它的参数为一个字符串。这个字符串表明其它角色的标签。
例子:
from sprites import Sprite,mouse_pos

for x in range(5):
    # 新建标签为'insect'的角色
    b = Sprite(tag='insect')
    b.gotorandom()

cat = Sprite(2)
while True:
    mx,my = mouse_pos()
    cat.goto(mx,my)
    # 检测是否和标签为'insect'的有重叠
    r = cat.collide_others('insect')   
    if r:
        print('碰到虫子' , r)

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