python - Pygame 组更新不带参数

标签 python pygame typeerror

我在其他地方读过类似的问题,但它说只是将“self”添加到函数定义中。当我检查文件的 self 时,它实际上已经先有 self 关键字了!这是回溯:

Traceback (most recent call last):
  File "C:\Users\Brenda\Documents\The Nick Folder\Mobile Fortress War 3\MFWRT3 - TileClass test\Title.pyw", line 142, in <module>
    SelectServer.main()
  File "C:\Users\Brenda\Documents\The Nick Folder\Mobile Fortress War 3\MFWRT3 - TileClass test\SelectServer.pyw", line 44, in main
    Main.mainloop()
  File "C:\Users\Brenda\Documents\The Nick Folder\Mobile Fortress War 3\MFWRT3 - TileClass test\Main.pyw", line 72, in mainloop
    globals.alltiles.update()
  File "C:\Python32\lib\site-packages\pygame\sprite.py", line 462, in update
    s.update(*args)
TypeError: update() takes no arguments (1 given)

我这样调用它:

globals.alltiles.update()

有人可以帮忙吗?

最佳答案

我有点晚了,但这可能是因为每张卡的更新方法声明不正确(我假设是 pygame.sprite.Sprite 的子类)

它应该声明为“def update(self)”而不是“def update()”

关于python - Pygame 组更新不带参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7624601/

相关文章:

python - 服务器,它将杀死并再次运行无限循环

python - 如何从列表 Python 创建类实例

python - 看不懂这个AttributeError : module 'turtle' has no attribute 'Turtle'

python - 如何通过django admin上传

python - 我应该在 Pygame 中使用什么 gui 工具包?

python - 覆盖 __class__ 引发 TypeError

python - 如何将 Sprite 从矩形更改为图像?

python - 如何根据图 block 的位置显示图 block ?

python - TypeError: __init__() 正好需要 4 个参数(给定 1 个)

python - Django - TypeError at/statements/int() 参数必须是字符串、类似字节的对象或数字,而不是 'AnonymousUser'