title: Mouse position and click detect in sfml
body: <pre><code>int Game::MouseOnDot(float x, float y, RenderWindow &amp;renderWindow) {
      Rect&lt;int&gt; Dot;
      Event event;
      Dot.left = x;
      Dot.top = y;
      Dot.width = 20;
      Dot.height = 20;
      while (renderWindow.pollEvent(event)) {
          float Mx = sf::Mouse::getPosition().x;
          float My = sf::Mouse::getPosition().y;
          if (event.type == Event::MouseButtonReleased&amp;&amp;Mx &gt; x &amp;&amp; Mx &lt; Dot.height &amp;&amp; My &gt; y &amp;&amp; My &lt; Dot.width){
                  return 1;
          }
              else
                  return 0;
      }
  }
  </code></pre>
  
  <p>I don't know why this won't work if the button is pressed on the dot it returns 1 which tell other function to close window. Am i doing something wrong on mouse position?</p>
  
  <pre><code>while (renderWindow.isOpen()) {
          processEvents(renderWindow);
          float Time = clock.getElapsedTime().asSeconds();
          float TimeDifference = Time - LastUpdateTime;
          if (TimeDifference &gt;= UpdateTime) {
              processEvents(renderWindow);
              y += 3;
              if (y &lt;= 770) {
                  if(Game::MouseOnDot(x, y, renderWindow)==1)
                                      renderWindow.close();
                  Game::Spawn(renderWindow, Green_Dots, x, y);
                  LastUpdateTime = Time;
                  return;
  </code></pre>
  
  <p>Still don't work i paste here the part when MouseOnDot reutrns 0 or 1. It won't close the windows and i don't know why??</p>