Hi,
I have a rock class, I use that class to generate multiple rock objects that are then put in a vector.
The problem I'm having is that when a rock is generated the whole game slows down making it laggy/choppy.
Right now my rock is loaded from file: rock.loadFromFile("image/rock.png")
; I figures the problem is that I load the image from file everytime a rock is generated. Can you advise me on how to resolve this or is my diagnosis of this is wrong? Note that there are at least 9 rocks generated at any given time.
void SpaceRock::Init()
{
if (!rock.loadFromFile("image/rock.png"))
{
}
s_Rock.setTexture(rock);
s_Rock.setTextureRect(sf::IntRect(17, 24, 88, 85));
s_Rock.setPosition(source.x, source.y); //used sf::vector2f
}