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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - jmaslaki

Pages: [1]
1
General / How can you toggle something with pressing a key?
« on: March 13, 2014, 03:23:16 am »
I looked in the resources, I couldn't find any information on how to do this. So I'm trying to figure out how to set "int a" from 0 to 1 by pressing down a key. For example:

if (sf::Keyboard::isKeyPressed(sf::Keyboard::Q)){
a = 1; //int a was already declared
}

So the problem here is that a = 1 as long as the key is pressed down, but once I release it, it goes back to equaling 0. I want to press it, and have it stay 1(not from releasing, from pressing once). Any solutions? Thanks.

EDIT: Forgot to mention this is in while (window.isOpen()){}

Pages: [1]
anything