Excusez-moi, mais je ne comprends pas cette erreur :
\SFML\System\Thread.inl||In instantiation of 'void sf::priv::ThreadFunctorWithArg<F, A>::run() [with F = void (Button::*)(sf::Event); A = Button*]':|
\Button.cpp|94|required from here|
\SFML\System\Thread.inl|48|error: must use '.*' or '->*' to call pointer-to-member function in '((sf::priv::ThreadFunctorWithArg<void (Button::*)(sf::Event), Button*>*)this)->sf::priv::ThreadFunctorWithArg<void (Button::*)(sf::Event), Button*>::m_function (...)', e.g. '(... ->* ((sf::priv::ThreadFunctorWithArg<void (Button::*)(sf::Event), Button*>*)this)->sf::priv::ThreadFunctorWithArg<void (Button::*)(sf::Event), Button*>::m_function) (...)'|
Button.h
#ifndef BUTTON_H
#define BUTTON_H
class Button : public sf::Sprite
{
public:
Button(absWindow *wparent, void(absWindow::*function)(), std::string const& adress, std::string const& adressO=std::string(), std::string const& adressL=std::string());
void setParent(absWindow *wparent, void(absWindow::*function)());
absWindow* getParent();
void setActive(bool yay);
void changeTextures(std::string const& adress, std::string const& adressO=std::string(), std::string const& adressL=std::string());
void checkClicked(sf::Event event);
private:
absWindow *parent;
sf::Texture texture, textureOver, textureLeaned;
sf::Thread *triggered, *ccd;
bool mouseOver, active;
};
#endif //BUTTON_H
Button.cpp
#include "Button.h"
Button::Button(absWindow *wparent, void(absWindow::*function)(), std::string const& adress, std::string const& adressO, std::string const& adressL) : \
parent(wparent), texture(), textureOver(), textureLeaned(), \
triggered(new sf::Thread(function, wparent)), ccd(new sf::Thread(&Button::checkClicked, this)), mouseOver(false), active(true)
{
changeTextures(adress, adressO, adressL);
ccd->launch();
}
void Button::setActive(bool yay)
{
if(active && yay)
{
return;
}
else if(yay)
{
active=true;
ccd->launch();
}
else
{
active=false;
setTexture(sf::Texture());
}
}
void Button::setParent(absWindow *wparent, void(absWindow::*function)())
{
active=false;
parent=wparent;
delete triggered;
triggered=new sf::Thread(function, parent);
active=true;
ccd->launch();
}
absWindow* Button::getParent()
{
return parent;
}
void Button::changeTextures(std::string const& adress, std::string const& adressO, std::string const& adressL)
{
texture.loadFromFile(adress);
if(adressO == std::string())
textureOver.loadFromFile(adress);
else
textureOver.loadFromFile(adressO);
if(adressL == std::string())
textureLeaned.loadFromFile(adress);
else
textureLeaned.loadFromFile(adressL);
}
void Button::checkClicked(sf::Event event)
{
if(active && event.type==sf::Event::MouseMoved)
{
if(getGlobalBounds().contains(sf::Vector2<float>(event.mouseMove.x, event.mouseMove.y)))
{//if the mouse is in the button...
mouseOver=true;
setTexture(textureOver);
}
else
{
}
}
}//required frop here