Add coins score to Game score at the end of gameplay?

Hi Guys,

Basically I was wondering if anyone of you geniuses out here knows how I can add the amount of coins collected at the end of the game to the overall score of the game?

For example, lets say you collected 5coins in my game and your other score in the game for distance travelled is 20, how do I add it up so the overall score when the game is over will be 25 as being the total score?

Thanks in advance. Every little helps

Comments

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited August 2013
    Set up a game attribute called Total Coins, and when the game is over set the attribute like this:

    Game.Total Coins = Game.Total Coins + Game.Coins Collected This Game

    Replace "Coins Collect This Game" with the attribute you're currently using of course :)
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited August 2013
    Sorry misread your post :( It would be something like this:

    Game.Total Score = Game.Distance Travelled + Game.Coins Collected
  • Gamer1992Gamer1992 Member Posts: 83
    @KevineCross thank you so much
  • Gamer1992Gamer1992 Member Posts: 83
    @KevinCross I need your help.

    Basically I've done what you've said about adding up my two scores which works perfectly thank you.

    However, I would like to know if you know how I can save the two added score together as a high score and then load them again. SO basically for example:

    lets say Game.Distance Travelled + Game.coins collected is 1000.

    How do I save it as my highscore so i can load em together again when the person plays my game again so the highscore will remain 1000? and also when the person plays the game and beats the highscore of 1000, how do I make sure it changes to that new high score?.

    This is what I have now in my score actor in my game:

    1. Display text behaviour:
    ""..floor(game.score + Game.coins)

    2. A rule:
    Atribute: Game.totalscore > game.score + game.coins
    change attribute: Game.totalscore TO game.score + Game.coins
    Save attribute: game.totalscore ... Key. Totalscore.

    so number 2 is basically where I'm trying to save gamescore + gamecoins which gives me the total score. Then after I wanna save the total score as a highscore. But this isnt working for me so do you have any idea how I can solve this please?
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Are you testing this in GameSalad or via the GameSalad Viewer? If so it won't properly save attributes, and all would be erased each time you preview your game. It'll only save your scores when you install your game on your device.

    The code/example you've provided looks correct.
  • Gamer1992Gamer1992 Member Posts: 83
    @KevinCross that didn't work however I posted that as a question and someone answered me. So basically I had to constrain the totalscore to game.score + game.coins and then I had to make a rule and it worked perfectly. but thank you so much for the help and tips. you are a genius Mr.Kevin
Sign In or Register to comment.