Score not adding up...

  • Working on a game where if a user selects the correct symbol a 1 gets added to the score.

    So I've got:

    ------------------

    Global number Score = 0

    Global number result = 0

    Global number guess = 0

    System > Every tick > Text > Set text to "Score: " & Score

    ... (other game events go here)

    System > guess = result > System > Add 1 to Score

    ------------------

    What this does if result and guess match is continually add 1 to the score so the score rockets up.

    So I've also tried:

    ------------------

    Global number Score = 0

    Global number result = 0

    Global number guess = 0

    System > On start of layout > Text > Set text to "Score: " & Score

    ... (other game events go here)

    System > guess = result > System > Add 1 to Score

    ------------------

    Which then doesn't add anything to the score.

    What am I doing wrong?

  • You need to put it all together on start you set the Text to Score Global, the check Everytick for Score to change if so then set Text to "Score: 1"

    System > On start of layout > Text > Set text to "Score: " & Score

    System > Every tick > Text > Set text to "Score: " & Score

    This would be triggered once like

    if the answer is correct then:

    System > trigger once

    System > guess = result > System > set Score to Score+1

  • Ah, yes, should have read more carefully. Use trigger once, or have a variable guessok = 0, set it to 1 when correctly guessed and it will trigger only once, then when new round starts reset to zero again. You can also set text to score when guessed ok, no need to do it every tick.

  • You need to put it all together on start you set the Text to Score Global, the check Everytick for Score to change if so then set Text to "Score: 1"

    System > On start of layout > Text > Set text to "Score: " & Score

    System > Every tick > Text > Set text to "Score: " & Score

    This would be triggered once like

    if the answer is correct then:

    System > trigger once

    System > guess = result > System > set Score to Score+1

    I've tried this and the score again just rockets up.

    On a separate dummy project I've used the following bare bones that works fine:

    ---

    Global number Score - 0

    System > Every tick > Test > Set text to "Score: " & Score

    Touch > On tap gesture on Sprite01 > System > Add 1 to Score

    Touch > On tap gesture on Sprite02 > System > Subtract 2 from Score

    ---

    This works fine on the dummy project, but not when dropped into the main project.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • In order for this to work you need to add a System -> trigger once along with System > Add 1 to Score, note that Touch is constantly so if the user is touching the Sprite every tick is adding 1 to Score so the Text "Score: 0" is goin to increment like hell, to avoid that maybe you can add another global like touched or answerOk

    Then

    if -> System -> answerOk = 1

    if -> System > guess = result

    System > trigger once

    System > Add 1 to Score

    System > answerOk = 0

  • How do I select an If for if > System... ?

  • OK this is driving me up the wall now. I've managed to get the score adding/subtracting, but because it's an 'is touching' event the scores rocket up/down if the button is held.

    ---

    Global number Score = 0

    Global number Answer = 0

    Global number AnswerCheck = 0

    Global number Guess = 0

    System > On start of Layout > Score > Set text to "Score: " & Score

    System > On start of Layout > System > Set Answer to choose(1,2)

    System > On start of Layout > System > Set AnswerCheck to Answer

    Touch > Is touching GuessButtonYes > System > Set Guess to 1

    Touch > Is touching GuessButtonYes > System > Set AnswerCheck to Answer

    ---- System > Guess = AnswerCheck > System > Add 1 to Score

    ---- System > Guess = AnswerCheck > System > Restart Layout <-- restart layout adds/subtracts the score on the next layout, but it cycles through this for as long as the mouse is held down

    ---- System > Guess ? AnswerCheck > System > Subtract 1 from Score

    ---- System > Guess ? AnswerCheck > System > Restart Layout <-- restart layout adds/subtracts the score on the next layout, but it cycles through this for as long as the mouse is held down

    I've tried the Trigger once action but it still continually restarts the layer and rockets up/down the score.

    I need an action that restarts the layout once per click.

    Any ideas?

  • Because of these things I rarely use is touching.

    Almost always use onTouch Start and get Touch coordinates, then if coordinates overlap an object ( or certain distance from object ) do the actions.

    Then either reset things on touchEnd or set up a timer which will start running on touchStart then reset things after x amount of seconds

  • Thanks - I changed 'Is touching' to 'On touched' and it works fine now.

    Hopefully this will translate to mobile devices.

    Thanks for your help

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