how to destroy an object when it collides?
if (bo.sprite.getGlobalBounds().intersects(ro.spr.getGlobalBounds()))
{
cout << "Collides" << endl;
}
How to instantiate an object, in this case i want to summon rocks, i do it in this manner
//rock class
void rock::create(sf::Vector2f pos)
{
tex.loadFromFile("Images/meteorBig.png");
spr.setTexture(tex);
spr.setPosition(sf::Vector2f(pos.x, pos.y));
std::cout << pos.x << std::endl;
}
void rock::draw(sf::RenderWindow &window)
{
spr.move(0.0f, +.05f);
window.draw(spr);
}
//Main Class
ro.create(pos);
ro.draw(window);
but with above i code i get the rock generated properly,but when i call it again, the previous rock goes invisible. how to make window draw as many rocks as generated.