Hello, I have two classes:
Object
ObjectManager
I store all of my objects inside the ObjectManager class with a vector. I update all objects in one function which works perfectly. But when it comes to drawing them all in another function the game freezes. I even tried getting the object to just draw a RectangleShape & it still freezes. But when I comment out the draw function inside the object itself it is fine. So I think it might have to do with drawing to the window?
Here is my draw code for the object manager:
mWindow:
sf::RenderWindow *mWindow;
void ObjectManager::draw()
{
// Draw all of our drawable objects
for (std::vector<Object*>::iterator it = objectList.begin(); it != objectList.end(); ++it)
{
(*it)->draw(mWindow);
}
}
Here is the function above it that updates the objects (and it works):
void ObjectManager::draw()
{
void ObjectManager::update(sf::Time &delta)
{
// Update all of our objects on the list
for (std::vector<Object*>::iterator it = objectList.begin(); it != objectList.end(); ++it)
{
(*it)->update(delta);
std::cout << "draw" << std::endl;
}
// Set there draw priority by depth
std::sort(objectList.begin(), objectList.end(), sortByDepth);
}