VertexArray无法找到其顶点函数(SFML)

时间:2016-07-03 07:44:46

标签: c++ sfml

我正在制作一个简单的基于重力的粒子系统,因此我制作了三个类:

    存储粒子系统的
  • ParticleManager

  • ParticleSystem,包含具有更新功能的粒子的VertexArray

  • Particle,一个从sf :: Transformable继承的顶点。

实际上,我在ParticleSystem更新功能时遇到了代码:

ParticleSystem()
{
    particles.setPrimitiveType(PrimitiveType::Points);
    int indexX = 0, indexY = 0;
    for (int i = 1; i < CHUNK_SIZE; i++)
    {
        Particle particle;
        particle.position = Vector2f(indexX, indexY);
        particles.append(particle);
        if (indexX < 100)
            indexX++;
        else
        {
            indexX = 0;
            indexY++;
        }
        force.push_back(0);
    }
}
void Update()
{
    for (int i = 0; i < particles.getVertexCount(); i++)
    {
        particles[i].Update();
    }
}

编译器在调用particles[i].Update()时出错,因为VertexArray只能包含sf :: Vertex;

有关实施该功能的任何建议吗?

1 个答案:

答案 0 :(得分:0)

制作自己的矢量。

std::vector<Particle> particles;