我想围绕纹理的物理路径创建物理体(剪掉 Alpha channel )。如何在 pygame 中做到这一点?会有效果吗?
player_idle = pygame.image.load('data\img\player\idle\idle-1.png')
最佳答案
您可以使用mask
模块,尤其是pygame.mask.from_surface()
功能:
Creates a Mask object from the given surface by setting all the opaque pixels and not setting the transparent pixels.
然后您可以存储结果 Mask
对象作为 Sprites 中的 mask
属性,例如使用pygame.sprite.collide_mask()
用于像素完美的碰撞检测。
关于python - Pygame Sprite 透明度碰撞,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57886086/