简体   繁体   中英

Can't define a Vector with pygame.math.Vector 2

I'm starting with pygame programming and I've seen vectors are useful x and y variables.

The issue is that i cant even define a vector because pycharm throws the following:

在此处输入图像描述

This is the body of the script:

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 throws `"Unexpected arguments" and the following inspection Description:

"Reports discrepancies between declared parameters and actual arguments, as well as incorrect arguments.

I've been looking for the solution for hours but I can't simply make it work. The most frustrating part is the everywhere I see they define the vectors the same way I'm trying to, and it looks so simple.

There is no error in your code. A pygame.math.Vector2 can be constructed either by a single argument, which is a tuple of 2 coordinates or 2 separate arguments. In fact, you discovered a bug in the IDE.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM