1
System / Thread for class function w/ parameter
« on: January 22, 2020, 07:29:29 pm »
Hi everybody,
I'm new on SFML and i have a problem that i understand, but can't find the right solution.
I have a class, named "Animation", with the function Play(), which take a RenderWindow parameter. I wanted to run this function in a thread, to render my animation in the same time the game is running. There is the part of the code:
I call it in the main() with the following code:
And it gives me the following error: C2064: term does not evaluate to a function taking 1 arguments.
I totally understand that i don't give the necessary renderWindow parameter in "shotAnim->animThread.launch();", but i don't find where/how to set it up.
Working on Visual Studio 2017 (Debug, x86).
Can you help me please? Thanks !
I'm new on SFML and i have a problem that i understand, but can't find the right solution.
I have a class, named "Animation", with the function Play(), which take a RenderWindow parameter. I wanted to run this function in a thread, to render my animation in the same time the game is running. There is the part of the code:
public:
Animation(animName index) : animThread(&Animation::Play, this){
this->Name = index;
switch (Name) { . . . }
}
~Animation() { . . . }
void Play(sf::RenderWindow &window);
sf::Thread animThread;
};
Animation(animName index) : animThread(&Animation::Play, this){
this->Name = index;
switch (Name) { . . . }
}
~Animation() { . . . }
void Play(sf::RenderWindow &window);
sf::Thread animThread;
};
I call it in the main() with the following code:
auto shotAnim = new Animation(animName::Shot);
shotAnim->animThread.launch();
shotAnim->animThread.launch();
And it gives me the following error: C2064: term does not evaluate to a function taking 1 arguments.
I totally understand that i don't give the necessary renderWindow parameter in "shotAnim->animThread.launch();", but i don't find where/how to set it up.
Working on Visual Studio 2017 (Debug, x86).
Can you help me please? Thanks !