Highscore is not working

0 favourites
  • 12 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • This is what I did:

    Create two text objects(t1 and t2(t2 in the game over))

    Global,highscore

    Global,Score

    Every 0.1 seconds

    • Add +1 to Global variable Score

    I have a player who flies and if he collide with the floor,

    -Go to Game over layout

    Every tick

    -Set t1 to Score

    In the gameover layout, If Global,Score > highscore

    highscore set to Score.

    t2 set to highscore

    So I want to save the high score in local.

    So this is the event above.

    If Global,Score > highscore

       -highscore set to Score.

       -Set key"savescore" to highscore   

       -t2 set to webstorage.localkey("savescore")

    But it does not load. t2 shows correct but when I close the game(Preview) and open,t2 is again zero

    ???

       

    <img src="smileys/smiley11.gif" border="0" align="middle" />

  • Well ofcourse it is..

    if you are only setting it when global.score is bigger than highscore.

    When you start the game again global will be lower, right?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well ofcourse it is..

    if you are only setting it when global.score is bigger than highscore.

    When you start the game again global will be lower, right?

    LittleStain

    Oh,My mistake

    It should be like this:

    If Global,Score > highscore

       -highscore set to Score.

       -Set key"savescore" to highscore   

    Every tick   

    -t2 set to webstorage.localkey("savescore")

  • In the gameover layout, If Global,Score > highscore

    highscore set to Score.

    t2 set to highscore

    So I want to save the high score in local.

    So this is the event above.

    If Global,Score > highscore

       -highscore set to Score.

       -Set key"savescore" to highscore   

       -t2 set to webstorage.localkey("savescore")

    I guess this could be the issue..

    first you set highscore to score, so global.score isn't bigger than highscore for the second event.

    It's not clear to me why you are using two events for this anyway.

  • LittleStain

    Score is the current score gained(Score gained in this play(before gameover)).Highscore is the biggest score gained ever.That's why I am saving it.

  • I understand what you are trying to do.

    I'm just saying the second event will not trigger if the first event is triggered, because after the first event highscore is the same as global.score, but maybe you aren't explaining your events right.

    Could you please upload a screenshot of your eventsheet so we can look for where the events are flawed?

  • Instead of saving your highscore to webstorage every tick without any conditions you could try this:

    <img src="https://dl.dropboxusercontent.com/u/48563442/highscore.jpg" border="0" />

  • LittleStain

    Why does that work? <img src="smileys/smiley25.gif" border="0" align="middle" />

  • You were saving your highscore to webstorage every tick, even when score wasn't higher than highscore.

    Highscore is 0 when the layout starts, so 0 was saved to webstorage.

  • LittleStain

    Oh,that's the case.I couldn't find another way of making that event happen.It seems NO conditions can also make this happen?just trigger once?

    Why is that?

  • LittleStain

    While the forum was down,i have done it.I have also added a feature to clear the topscore

    But I have a question though,Is there a way to pop up a dialog saying whether you want to delete the topscore and provide two options i.e Yes or No.

    I found the Browser object but it allows just Ok.Even If i press the cross,event is executed.

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