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

Author Topic: Idea for sf::Keyboard  (Read 1079 times)

0 Members and 1 Guest are viewing this topic.

MarbleXeno

  • Guest
Idea for sf::Keyboard
« on: July 18, 2020, 01:54:57 pm »
Hello, I'm currently working on a dev module for my game that I'm creating for fun (this is a project only for me, i wan't to just learn C++ and SFML) and i have a problem with sf::Keyboard, so basically i wan't to display a dev values (like delta time) - when a player clicks F5 the value appears (so the function is just called there) and when the player clicks f5 again the values ​​disappears, how can i do that?

F5 = DeltaTime appears on the screen.
F5 again = DeltaTime disappears.

PS: Dev module i have already created.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Laurent Gomila - SFML developer

MarbleXeno

  • Guest
Re: Idea for sf::Keyboard
« Reply #2 on: July 18, 2020, 03:23:20 pm »
I know that I need to use KeyPressed and Released but I don't know how I can do that, I have DevMode class with methods like "displayDeltaTime" and I have also draw method. I don't know how to make text stay on click and disappears after second click. I know about KeyPressed and KeyReleased. That's my problem.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Idea for sf::Keyboard
« Reply #3 on: July 18, 2020, 04:58:58 pm »
bool showDeltaTime = false;

// on keypressed event...
showDeltaTime = !showDeltaTime;

// at draw time
if (showDeltaTime)
    DevMode.displayDeltaTime();
Laurent Gomila - SFML developer

MarbleXeno

  • Guest
Re: Idea for sf::Keyboard
« Reply #4 on: July 18, 2020, 07:59:43 pm »
Thank you very much!