调试样例pygame代码。super()可能出错,再次出现

2024-06-28 20:22:14 发布

您现在位置:Python中文网/ 问答频道 /正文

不知道怎么了。我只知道它不能执行。在底部找到trackback。你知道吗

编辑:已更新,仍不能正常运行。。。你知道吗

from livewires import games
SCREENWIDTH = 666
SCREENHEIGHT = 461
games.init (screen_width = SCREENWIDTH, screen_height = SCREENHEIGHT, fps = 100)
backgroundimage = games.load_image ("canvas.jpg", transparent = False)
games.screen.background = backgroundimage

class PhelpsAnimation(games.Animation):
    thePhelpsFiles = ["Phelps1.jpg",
                      "Phelps2.jpg",
                      "Phelps3.jpg",
                      "Phelps4.jpg",
                      "Phelps5.jpg",
                      "Phelps6.jpg",
                      "Phelps7.jpg"]

    def __init__(self, x = 333, y = 230.5):
        super (PhelpsAnimation, self).__init__(x = x,
                                               y = y,
                                               images = PhelpsAnimation.images,
                                               n_repeats = 1,
                                               repeat_interval = 5)
games.screen.add(PhelpsAnimation())
games.screen.mainloop()

回溯:

Traceback (most recent call last):
  File "C:\Users\COMPAQ\My Documents\Aptana Studio Workspace\PygameProject2\AstrocrashSoundandExplosion.py", line 28, in <module>
    games.screen.add(PhelpsAnimation())
  File "C:\Users\COMPAQ\My Documents\Aptana Studio Workspace\PygameProject2\AstrocrashSoundandExplosion.py", line 25, in __init__
    images = PhelpsAnimation.images,
AttributeError: type object 'PhelpsAnimation' has no attribute 'images'
Exception AttributeError: "'PhelpsAnimation' object has no attribute '_gone'" in <bound method PhelpsAnimation.__del__ of <__main__.PhelpsAnimation object at 0x02600C90>> ignored

Tags: inselfaddobjectinitscreenusersgames