Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Strange thing with mouse  (Read 1906 times)

0 Members and 1 Guest are viewing this topic.

Salmon_Yo

  • Newbie
  • *
  • Posts: 17
    • View Profile
    • Email
Strange thing with mouse
« on: December 06, 2013, 06:06:27 pm »
Hi guys. I have a little problem. It happens when i`m moving picture in the window and a mouse cursor (in that window) at the same time.. Picture starts to move rather quickly than when coursor don`t move or moving in not my window.. It`s normal?

Maybe it depends ..

#include <SFML/Graphics.hpp>




int main()
{


 
        sf::RenderWindow window(sf::VideoMode(380, 390), "Happines!");
 
       
        sf::RectangleShape s;
        s.setSize(sf::Vector2f(10, 50));
        s.setPosition(10, 50);
        s.setFillColor(sf::Color::Red);


    while (window.isOpen())
    {
       
                 

               
               

               

        sf::Event event;
        while (window.pollEvent(event))
        {

                       

            if (event.type == sf::Event::Closed)
                                window.close();

                       
                       
                       

                        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)){
                               
                                s.move(1, 0);
                               
                               
                        }

               
       
       
                }
               
                window.clear(sf::Color::White);
                       
               
                window.draw(s);
                window.display();
               
                }
       
    return 0;
        }

Video :
http://www.youtube.com/watch?v=3QqN92AKbM4&feature=youtu.be
« Last Edit: December 06, 2013, 06:10:04 pm by Salmon_Yo »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: Strange thing with mouse
« Reply #1 on: December 06, 2013, 06:12:28 pm »
Read the official tutorials again. ;)

sf::Keyboard::isPressed should not be used inside the event loop.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Salmon_Yo

  • Newbie
  • *
  • Posts: 17
    • View Profile
    • Email
Re: Strange thing with mouse
« Reply #2 on: December 06, 2013, 06:16:19 pm »
Thank you so much=)

 

anything