簡體   English   中英

無法使用 pygame.math.Vector 2 定義向量

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM