import pygame class Item(pygame.sprite.Sprite): def __init__(self,x,y,w,h,name): pygame.sprite.Sprite.__init__(self) self.image = pygame.Surface((w,h)).convert() # 添加一个空的图层使其各自有一个宽高 self.rect = self.image.get_rect() self.rect.x = x self.rect.y = y self.name = name