Layout not refreshing from inside a function.

  • So I have this function that calls a bunch of other functions. I wanted to add a progress bar so that after each of the inner functions are run, it would show the progress. However, I'm discovering (I think) that while a function is being run, the layout isn't being updated. Once I click the button to start, the progress bar doesn't move until the main function completes.

    Is there anyway to refresh the layout so that this progress bar shows movement?

    * On function 'Startup'
    -> Functions: Call BuildArrayRandom
    -> ProgressBar: Set progress to ProgressBar.Progress+1
    -> Functions: Call AverageTheArray
    -> ProgressBar: Set progress to ProgressBar.Progress+1
    -> System: Set ArrayTotal to round((ArrayTotal÷ArrayCount))×MapFilter
    -> Functions: Call SetTerrainIslandorWater
    -> ProgressBar: Set progress to ProgressBar.Progress+1
    -> System: Set ArrayCount to 0
    -> Functions: Call EliminateOrphans
    -> ProgressBar: Set progress to ProgressBar.Progress+1
    -> Functions: Call FillInPonds
    -> ProgressBar: Set progress to ProgressBar.Progress+1
    -> Functions: Call FixConnectors
    -> ProgressBar: Set progress to ProgressBar.Progress+1
    -> Functions: Call PlaceBeaches
    -> ProgressBar: Set progress to ProgressBar.Progress+1
    -> Functions: Call CopyToTilemap
    -> ProgressBar: Set progress to ProgressBar.Progress+1
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The eventsheet blocks any other execution until it has completed. You need to split the work up somehow, ideally into chunks that occur in under 16ms. A wait action for 0 seconds should pause work until the next tick, allowing the layout to render.

    It can be quite hard to decide when to pause, often it's easier to pause more often than you need which slows down your loading significantly. But at least if your not blocking anymore you can show a nice loading animation.

  • The eventsheet blocks any other execution until it has completed. You need to split the work up somehow, ideally into chunks that occur in under 16ms. A wait action for 0 seconds should pause work until the next tick, allowing the layout to render.

    It can be quite hard to decide when to pause, often it's easier to pause more often than you need which slows down your loading significantly. But at least if your not blocking anymore you can show a nice loading animation.

    Perfect! Added the wait 0 after each function and the progress bar updates. An unexpected method for solving the problem, but hey, it works.

    Thanks!

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