How do I save level completion time to an array?

0 favourites
  • 5 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • What I would like to do is save the time that is remaining on the countdown timer to a "cell" on an array and when you beat the level that number will be displayed on the level that you just completed i.e "Best Time:" & bestTimeArr.At(location where current time left is stored in the array). I would like the countdown timer to save a new value to a new "cell" in my array for each level. I just can't figure out how to make the "Timer" ES save to a new cell in the array, each time. Any ideas? Basically how do I tell the "EndOfLayout" event to store the current Countdown timer value to a new cell in the array every time?

  • Create an array that is simple and corresponds to the number of levels you have. For example, if you have 30 levels, create an array with a width of 30 would be nice. From there on, save each best time at the appropriate array. Level 1 will be at array cell 0 and etc.

    And I wouldn't use at the end of layout for this. I would trigger it once your condition for winning that level is met. For example, you win if all the enemies are killed. I would do the check at that event. You should use a variable to save the current level completed time, than compare it with the value in the array. And if variable < array value, delete the array value, insert the new best time from the variable into the array, and save.

  • Create an array that is simple and corresponds to the number of levels you have. For example, if you have 30 levels, create an array with a width of 30 would be nice. From there on, save each best time at the appropriate array. Level 1 will be at array cell 0 and etc.

    And I wouldn't use at the end of layout for this. I would trigger it once your condition for winning that level is met. For example, you win if all the enemies are killed. I would do the check at that event. You should use a variable to save the current level completed time, than compare it with the value in the array. And if variable < array value, delete the array value, insert the new best time from the variable into the array, and save.

    Is there anyway to save the countdown timer value into a new slot on the array everytime? can I tell it to check to see if the previous cell in an array is already "filled" with a variable and then it moves to the next empty cell to save the new variable?

  • Nevermind I figured it out. I just set each individual Array Cell to correspond to the countdown timer at the end of the cells corresponding level i.e Level 1 is cell 0, Level 2 is cell 1 and so forth and so on. Thanks for the pointer rekjl!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No problem UnitDTH. Also something that I forget to mention. It is best to do two event checks for the arrays. One to check if the array value is smaller than the time variable, and another if the array value is 0 (which means that it is empty and contains no value). I am sure you can see the problem now, If you do a event check timevariable <array, than set new array and save, it will never save because the empty value when first check is 0 and will always be less than timevariable.

    This is usually what I do,

    1st event,

    timevariable < Array, value at (?)

    -delete that value and add the new time variable in, and save

    2nd event,

    Array, value at (?) = 0

    -delete that value and add the new time variable in, and save

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