hyt8853 发表于 2023-1-13 12:07:18

飞机大战报错

Traceback (most recent call last):
File "D:\project\gameplane\gameplane.py", line 76, in <module>
    main()
File "D:\project\gameplane\gameplane.py", line 45, in main
    me = myplane.MyPlane(bg_size)
File "C:\Users\23627\AppData\Local\Programs\Python\Python310\lib\site-packages\pygame\sprite.py", line 116, in __init__
    self.add(*groups)
File "C:\Users\23627\AppData\Local\Programs\Python\Python310\lib\site-packages\pygame\sprite.py", line 134, in add
    self.add(*group)
File "C:\Users\23627\AppData\Local\Programs\Python\Python310\lib\site-packages\pygame\sprite.py", line 134, in add
    self.add(*group)
TypeError: pygame.sprite.Sprite.add() argument after * must be an iterable, not int

实例化 me = myplane.MyPlane(bg_size)飞机时
bg_size 警告 Expected type 'AbstractGroup', got 'tuple' instead

KeyError 发表于 2023-1-13 12:25:03

完整代码。

hyt8853 发表于 2023-1-13 12:45:47

KeyError 发表于 2023-1-13 12:25
完整代码。

已解决感谢,pycharm 快捷输入 __init__选成 __int__
页: [1]
查看完整版本: 飞机大战报错