Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - swa870

Pages: [1]
1
System / thread in a class
« on: October 23, 2013, 10:23:15 pm »
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;
         }
      }
}
 

Pages: [1]