Array sum question

Get help using Construct 2

Post » Fri Sep 18, 2015 11:00 pm

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!
B
24
S
6
Posts: 64
Reputation: 1,436

Post » Sat Sep 19, 2015 1:52 pm

Bump! And what the hell is with the chinese character posts spam!!
B
24
S
6
Posts: 64
Reputation: 1,436

Post » Sat Sep 19, 2015 3:13 pm

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 told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Sep 19, 2015 7:06 pm

LittleStain wrote: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!
B
24
S
6
Posts: 64
Reputation: 1,436


Return to How do I....?

Who is online

Users browsing this forum: ChesVCF, LaDestitute, OBLIVION, Solomon, yiuyiu6666 and 12 guests