Python精灵模块的find_overlapping_sprites查找重叠返回角色指令

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

角色命令 >> Python精灵模块的find_overlapping_sprites查找重叠返回角色指令

简介:查找和角色绑定盒重叠的对象,返回列表。
例子:
from sprites import Group,Sprite,mouse_pos

bugs = Group('insect')
for _ in range(20):
    b = Sprite(tag='insect')
    b.gotorandom()

cat = Sprite(2)
while True:
    mx,my = mouse_pos()
    cat.goto(mx,my)
    # 查找和cat矩形重叠的对象,返回列表
    bugs = cat.find_overlapping_sprites()
    print(bugs)

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