我是python和pygame的初学者,我正在尝试使用类生成一些对象,并对其进行筛选。但我不知道如何消除错误“typeerror:参数1必须是pygame.surface,而不是class”。。代码如下:
ddong(pygame.Rect) :
def __init__(self):
self.ddong = pygame.image.load('C:/Users/user/Desktop/게임 프
트/pygame_basic_.py/enemy.png')
self.ddong_size = self.ddong.get_rect().size
self.ddong_width = self.ddong_size[0]
self.ddong_hight = self.ddong_size[1]
self.x_pos = randint(1, screen_width - self.ddong_width)
self.y_pos = 0
self.rect = self.ddong.get_rect()
self.rect.left = self.x_pos
self.rect.top = self.y_pos```
and if I make object through this class and `blit` it like this:
screen.blit(enemy1, (enemy1.x_pos, enemy1.y_pos))
There comes the error message. I can't find what is wrong..
I'm having a hard time trying to figure this out. plz help
暂无答案!
目前还没有任何答案,快来回答吧!