gb.buttons.held

Description

bool gb.buttons.held( Button button , uint16_t time )

gb.buttons.held returns true once the button has been held for time amount of frames. It will not return true again until you release the button and hold it down again that long.

Parameters

  • Button button: the button to check
  • uint16_t time: the number of frames you need to hold that button down

Returns

bool: true if the button has been hold down exactly  time frames

Example

#include <Gamebuino-Meta.h>

void setup() {
  gb.begin();
}

void loop() {
  if (gb.update()) {
    // check if the A button was held down for 25 frames (one second)
    if (gb.buttons.held(BUTTON_A, 25)) {
      // handle it
    }
  }
}