These vectors are kicking my butt! 'layer1' is defined as such:
I'm adding sprites to it with my addSprite method:
Here's my 'removeSprite' method. It's function is to delete a sprite and the element in the vector 'layer1' pointing to it.
The problem is with this function. It generates all sorts of strange access and exception errors, the bad ones with the msg box that says 'abort, retry, fail'. What am i doing wrong? Thanx, maybe someday i'll quit asking vector questions.
Code:
vector <cls_sprite*> layer1;
I'm adding sprites to it with my addSprite method:
Code:
cls_sprite* cls_spriteCollection::addSprite(int layer){
if (layer == 1){
layer1.push_back(new cls_sprite());
layer1[layer1.size() - 1]->id = layer1.size() - 1;
return layer1[layer1.size() - 1];
}
}
Here's my 'removeSprite' method. It's function is to delete a sprite and the element in the vector 'layer1' pointing to it.
Code:
void cls_spriteCollection::removeSprite(int layer, int id){
if (layer == 1){
delete [] layer1[id];
layer1.erase(layer1.begin() + id);
if (layer1.size() > 0){
for (int i = 0; i == layer1.size() - 1; i++){
layer1[i]->id = i;
}
}
}
}
The problem is with this function. It generates all sorts of strange access and exception errors, the bad ones with the msg box that says 'abort, retry, fail'. What am i doing wrong? Thanx, maybe someday i'll quit asking vector questions.