当我调用Zombie类中的render()方法时,我想将Zombie对象的一个实例添加到ZombieList.list中。当我尝试这样做时,它说
list类的未解析属性引用ZombieList。
我应该尝试以另一种方式做到这一点吗?
class ZombieList:
def __init__(self):
self.list = []
for zombie in self.list:
ds.blit(zombie.image, (1000, random.randint(10, 790)))
class Zombie(object):
def __init__(self):
self.attack = 3
self.speed = 5
self.health = 30
self.image = pygame.image.load("Assets/green zombie.png")
self.zombieList = []
def render(self):
ZombieList.list.append(self)
ibeautiful
慕盖茨4494581
摇曳的蔷薇
相关分类