How do I Addition score from different layout?

Get help using Construct 2

Post » Tue Feb 09, 2016 2:02 pm

Hi Guys new user here , anyone can help Please? I have 3 levels (layouts) ,each level has it's score global variable, ex level1=score1 , level2=score2 , level3=score 3 , at the end of the level3 which is the final level , i would like to make an addition of score1+score2+score3 to get a final score which will be used to open another layouts depending of the amount of the scores. I've tried to use ""score "&score1+score2+score3 but it gives me 12 even if the scores are different .Thanks for your help guys
B
8
S
4
Posts: 17
Reputation: 792

Post » Tue Feb 09, 2016 2:13 pm

You could probably make either an array and store values in there for each level (Assuming an array's data persists through layouts, I've never found anything that says it does or not?), or make a global object that's invisible that keeps track of the total score. At least those are the solutions I would use with my limited knowledge. :)
B
5
Posts: 43
Reputation: 311

Post » Tue Feb 09, 2016 2:37 pm

You could just make an additional variable "totalscore".

Every time you add something to score1(2,3) you also add the same amount to totalscore, so in the end you
have the total and the level specific scores.

Or at the end: totalscore=score1+score2+score3
You will need a variable to store this number anyway if you want to use it for something else.
B
7
S
2
Posts: 56
Reputation: 583

Post » Tue Feb 09, 2016 2:41 pm

I don't think Variables cross over to a new layout though? So he'd still need something to store those in to transfer them to his final layout.
B
5
Posts: 43
Reputation: 311

Post » Tue Feb 09, 2016 2:43 pm

Global variables are useable for all layouts.
Only local or instant variables arent.

For this score1-3 dont even need to be global.

A array or a global instant would work too, as you said, but a global variable is much easier.
Last edited by dsminor on Tue Feb 09, 2016 2:45 pm, edited 1 time in total.
B
7
S
2
Posts: 56
Reputation: 583

Post » Tue Feb 09, 2016 2:45 pm

Interesting, I always figured global variables were global for that layout only (Although thinking back, the name should have been a dead giveaway.). Guess that would solve his problem. :)

(And thank you for teaching me something new! :D )
B
5
Posts: 43
Reputation: 311

Post » Wed Feb 10, 2016 4:59 pm

Thanks for your answers guys. I've already tried to create a Total Score Global variable (Scorebe) ,everytime an object is destroyed it add ''1'' to the Totalscore and the current layout Score simultaneously. Each layout has a maximum score of 12 , means that the player needs to accumulate at least 24 points (maximum is 36 >>>> 12x3 per level) to win the game after the 3 layout (levels) . I've also tried to use the Totalscore=score1+score2+score3 but no succes...The problem is that after the final level the Game shows a total score of 36 whatever the score per level is. I'm sure i'm doing something wrong but i don't know what as i'm a pretty new user :P . Solving this problem could help me to step forward with this project :D
Thanks guys
B
8
S
4
Posts: 17
Reputation: 792

Post » Wed Feb 10, 2016 5:07 pm

Sounds like a bug in the code not like a logical problem.
B
7
S
2
Posts: 56
Reputation: 583

Post » Thu Feb 11, 2016 3:52 am

you would have to have an event sheet like score where layout 1 and 2 also call event sheet score also.

so it would be an external event sheet for global's and stuff reused through out the whole game.

layout1 = event sheet 1
layout2 = event sheet 2

on event sheet 1 and 2 include event sheet (score)
B
29
S
13
G
10
Posts: 355
Reputation: 8,312

Post » Thu Feb 11, 2016 8:03 am

Carbincopy wrote:-snip-
on event sheet 1 and 2 include event sheet (score)

I feel incredibly dumb, because I only just realized this was possible.. It's not my topic, but I'd like to thank you for pointing that out to me anyhow. :D
B
5
Posts: 43
Reputation: 311

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 4 guests