0 Favourites

How do I Addition score from different layout?

  • 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

  • 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.

  • 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.

  • 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.

  • 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.

  • 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! )

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • 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

    Thanks guys

  • Sounds like a bug in the code not like a logical problem.

  • 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)

  • -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.

  • 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)

    I have 3 event sheets for the 3 layouts and a ""score"" global variable copied on each event sheet but it doesn't work. Can you please make an example very simple project? Help Please

  • You could just post the .capx iam pretty sure its just a bug.

  • Here is a demo of what I said to do.

    https://www.scirra.com/arcade/tutorial- ... topic-5495

    if text score on screen set text = Score

    updated demo as global's transfer between layouts and local's do not.

    see demo for more details.

    so if you need to have local's for each layout they need to be set on scoring event sheet

    then on layout total / finish pull local scores then add to total score.

    like seen in galaga where to total ships destroyed = total score.

    I have 3 event sheets for the 3 layouts and a ""score"" global variable copied on each event sheet but it doesn't work. Can you please make an example very simple project? Help Please

    only have to set global on one event sheet to call on all layouts

    Edit1: Updated demo to add total scores both for global and local.

    Edit2: Ok! I have not made the mod for this part, But you could also use something like subtract 1 from score lv1 add to total score if lv1 score =0 do event subtract 1 from score lv2 add to total score. if lv2 score = 0 do event subtract 1 from lv3 score add 1 to total score.

    Thus you would see text scores for each displayed score and total = 0

    Then as each score zeros out and add to total

    The next would start to zero out and add to total

    for a more cool total effect.

    Edit3 : Ok! I added a trigger button to total all scores and subtract from other scores.

    Edit4: Ok! I went as far as to make a video talking about this topic and added it to my collection of video tutorials. see them here. my-construct-2-video-tutorials_t168236

  • Carbincopy: Cool job (although it is a bit of a monologue you have there), but please next time, do edit your post yourself instead of multiposting in a row.

    Bumps of 24 hours are the only one accepted.

  • Carbincopy: Cool job (although it is a bit of a monologue you have there), but please next time, do edit your post yourself instead of multiposting in a row.

    Bumps of 24 hours are the only one accepted.

    Sorry about that. Just had way to much fun with this topic.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
99 10,153
karshinkoff's avatar
karshinkoff
Unread hot topic
62 5,915
Nesteris's avatar
Nesteris
Unread hot topic
132 29,607
chadorireborn's avatar
chadorireborn