我正在构建一个游戏,并且有一个名为 sprite 的对象向量。
struct Sprite
{
SpriteType texture; // The texture enumeration
float x; // The x position of the sprite
float y; // The y position of the sprite
float xVel; // The x velocity of the sprite
float yVel; // The y velocity of the sprite
int imgBlockX; // The x block in the image
int imgBlockY; // The y block in the image
int numFrames; // The number of frames in the sprite animation
int curFrame; // The current frame of animation
int delay; // The delay between frame switches
int elapsed; // The amount of time on this frame
long lastTime; // The last update time
long curTime; // The current update time
bool loop; // Does this animation loop?
int lifespan; // The max lifespan of the sprite
int order; // 0 for first 1 for last
bool hasChildren; // Is this a parent sprite?
int maxSize;
std::vector<SpriteChild> children;// The sprites that are linked to this one (die when this one dies)
};
正如你在底部看到的,它包含一个精灵子向量本身。如果我从我的 sprite 向量中删除一个元素,它会导致 spritechild 向量发生内存泄漏,还是已经解决了?
谢谢!