我在下面包含的代码会引发以下错误:
NameError: name 'Vector2' is not defined
Run Code Online (Sandbox Code Playgroud)
在这一行:
def Translate (self, pos: Vector2):
Run Code Online (Sandbox Code Playgroud)
为什么Python不能Vector2在Translate方法中识别我的类?
class Vector2:
def __init__(self, x: float, y: float):
self.x = x
self.y = y
def Translate(self, pos: Vector2):
self.x += pos.x
self.y += pos.y
Run Code Online (Sandbox Code Playgroud)