我在运行pygame.Surface
对象不可下标时遇到这个错误。我试过看类似的代码,但仍然是绿色的地方,我错了。你知道吗
如果我删除所有的“命中”线,它的工作。我想为命中函数插入一个图像,它将一直运行到命中空格为止。你知道吗
elif self.isHitRight:
win.blit(hitRight[self.hitCount], (self.x, self.y))
self.hitCount += 1
elif self.isHitLeft:
win.blit(hitLeft[self.hitCount], (self.x, self.y))
self.hitCount += 1
您的错误} 对象不支持此操作。你知道吗
object is not subscriptable
意味着您试图在不支持它的对象上使用数组运算符(也就是说您做了类似x[y]
的操作)。你在上面做这个的对象只有hitLeft
和hitRight
,我假设它们是pygame.Surface
对象。^{很可能您最初需要将
hitLeft
和hitRight
定义为pygame.Surface
对象的数组。你知道吗相关问题 更多 >
编程相关推荐