Python精灵模块的stampcollide指令

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

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

简介:编号为item的图章和other的碰撞检测,别名是collidestamp。
它有三个参数,第一个参数是item,检测是否要碰到的图章。
第二个参数是other,可能是图章也可能是角色,默认为角色自己。
第三个参数是scale,用于缩放自己的绑定盒。
例子:
from sprites import Screen,Sprite,mouse_pos

screen = Screen()
screen.setup(480,360)

bug = Sprite(pos=(0,0))
d = bug.stamp()
bug.fd(50)

while True:
    bug.goto(mouse_pos())
    if bug.stampcollide(d): # bug是否碰到了编号为d的图章
        bug.say('碰到',delay=0.1,wait=False)
    else:
        bug.say('',delay=0.1,wait=False)
    

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