Run after a certain time

I am a beginner in creating games using openframeworks.

I want to display a screen that says “Success” after 2 seconds when I get the score when I am playing the game.

If you know how to use ofGetElapsedTimef () function.
If you have any other suitable function, please help me.

Thank you in advance.

Long ago I did some code to restart an ofApp after some delay. You can check out the code to do the countdown:

Hi openF,

This would be a sample of using ofGetElapsedTimeMillis() for delays in your code.

definitions in ofApp.h

unsigned long actualTime, sucessTimer;
unsigned int sucessTimeDelta;

in setup()

// set the delay (here 2 seconds)
sucessTimeDelta = 2000;  

in update()

// first get the actual time each cycle
actualTime = ofGetElapsedTimeMillis();

// check if enough time has passed after your trigger:
// actualTime is higher each cycle. successTimer is only changed, when triggered.
// so deviation of the two is 0, the moment sucessTimer is triggered and then growing 
// if succesTimeDelta is reached 2000, 2 seconds have passed.
if (actualTime - sucessTimer > sucessTimeDelta) {
    // do anything (e.g. show "success")
}

trigger: may be in keyReleased() or the function that triggers your score:

sucessTimer= ofGetElapsedTimeMillis();

hope this helps!
oe