gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 19:29:41 25 4
gpt4 key购买 nike

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

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

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com