Satranci Bu kodda ne oluyor inceleyelim;
ilk adımda;
if(this->ispressed == true)
this->ispressed = false;
ile true ise false yapıyorsun. Sonrasında;
if(this->ispressed == false)
this->ispressed = true;
false ise true diyorsun ve tekrar true değerini atıyorsun. Yapman gereken şu;
bool ispress(Event &event,RenderWindow &window){
if(this->ispressed == true) {
this->ispressed = false;
} else {
this->ispressed = true;
}
float mousex = Mouse::getPosition(window).x;
float mousey = Mouse::getPosition(window).y;
float buttonx = shape.getPosition().x;
float buttony = shape.getPosition().y;
float bgw = shape.getLocalBounds().width + shape.getPosition().x;
float bgh = shape.getLocalBounds().height + shape.getPosition().y;
if(mousex < bgw && mousex > buttonx && mousey < bgh && mousey > buttony && Mouse::isButtonPressed(Mouse::Left))
change();
return this->ispressed;
}
Syntax'da hata yapmış olabilirim, mantığını anlamışsındır 🙂