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

Author Topic: Design issue with sf::Keyboard / Events  (Read 1759 times)

0 Members and 1 Guest are viewing this topic.

Kaphonaits

  • Newbie
  • *
  • Posts: 21
    • View Profile
Design issue with sf::Keyboard / Events
« on: March 02, 2012, 08:08:30 am »
So like many other people using SFML2, I'm making a game. Like many other games, it uses several keys on the keyboard to move a sprite around.

The issue is that if I use KeyPressed in the Event Loop to get player movement, I get a sort of "stutter" and it is very unpleasant.

If I use sf::Keyboard to get player movement, it moves smoothly but movement persists when the window is not in focus.

How can I work around this? :(
The keyboard is mightier than the sword.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Design issue with sf::Keyboard / Events
« Reply #1 on: March 02, 2012, 08:18:27 am »
Catch the focus events, and disable input when the window is not in focus.
Laurent Gomila - SFML developer

Kaphonaits

  • Newbie
  • *
  • Posts: 21
    • View Profile
Design issue with sf::Keyboard / Events
« Reply #2 on: March 03, 2012, 12:19:39 am »
Thanks.
The keyboard is mightier than the sword.

 

anything