self.direction = pygame.Vector2(1, 0)#Vector2(1,0) AttributeError: 'module' object has no attribute 'Vector2'
我对此有错误,我不明白问题是什么,我尝试了很多事情来解决此问题,但是错误弹出了相同的
用Vector2D
替换Vector2
也没有帮助我试图旋转精灵,以便任何替代方案也可以做我还尝试使用math.Vector2D
,但它没有识别它,并且导入错误弹出
import pygame
import random
##from pygame import Vector2
from os import path
import os
import sys
import math
..
..
self.direction = pygame.Vector2(1, 0)
您要搜索的类是在pygame.math
中实现的。
请参阅pygame.math.Vector2
所以必须是:
import pygame
self.direction = pygame.math.Vector2(1, 0)
分别
from pygame.math import Vector2
self.direction = Vector2(1, 0)