I can't compile and test a piece of code with single if statement like that though... so if you have a ready example you might as well give it instead of hoping I'll reproduce the bug myself.
Key repeat only affects keyboard keys, not mouse buttons.
main.cpp
#include <SFML/Graphics.hpp>
#include <iostream>
#include <sstream>
#include "increase.h"
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 800), "SFML works!");
sf::CircleShape shape(20.0f);
shape.setFillColor(sf::Color::Green);
window.setKeyRepeatEnabled(false);
increase i1;
sf::Font font;
font.loadFromFile("font/arial.ttf");
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
if (sf::Mouse::isButtonPressed(sf::Mouse::Right)){
int t = 0;
t + 1;
std::cout << t;
}
if (event.type == event.MouseButtonReleased && event.mouseButton.button == sf::Mouse::Left)
{
if (shape.getGlobalBounds().contains(event.mouseButton.x, event.mouseButton.y) == true)
{
i1.setIncrease(i1.getIncrease() + 1);
std::cout << "test" << std::endl;
}
}
sf::Text roomDisplay("", font);
roomDisplay.setCharacterSize(20);
roomDisplay.setColor(sf::Color::White);
roomDisplay.setPosition(100, 100);
std::stringstream ss;
ss << i1.getIncrease();
roomDisplay.setString(ss.str().c_str());
window.clear();
//Draw Stuff
window.draw(shape);
window.draw(roomDisplay);
//End Draw Stuff
window.display();
}
return 0;
}
increase.h
#pragma once
class increase
{
public:
increase();
~increase();
int getIncrease();
void setIncrease(int increase);
private:
int m_increase;
};
increase.cpp
#include "increase.h"
increase::increase()
{
m_increase = 0;
}
increase::~increase()
{
}
int increase::getIncrease(){
return m_increase;
}
void increase::setIncrease(int increase){
m_increase = increase;
}