How do I update the progressbar in a loop?

0 favourites
  • 3 posts
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies.
  • Hi,

    sorry for asking, but I couldn't find any help, though I was searching a while on google and construct2 forums. However I have a simple problem (from my point of view). I have a loop calculating some new values for a 2dimensional array. This takes some time (>20s) so I want to have a progressbar to inform the user about the status.

    But I can't get it to work. The progressbar shows only the final values but not any stauts in between. I tried different methods (timer, an action within the loops) but nothing worked. Probably I need something to interrupt the execution of the loop and let other tasks to be done. But how?

    Here is the test-code I generated to play around.

    This image shows the layout (red text are the object names).

    This is my event sheet:

    Any help would be nice. Thanks.

  • Yeah, your entire loop is done in one tick, that's why the progress bar is not updating.

    Try something like this:

    On every tick
     For "outerLoop" from 1 to 200 : Add 1 to X
     if X<=int(TextBoxX.text)
     ...For "InnerLoop" from 1 to int(TextBoxY.Text) 
     ......[do some stuff]
     ......[update progress bar]
    

    This way you'll process numbers in small portions on every tick. If TextBoxX=10000, this will take 50 ticks. And your progress bar will work.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi,

    Thanks! It's working now.

    (sorry for the late answer, I had a long day at work yesterday)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)