【发布时间】:2020-05-29 22:17:13
【问题描述】:
我获得了可以访问所有标准 SFML 内容的 A 类:
class A{
public:
A(int type, Vector2f pos){
if(type == 1) tex.loadFromFile(path1);
else if(type == 2) tex.loadFromFile(path2);
//etc. etc.
shape.setTexture(&tex);
//then I set up the radius, and the position (from the constructor)
//I debugged this part and it seemed to work so I wont bother typing it out
};
Texture tex;
CircleShape shape;
};
在另一个 B 类中,我得到了 A 的 std::vector:
class B{
public:
void update(){
//under a bunch of conditions
list.push_back(A(1,Vector2f(100,100)); //examples
list.push_back(A(1,Vector2f(200,200))
}
std::vector<A> list;
};
无论如何,纹理无法正确加载,我只剩下白色球体。我尝试将它放在一个单独的函数中并使用back() 调用它,它只加载了第一个,而不是第二个。这是非常奇怪的行为,我不知道是什么原因造成的。
【问题讨论】:
标签: c++ textures sfml stdvector