You must be logged in to do that.

Unpress

Unpress
void Unpress(int button)

Documentation

This important function is used when you have handled a button press event and are ready for the engine to not show it as being pressed any more. After calling Unpress() for that button, the button will be read as being released. It will not read as being pressed until the user presses the button again.

This is most commonly used for buttons that operate as events, rather than states. For example, normally the [left] button will make a character be walking as long as it is pressed down. But if [left] is being used to control a menu cursor, you do not want to move the cursor left for as long as it is pressed (otherwise you will whiz across the menu in a split second). You may want to require each movement in the menu to be a separate press of the [left] button. In this case, you would use Unpress() after you did each movement.

I have made this sound more complicated than it is. Just look at the example.

This table shows the values to be given to unpress for each of verge's logical buttons. If you want to unpress left, you would use Unpress(7).

Numerical ValueButton Unpressed
0b1 through b4
1b1
2b2
3b3
4b4
5up
6down
7left
8right
9b1 through b4 and all directionals (available on versions >= r251 (Oct 11, 2008))

Example Usage

if (b1)
{
	Confirm();
	Unpress(1);
}
Talkback

Post a new comment?

Talkback #2 written by Technetium on 2012-01-05.

Note that you CANNOT use key[] scan codes with Unpress. It only works with button values. Not only that, but the following code will NOT work:

if(key[SCAN_DOWN])
{
  //code to move a menu pointer down
  unpress(6);
}

Even though key[SCAN_DOWN] and the variable "down" will both get detected by pressing the down arrow key while updatecontrols is in effect, the game will continue to detect that key[SCAN_DOWN] is true even though unpress(6) will set the button variable "down" to false.

Use the button variables whenever possible.

Talkback #1 written by verge-rpg.com on 2012-01-05.

This is the talkback thread for the documentation page: unpress

Post a new comment?

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.