1 回答
TA贡献1798条经验 获得超7个赞
您self.initialize()在while-loop 中使用,但self.只能在内部使用class
您应该使用running = True/False退出while循环并稍后使用car_racing.initialize()
if __name__ == '__main__':
screen = pygame.display.set_mode([800,600], 0 , 32)
startscreen = pygame.image.load(".\\img\\startscreen.png")
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
#self.initialize()
running = False
screen.blit(startscreen,(0,0))
pygame.display.update()
car_racing = CarRacing()
car_racing.initialize()
car_racing.racing_window()
添加回答
举报