Im trying to use my class function as a tread but the thread only do this function one time... why?
doc.h
class cScreen_Game2 : public cScreen
{
protected :
list<TJoueur> LesJoueurs;
vector<TEnnemis*> LesEnnemis;
sf::Thread m_thread;
public:
cScreen_Game2(void);
~cScreen_Game2(void);
virtual int Run (sf::RenderWindow &window);
void ThreadEnnemis();
};
doc.cpp
cScreen_Game2::cScreen_Game2(void):m_thread(&cScreen_Game2::ThreadEnnemis, this)
{
}
void cScreen_Game2::ThreadEnnemis()
{
cout << "1";
}
int cScreen_Game2::Run (sf::RenderWindow &window)
{
bool Running = true;
m_thread.launch();
while (Running)
{
window.clear();
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed:
return -1;
break;
case sf::Event::KeyPressed: // Nous pouvons utiliser aussi KeyReleased
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
return 1;
break;
}
}
}