I have the following function.
void BulletFactory::update(Uint32 ticks) {
std::list<Sprite*>::iterator it = activeBullets.begin();
while (it != activeBullets.end()) {
(*it)->update(ticks);
if(!((*it)->inView())) {
activeBullets.remove(*it);
Sprite* temp = *it;
it++;
inactiveBullets.push_back(temp);
} else {
it++;
}
}
}
when the condition !((*it)->inView())
is being true
there is a segmentation fault. I am not able to see the problem.
edit: forgot to mention that activeBullets and inactiveBullets are two lists.