运用pygame 进行游戏开发,报错“‘str’ object has no attribute ‘_Sprite__g’”,求助
源代码如下:
import pygame
from pygame.locals import *
import sys
class newSprite(pygame.sprite.Sprite):
def __init__(self,target,zhen,single_width,single_height,pos=(0,0)):
pygame.sprite.Sprite.__init__(self)
self.image=pygame.image.load(target).convert_alpha()
self.main_image=self.image
self.frame=zhen
self.rect=sele.image.get_rect()
self.count=0
self.single_w,self.single_h=single_width,single_height
self.rect.topleft=pos
def update(self):
if self.count<self.frame:
self.count+=1
else:
self.count=0
self.image=self.main_image.subsurface([self.count*self.single_w, 0, self.single_w,self.single_h])
pygame.init()
screen=pygame.display.set_mode([600,600])
pygame.display.set_caption("spriteDemo")
exp=new