How does one erase a Game Object from the vector . Anyone spot what Im doing wrong
//----------------------------------------------------------------
//PROJECTILES COLLISION TESTING
if (!projectiles.empty())
{
for (auto vehicle : this->vehicles)
{
for (auto projectile : this->projectiles)
{
if (projectile->getSprite() != NULL)
{
cocos2d::Rect rect1 = vehicle->getSprite()->getBoundingBox();
cocos2d::Rect rect2 = projectile->getSprite()->getBoundingBox();
if (rect1.intersectsRect(rect2))
{
vehicle->setDamage(projectile->returnType());
cocos2d::Vec2 location = projectile->getSprite()->getPosition();
this->removeChild(projectile->getSprite());
projectiles.erase(projectile);//This DOT is highlighted red and wont work
projectile->DisposeObject();
Explosion* explosion = new Explosion();
explosion->getSprite()->setPosition(location);
this->addChild(explosion->getSprite());
}
}
}
}
}
Objects Inherit like this and my vector is
GameObject -> GameObjectPhysics - > Bullet
std::vector<GameObject*> projectiles;
Thanks Very Much any help