Adding multiple variables

0 favourites
  • 6 posts
From the Asset Store
Kids Game
$49 USD
New Sounds Added Update: 115 new sound effects added for no additional cost!
  • Hi Guys,

    I've had a trawl through the forum but can't seem to find an answer to my problem.

    I have 3 levels, each with its own global variable for the level score.

    When the you die / complete the game, there's a final score layout, only I'm having headaches trying to add the 3 global variables up.

    For example:

    endScore=LevelOneScore+LevelTwoScore+LevelThreeScore ?

    Any help is much appreciated, mainly to stop any more hair falling out! :D

    And a big thanks to all the posts here for teaching me so much, you look like a good bunch!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Forgot to add, the formula I'm looking for is the one like this:

    Scoreboard Layout...

    System | Every Tick | endScore | Set text to ""&Score+Score2+Score3

    What am I doing wrong?

  • Try this for the set text: str(int(Score) + int(Score2) + int(Score3))

  • Hello Jayjay,

    Thanks for your quick response, I tried:

    str(int(Score) + int(Score2) + int(Score3))

    and

    str(int(Score)+int(Score2)+int(Score3))

    ...but it only seems to show the score from the level I was on, it doesnt add the score from previous level(s) to the end score, any ideas why?

  • I'd say you're doing the set text part right. Most likely the scores are 0 because they aren't being set properly or are being reset somewhere.

  • Hi Ramones,

    Makes sense - Jayjay's answer looks the part.

    So if I complete layout 1 (level 1) and move on to layout 2 (level 2), why isnt the global variable "Score" being remembered? On all event sheets, at the top is "reset all global variables" but I wouldnt have thought that applies when you leave it to go to a new layout? <img src="smileys/smiley23.gif" border="0" align="middle" />

    This is the first time I've done more than one level so I'm still learning!

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