【发布时间】:2021-05-22 12:49:01
【问题描述】:
我不知道发生了什么,也找不到其他有同样问题的人。 这是我的代码:
import pygame
import math
import random
import os
SWIDTH = 800
SHEIGHT = 600
vec = pygame.math.Vector2
FRI = 0.3
ACC = 1
这是错误
File "C:\Users\USERNAME\Desktop\games\GAME.py", line 137, in update
self.loc += self.vel + 1 + self.aird
TypeError:+ 不支持的操作数类型:“pygame.math.Vector2”和“int”
【问题讨论】:
-
问题中缺少部分代码。
-
我猜你正在将一个整数添加到一个向量中。要么将其添加到向量的某个部分(vec.x 或 vec.y),要么将其设为向量并以这种方式添加。
-
此代码不会产生该错误。发布完整的错误消息(准确告诉您错误在哪一行)和minimal reproducible example。
标签: python vector pygame runtime-error operands