0
我正在使用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
但這並不起作用。我該怎麼辦?
你在哪裏存儲對象? – jwodder
@jwodder在一個組中,我後來從中得到一個精靈列表並迭代它。我現在解決了我的問題。 – ca1ek