1
General / Re: Using thread on function that have music as argument
« on: May 19, 2013, 01:12:37 pm »Thank you for answering.QuoteAs I write two functions that use while statement, I realized that I can't run the screen fade and music ending functions at the same time.This is the wrong approach. What if you now want to animate a character? Of fade a second music? Are you going to spawn a separate thread for every task? Why can't you update all these tasks inside a single loop?
For your problem, there are two solutions:
- sf::Thread thread(&endMusic, std::ref(music)); (C++11 only)
- using a pointer
Actually, I did modify my code and run both the screen fade and music fade on the same function so they can happen at the same time, I am just curious on the error " \include\sfml\system\noncopyable.hpp(67) : see declaration of 'sf::NonCopyable::NonCopyable'"
So I'll have to use sf::Thread thread(&endMusic, std::ref(music)); or change my function parameter into void endMusic(std::Music *music), right ?