[英]Can't define a Vector with pygame.math.Vector 2
我从 pygame 编程开始,我已经看到向量是有用的 x 和 y 变量。
问题是我什至无法定义向量,因为 pycharm 抛出以下内容:
这是脚本的主体:
import pygame as pg
class Character(pg.sprite.Sprite):
def __init__(self, ai_game):
pg.sprite.Sprite.__init__(self)
# Game
self.screen = ai_game.screen
self.screen_rect = self.screen.get_rect()
self.settings = ai_game.settings
'Initialize position'
self.rect.midbottom = self.screen_rect.midbottom
self.pos = pg.math.Vector2(1, 2)
Pycharm 抛出`“Unexpected arguments”和以下检查说明:
"Reports discrepancies between declared parameters and actual arguments, as well as incorrect arguments.
我一直在寻找解决方案几个小时,但我不能简单地让它工作。 最令人沮丧的部分是我看到他们以与我尝试相同的方式定义向量的任何地方,它看起来很简单。
您的代码中没有错误。 pygame.math.Vector2
可以由单个参数构造,该参数是 2 个坐标的元组或 2 个单独的 arguments。 事实上,您在 IDE 中发现了一个错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.