Loading UI loading bar

is there a way we can make ui loading bar change percent and have it like fill up in a few seconds ? i know you can call the setPercent method on it, but how would I get it to go from 0 to 100 in like say 5 seconds ?

Are you faking progress? Ie making it look like progress when there isn’t any? If so just use a sequence and delay then move progress. Then delay. Then move progress. Etc.

1 Like

thanks I was able to figure it out !

It would be cool to share your findings, so new users can also learn from it. :wink:

1 Like

This similar

1 Like

this is what I did to display a interstitial every 5th game over in my “onContactBegin” method I wrote this

  fourthIntAd++;
    if(fourthIntAd == 5){
        
        loadingBar->setVisible(true);
        loadingBarOutline->setVisible(true);
        loadLabel->setVisible(true);
        
        this->schedule(schedule_selector(LevelFour::loadBar), 1.0f, 2, 0);
        fourthIntAd = 0;
    } else {
        gameEnded();
    }

and in loadBar method I wrote this

 void LevelFour::loadBar(float dt)
 {
if(loadingBar->getPercent() == 0)
{
    loadingBar->setPercent(50);
    
} else if(loadingBar->getPercent() == 50)
{
    loadingBar->setPercent(100);
    
}else if(loadingBar->getPercent() == 100) {
    
    AdHelper::showInterstitialAd();
    loadingBar->setVisible(false);
    loadingBarOutline->setVisible(false);
    loadLabel->setVisible(false);
    gameEnded();
}
}