Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python pygame错误:参数必须是rectstyle对象序列_Python_Python 3.x_Pygame_2d Games_Pygame Surface - Fatal编程技术网

Python pygame错误:参数必须是rectstyle对象序列

Python pygame错误:参数必须是rectstyle对象序列,python,python-3.x,pygame,2d-games,pygame-surface,Python,Python 3.x,Pygame,2d Games,Pygame Surface,嗨,我正在尝试用pygame制作一个简单的2d汽车游戏,我正在尝试添加两辆汽车之间的碰撞,但我一直遇到这个错误: Traceback (most recent call last): File "C:\Users\emilio pinto\Desktop\Running car proj\Running car.py", line 69, in <module> if pygame.Rect.collidelist(car1,car2) >= 0

嗨,我正在尝试用pygame制作一个简单的2d汽车游戏,我正在尝试添加两辆汽车之间的碰撞,但我一直遇到这个错误:

Traceback (most recent call last):
  File "C:\Users\emilio pinto\Desktop\Running car proj\Running car.py", line 69, in <module>
    if pygame.Rect.collidelist(car1,car2) >= 0:
TypeError: Argument must be a sequence of rectstyle objects.

这将解决您的问题:

if pygame.Rect.colliderect(car1,car2) >= 0:

说明:

您使用了错误的函数,或者该函数的参数错误

对两个对象使用
Rect.colliderect

或者使用对象列表的
Rect.collidelist
。因此,必须将
car1
car2
放入列表对象中。

if pygame.Rect.colliderect(car1,car2) >= 0: