how to make your timer a highscore

laduester42laduester42 Member Posts: 10
edited June 2012 in Working with GS (Mac)
hey guys,

i'm making a maze game where a ball goes into a hole. I have a working timer that counts up according to how long the game is played, but i would like to display the time it took on another screen of what the player got. I would also like it to have a best time that shows your high-score on that same screen. This would also have to be saved, so that when you exit the app, it saves your score, but i think i know how to do that. This way there are not only levels, but you can repeat to beat your own (timed) highscore. I've looked on youtube and no one else has this question.

Thanks

Best Answer

  • rotorrotor Posts: 25
    Accepted Answer
    Ok, so basically you want to start the start and end time for calculating how long something has taken. You do this by making 2 attributes, that you can add to your scene or actor. At the start of your game logic, when you initiate the challenge you want to record the time, so you change that attribute to the current time (Change Attribute Behaviour to set your StartTime to game.Time, for example 3.123 seconds).
    When your challenge has completed you set your second attribute EndTime to game.Time, which stores the time the challenge has completed, for example 23.123 seconds. To calculate the time span, you can just calculate, EndTime - StartTime, or 23.123 - 3.123 = 20 seconds.

    You can use a 'Save Attribute' behaviour to store your value persistently, try searching for that on YouTube, I saw a video there explaining it :)

Answers

  • laduester42laduester42 Member Posts: 10
    also, i figured out that if you die and must reset the scene, it does not reset the timer, so if you know how to do that to, that'd be great!
  • rotorrotor Member Posts: 25
    To answer your second question:
    -Make a local attribute called self.sysTime and a local attribute called self.sysEndTime
    -At the top of your logic create a Change Attribute behaviour that changes sysTime to game.Time
    -Once your level ends make a Change Attribute beheaviour to change self.sysEndTime to game.Time
    -The time it take for the level to complete you can calculate like this: self.sysEndTime - self.sysTime

    For your first question, I believe if you store the end value in a table it should be stored persistently, but I didn't get that far yet in my own project yet to work with it :)
  • laduester42laduester42 Member Posts: 10
    hey rotor,

    I tried your answer to my second question, yet it didn't work. Although, your answer was confusing, and maybe I did something wrong converting it. Could you answer again, but with more detailed instructions. I would GREATLY appreciate it.

    Thanks
  • laduester42laduester42 Member Posts: 10
    thanks, it helped :)
Sign In or Register to comment.