This is a function I'm using to spawn enemies, and I'm using sf::sleep to add a delay.
void spawn()
{
sleep(seconds(2));
if (count1 % 20 && count1 != 0)
{
enemies.push_back(Enemy(true, 500.0, 25.0, 50.0, 50.0, Color::Red));
}
else
{
enemies.push_back(Enemy(false, 100.0, 15.0, 50.0, 50.0, Color::White));
}
count1++;
}
I launch the thread from here:
Thread spawning(&spawn);
spawning.launch();
But for some reason, the sleep in the thread affects my main loop and causes it to update every two seconds.