2011-07-04 34 views
1

无法弄清楚什么是错的。我所知道的是它不会执行。在底部找到引用。调试示例pygame代码。可能与超()错误,再次

编辑:更新时,仍然不作为应该运行...

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 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 

回答

1

这是images = PhelpsAnimation.thePhelpsfiles参数。 thePhelpsfiles不是您定义的PhelpsAnimation类的属性。它应该工作,如果你改变只是images=thePhelpsfiles

+0

再看一遍,试着改变它一下。你告诉我什么,仍然没有工作。 – Louis93

+0

明白了,愚蠢的错误。以不同的名称呼叫...对不起! – Louis93