开发者

Debugging sample pygame code. Possibly error with super(), yet again

Can't figure out what's wrong. All I know is that it doesn't execute. Find the trackback at the bottom.

EDIT: UPDATED, still doesn't run as should...

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:

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 objec开发者_运维技巧t '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


It's the images = PhelpsAnimation.thePhelpsfiles parameter. thePhelpsfiles is not an attribute of the PhelpsAnimation class you've defined. It should work if you change that to just images=thePhelpsfiles.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜