Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I know this is an old question but I would like to answer it in the interest of helping others who may find themselves here experiencing similiar problems.</p> <p>SFML 1.6 has two ways you can get input from the user. One is event-based where you process each event sent to you via <code>sf::Window::GetEvent()</code>. The other is query-based where you check the <code>sf::Input</code> class of your window directly.</p> <p>You have used the query-based method here but put it inside an event loop which isn't really the way it was intended to be used. It was meant to be used like this. This is a nice feature because SFML essentially keeps a boolean table of keys automatically for you so you don't need to manage key states yourself. IMHO for using repeating input this is more elegant since you won't be spamming your event queue, just checking a boolean value.</p> <pre><code>while(app.GetEvent(event)) if(event.Type == sf::Event::Closed) running=false; if(event.Type == sf::Event::KeyPressed &amp;&amp; event.Key.Code == sf::Key::Right) { // move right } } </code></pre> <p>If you wanted to just query sf::Input directly then you use the same code as above, but you put it outside the event loop. </p> <pre><code>while(app.GetEvent(event) { } if (myWindow.GetInput().IsKeyDown(sf::Key::Right)) { } </code></pre> <p>By default automatic key repeat should be enabled for sf::Windows but you can make sure by using <code>sf::Window::EnableKeyRepeat(true)</code>. This means it will send a <code>KeyPressed</code> event repeatedly while a key is held down. </p> <p>Try using the query-based method outside the main event loop and see if that works for you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload