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.


Messages - swa870

Pages: [1]
1
System / Re: thread in a class
« on: October 23, 2013, 11:14:44 pm »
thank you... i understand now i was right... i went back to the tutorial

2
System / Re: thread in a class
« on: October 23, 2013, 11:11:45 pm »
thank you for yout fast answer...

A thread would not loop itself? it's the first time that im trrying to do a thread...

Well my thread is good?

should i make a loop in the function or in put thread.lauch with my main loop?

3
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]
anything