我正在用pygame做一个小游戏,我想删除已经从屏幕上消失的对象。我想要做的是
class Projectile(pygame.sprite.Sprite):
    def __init__(self, path, move_speed, x_pos, y_pos):
        super().__init__()         
        self.rect = self.image.get_rect()
    def move(self):
        if self.rect.y < 0:
            del self但这并不管用。我该怎么办?
发布于 2015-12-10 07:14:03
好吧,我找到了一个解决方案。
在我的游戏循环中我做到了
for projectile in projectile_group.sprites():
    if projectile.rect.y < 0:
        projectile.kill()它可以杀死屏幕外的任何投射物。
https://stackoverflow.com/questions/34190759
复制相似问题