Array sum question

0 favourites
  • 4 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hello everybody, I have a specific question and I hope I'll be as clear as possible:

    In my game, I have several levels. For each level you pass, you gain a certain amount of XP. Then, I want the sum of those XP's to show in the level screen.

    Example: XP_total = levelxp1 + levelxp2, and so on.

    I did that with the "For each X element" >> Add levelxp.CurValue to XP_total" .

    I already managed to do that perfectly, but here comes my problem: I want to implement some boosters to buy with the XP you gain.

    Example: Booster "Nitro" costs 50 XP. So, I subtract the 50 XP from XP_total. But, when I go back playing the game, it re-calculates the sum of all levelxp's, and it forgets the subtraction I did.

    I already tried to create another instance variable that is equal to XP_total, but it doesn't work properly.

    If somebody could help me, it'll be very much appreciated!

  • Bump! And what the hell is with the chinese character posts spam!!

  • Would creating three global variables work?

    CombinedXP : set to the "For each X element" >> Add levelxp.CurValue to CombinedXP"

    BoosterCosts : set to the amount of XP spent on boosters

    XPtotal : set to combinedXP minus Boostercosts

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Would creating three global variables work?

    CombinedXP : set to the "For each X element" >> Add levelxp.CurValue to CombinedXP"

    BoosterCosts : set to the amount of XP spent on boosters

    XPtotal : set to combinedXP minus Boostercosts

    I'ma try this and give you my feedback, thank you!

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