【发布时间】:2021-06-21 15:47:12
【问题描述】:
我做了这个简单的类,由于某种原因它使 python 崩溃了,我不知道为什么
这是代码
import pygame
pygame.init()
class Entity(pygame.sprite.Sprite()):
def __init__(self, pos, size):
super().__init__()
这是我得到的错误
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "entity.py", line 4, in <module>
class Entity(pygame.sprite.Sprite()):
File "C:\Users\playe\AppData\Local\Programs\Python\Python38\lib\site-packages\pygame\sprite.py", line 124, in __init__
self.add(*groups)
File "C:\Users\playe\AppData\Local\Programs\Python\Python38\lib\site-packages\pygame\sprite.py", line 142, in add
self.add(*group)
File "C:\Users\playe\AppData\Local\Programs\Python\Python38\lib\site-packages\pygame\sprite.py", line 142, in add
self.add(*group)
File "C:\Users\playe\AppData\Local\Programs\Python\Python38\lib\site-packages\pygame\sprite.py", line 142, in add
self.add(*group)
[Previous line repeated 992 more times]
File "C:\Users\playe\AppData\Local\Programs\Python\Python38\lib\site-packages\pygame\sprite.py", line 137, in add
if hasattr(group, '_spritegroup'):
RecursionError: maximum recursion depth exceeded while calling a Python object
我该如何纠正这个错误?
【问题讨论】:
标签: python python-3.x pygame pygame-surface