How do I Create Highscore for Autorunner?

0 favourites
  • 4 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • I'm struggling to create a Highscore for my game. I understand that you do this through webstorage but i've had multiple attempts at this but i keep getingt different issues with it.

    I'm making this game for phones and want to display the highscore on the Main Menu and Game Over screen. I also want to so that the highscore updates as soon as the score has been beaten.

    Can someone help me out, i've provided a capx file that i created just so i'm under the 2mb limit to post it here.

    Thanks

  • Hi,

    You can see in game layout that there is scoring in the top left corner. This text object is named DistanceDisplay. Now in the GAME EVENT you can find a line where this number changes:

    http://screencloud.net/v/7kOO

    So we can assume that TotalDistance is your score.

    Now add Web Storage to the project so we can use it.

    First we need to check if there actually is any highscore so we do this event:

    http://screencloud.net/v/1kBE

    It basically means "on start of the layout check if local key "MyGameNameHighscore" exists, if not then create it set it to 0.

    Now during the game, we want to know if the highscore has been beaten. You can check it every tick or every x time. Just like this:

    http://screencloud.net/v/hLH1

    So... Every 2 seconds check if TotalDistance is greater than value stored at "MyGameNameHighscore", if yes then assign a new value to this key.

    And that's it.

    Now you wanted to view the highscore in the main menu?

    Then try adding a event that checks if the local key exists (at the start of the layout - you did this before).

    If yes, then set an object in the main menu to visible and set it's value to WebStorage.LocalValue("MyGameNameHighscore")

    Let me know if you succeeded : )

  • Btw, you dont have to create variables for toggle_sound etc. You can use Audio object to check those kind of things like "Is silent", "toggle silent" etc : )

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I've managed to get it working so thank you for your reply, it's really helped me out. I wanted to add a flashing 'New Highscore' text when a highscore has been beaten but i'm having a little trouble with that.

    I've done the following -

    System - (Compare Variable) Total Distance>WebStorage.LocalValue("HighScore")

    Action - (System) Create Object

    The create object is a sprite that says New Highscore, but this doesn't appear when i beat a highscore for some reason, can you tell what i'm doing wrong? I'm also struggling to get the flashing behaviour to work as the sprite doesn't flash even though i've enabled its behaviour and added a Flash action to the Sprite.

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