gb.buttons.repeat

Description

bool gb.buttons.repeat( Button button , uint16_t period )

gb.buttons.repeat returns true if the button has been held down for period amount of frames, repetitively. A period of 0 will check if the button is pressed down in this instant

Parameters

  • Button button: button to check
  • uint16_t period: repetitive period the button needs to be held

Returns

bool: true if the button has been held repetitive for period frames

Example

#include <Gamebuino-Meta.h>

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

void loop() { while(!gb.update()); // check if the A button is held right now if (gb.buttons.repeat(BUTTON_A, 0)) { // handle it }

// check if the B button is held for 4 frames, repetitively if (gb.buttons.repeat(BUTTON_B, 4)) { // handle it } }