python - 类型错误:参数 1 必须是 pygame.Surface,而不是元组(动画时发生)
问题描述
在尝试创建动画系统时,我遇到了这个错误:TypeError: argument 1 must be pygame.Surface,not tuple。它出现在函数 draw 的最后一行。此外,如果我尝试调用主程序中的方法,程序将运行但它会立即停止而不提供任何错误代码。
import pygame
class Animation():
def __init__(self, imageList):
self.imageList = imageList
self.animationTimer = 0
self.animationSpeed = 1
self.imageIndex = 0
def update(self):
self.animationTimer+=1
if self.animationTimer >= self.animationSpeed:
self.animationTimer = 0
self.imageIndex+=1
if self.imageIndex >= len(self.imageList)-1:
self.imageIndex=0
def draw(self, screen, x, y):
screen.blit(self.imageList[self.imageIndex], (x,y))
解决方案
推荐阅读
- azure-cognitive-search - Azure 搜索服务进入“预配”模式(但没有任何改变)搜索索引已关闭
- algorithm - 用 1 和 0 填充 n*n 数组
- javascript - 矩对象数组具有未定义的元素
- sql-server - SQL Server 死锁问题;多个进程更新同一个表但不同的行
- azure - 将 SAML 请求编码到 Azure AD 终结点的正确方法是什么?
- javascript - 将 API 密钥存储到 credentials.yml.enc 的正确方法?
- css - 具有自定义验证的 Angular 组件
- python - 程序不会完全通过代码运行(无错误) Python 2.7.15
- ios - 中心滚动视图对象到每个水平滚动页面 - Xamarin iOS
- x86 - 为什么 NEG 指令会干扰进位标志?