Set duration time in progress bar

Set duration time in progress bar


Greetings to all

Can you tell me how to make a progress bar, which has a duration of about 15 seconds, for example?

Currently I use this code, but the duration time is not very accurate and I have to use a timer to validate how long it lasts and according to the level I need to change this value and I would like it to be with a value that I can put in a variable.

tiempo(dt) {

    tiempoRestante = this.barraProgreso.progress;
        if (tiempoRestante > 0) {
            tiempoRestante -= 0.0012;
            this.barraProgreso.progress = tiempoRestante;

If I use a time interval the bar lasts the exact time, but the change is seen to give sudden changes.


Use this.schedule


@Andres_IC . Thanks for the answer, could you give me an example of how you should use it please?


let timer=(dt)=>{


            //do something




@Andres_IC Thank you very much for the information