(SFML, C++) 如何访问动态分配的 sf::Vertex 数组中的特定 sf::Vertex?

(SFML, C++) How to access specific sf::Vertex in dynamically allocated sf::VertexArray?

我是 SFML 的新手,正在用 C++ 学习它,但我遇到了无法解决的问题。
我的程序 (class) 包含的是:

在头文件中:

sf::VertexArray *hitbox;

在源文件中:

this->hitbox = new sf::VertexArray(sf::TriangleFan, 20); //example

还有一个方法

void Object::setPosition(sf::Vector2f position)
{
    if(this->hitbox->getVertexCount()!=0)
    {
        this->hitbox->position = position; //error here
    }
}

编译器是这样说的:

 error: 'class sf::VertexArray' has no member named 'position'
   this->hitbox->position = position;
                 ^

所以问题是我想改变第一个顶点的位置,但是我动态分配sf::VertexArray时似乎无法访问它。我在 https://www.sfml-dev.org/ 上读到 sf::VertexArray 实际上是 std::vector<sf::Vertex> 和 [] 运算符重载,所以 应该 是一种方法,但我很难找到它。此外,class 不继承自 sf::Transformable。我该如何解决这个问题?

编辑:
this->hitbox[0]->position = position;

this->hitbox[0].position = position;
不解决这个问题。在第一种情况下,编译器遇到 hitbox[0] 不是指针的问题,在第二种情况下,它的错误与上述相同/

像这样使用重载的 [] 运算符:

this->hitbox[0].position = position;

这将为顶点的第 0 个条目建立索引,您可以根据需要对其进行修改。

由于 this->hitbox 是指向 sf::VertexArray 的指针,您需要在使用 operator[] 之前取消引用它:

(*(this->hitbox))[0].position = position;

在这里根本不使用指针可能会更好。