How do I use progress bar for multiple objects?

0 favourites
  • 6 posts
From the Asset Store
Progress\Loading Bar. Now Load you game like a Professional.
  • Hey everyone!

    When a mine is built in one of 15 spots, a progress bar is created (CoalMineConstruction) with the x/y of where that mine is. There is an instance variable on the coal mine (buildstatus) that is incremented +25 every 5 seconds until it reaches 100. When it hits 100, the progress bar is destroyed.

    This increment is showing up on the initial coal mine, however if another mine is built, the value for that shows as full. How do I reset the buildstatus for the others that are built after?

    Snapshot of what I'm trying to make work:

  • In the second event on your screenshot (Every tick) you need to pick the correct Minerals instance. If you don't pick it, then the value of BuildStatus will be taken from the first existing instance.

    Also, don't use the ProgressBar object, there are too many problems with it. Make your own progress bar with a sprite or TiledBackground, simply set its width to (BuildStatus/MaxBuildStatus)*BarWidth

  • Thanks for the info and reply.

    Do I add the “selectedID” to make it pick the right instance?

    So a sprite or tiledbackground? Interesting approach!

  • I prefer tiled background, here is a demo:

    howtoconstructdemos.com/simple-healthbar

    I don't know your game, so not sure what will be the right way to pick Minerals instance. If only one mine can be built at a time and you only need one progress bar, you can pick by UID or custom ID variable.

    If you need a separate progress bar for multiple mines, you can link them with hierarchy, or put in a container, or use MineUID instance variable on the bar object.

  • I prefer tiled background, here is a demo:

    https://howtoconstructdemos.com/simple-healthbar/

    I don't know your game, so not sure what will be the right way to pick Minerals instance. If only one mine can be built at a time and you only need one progress bar, you can pick by UID or custom ID variable.

    If you need a separate progress bar for multiple mines, you can link them with hierarchy, or put in a container, or use MineUID instance variable on the bar object.

    Good morning!

    I'm glad you posted that demo as it's the one I've gone through it's the one I thought I had reviewed.

    The problem I had was that there could be multiple mines/structures that could be built, eventually with different build times. So I wasn't sure how to get the progress bar (or it's equivalent) to show for different builds.

    Testing it now to see if I can figure out how to associate it to different builds.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There are several ways:

    1. Create an instance variable MineUID on the progress bar.

    2. Add progress bar to the mine as a child. (hirerarchy)

    3. Add progress bar and mine to a container, but then you'll have to make the bar invisible, you will not be able to destroy it.

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