How to create a clock?

Benjamin_m5Benjamin_m5 Member Posts: 646
edited November -1 in Working with GS (Mac)
Hi everyone

I will made a clock that shows how long i'm race in my race game. Now I want that ,when I finished my Race the time that I needed to race my track, will showed on screen and saved. How can I do that? Has anyone a tutorial?
Thanks for help

Comments

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    Whilst you await T-shirts tutorial...

    It's something like..

    Make attribute, game.RaceTime and game.SaveRaceTime

    Have a timer, when race has started, that adds 1 to the game.racetime every second.

    When the race is done, stop adding 1 to the time.

    And to save it in the other attribute.

    Change Att...game.SaveRaceTime to game.racetime

    (Oh and change att game.racetime to 0, ready for your next race if you need to.)

    That should get you looking in the right direction, you could go on, to save the best 5 times, save the attributes, and load them, each time the game is opened. etc etc...
  • SparkyidrSparkyidr Member Posts: 2,033
    ^^^ What Stormy said

    I am doing exactly the same thing, and that's the best way I found to do it too.

    You can also add another attribute to save times per level if you have lots of levels.

    So have you game.racetime (this is your active timer in the level)
    Once it's done, stop the timer and add it to game.leveldonetime (this will give you the final time for the current active level and display it regardless of what level you are at)

    Then, have an attribute for each level you hae. game.level1time, game.level2time etc, and also an attribute to keep track of what level you are on... game.whatlevelisthis for example

    and have a rule before you reset the timers and go to the next levelthat says

    When game.whatlevelisthis = 1 change game.level1time to game.leveldonetime

    etc.

    Dont forget to save them at some point too...and load them
  • Rob2Rob2 Member Posts: 2,402
    capturing scene.time or game.time might be a better method as it doesn't involve a timer and you may as well make use of it as this clock is always running!
  • SparkyidrSparkyidr Member Posts: 2,033
    In mine, I actually have a timer actor, and I'm capturing self.time for it.
    Had to do a few bodge around to get it working with an "instant reset" I have made for the game. (Rather then resetting the scene.
    But deffo works.
  • Benjamin_m5Benjamin_m5 Member Posts: 646
    Okay thanks everybody. I will try it how stormystudio it says and wait for tshirtbooth tutorial.
    Tshirtbooth tutorials are great!!!
    Check it out on: http://www.youtube.com/user/GameSaladCookbook

    Thanks to all
Sign In or Register to comment.