python - 调试示例 pygame 代码。 super() 可能再次出错

标签 python debugging animation pygame livewires

不知道出了什么问题。我所知道的是它没有执行。找到底部的引用。

编辑:已更新,仍然没有按预期运行...

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

最佳答案

这是images = PhelpsAnimation.thePhelpsfiles 参数。 thePhelpsfiles 不是您定义的 PhelpsAnimation 类的属性。如果您将其更改为 images=thePhelpsfiles,它应该可以工作。

关于python - 调试示例 pygame 代码。 super() 可能再次出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6576811/

相关文章:

java - 意外按下不允许安装应用程序并记住 - Android Studio

ios - swift 中 UILabel 的彩色动画

css - 为什么这个不透明动画不起作用?

python - 保存一系列命令并将其重新加载到 Python shell 中

wpf 调试错误输出 System.WIndows.Data 错误 25

python - 包括 CMU pocketsphinx gstreamer 的语法

debugging - 在 Delve 中调试时理解 `time.Time` 值

jquery - 如何在jQuery中为每个动画设置不同的帧速率

python - 检查大量字符串是否存在的有效方法

python - 如何在 python 中添加 L1 规范化?