You're misunderstanding. self
is only an internal reference. Within the class, you refer to self
. Otherwise, you refer to the sprite
object directly as such,
class A():
self.health = 5
class B(): # This class already has a self function
for sprite in all_sprites:
if pygame.sprite.collide_circle(self, sprite):
sprite.collide = True
sprite.health -= 0.1
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…