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

Author Topic: SFML 2.0 GetInput  (Read 2831 times)

0 Members and 1 Guest are viewing this topic.

Morph

  • Newbie
  • *
  • Posts: 6
    • View Profile
SFML 2.0 GetInput
« on: May 11, 2013, 01:54:24 am »
Umm, hello guys. I was following up a series on how to code a platformer game on the 1.6 version. However, when I moved to try out the 2.0 version, I had a trouble converting a statement so far. It goes as the following :

Window.GetInput().IsKeyDown(key); //KeyDown is a function inside a class I made to handle the pressed down buttons of a keyboard and key is an int in the function's parameter

so I was wondering on how to make that line work as a 2.0 code.
Thanks in advance :)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML 2.0 GetInput
« Reply #1 on: May 11, 2013, 01:58:03 am »
Read the tutorial about real-time input in SFML 2...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Morph

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: SFML 2.0 GetInput
« Reply #2 on: May 11, 2013, 03:27:08 am »
Yeah, I see. Thanks :) Just tried it out and it worked :D

Morph

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: SFML 2.0 GetInput
« Reply #3 on: May 11, 2013, 05:39:59 am »
But hey.. would it only be like "if(sf::Keyboard::isKeyPressed)"? neglecting any of the parameter intended ?

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: SFML 2.0 GetInput
« Reply #4 on: May 11, 2013, 05:45:15 am »
No, it takes a keyboard key as parameter so it would be
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
with Escape replaced with your desired key(A,B,Space,Return etc. auto completion and docs will tell you).
« Last Edit: May 11, 2013, 05:48:37 am by FRex »
Back to C++ gamedev with SFML in May 2023

Morph

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: SFML 2.0 GetInput
« Reply #5 on: May 11, 2013, 06:46:36 am »
I see, thank you very much, that has been helpful, indeed :)