Timer Optimization

bluebyu25bluebyu25 Member Posts: 500
edited November -1 in Working with GS (Mac)
Hey guys,

Instead of using game.timer which created all sorts of issues with a time attack mode I was creating I just made my own timer. Every 0.1 it adds 0.3...which makes it extremely close to being accurately close to a second. Just wondering though if you think this will kill my optimization of my scene or not? I guess you never know until you try but it isnt an actor heavy scene and I just made the timer last night after a lot of work and hit the sack. So before I boot up my project today after the gym I just thought I would get some input

Comments

  • DrGlickertDrGlickert Member Posts: 1,135
    Well, my first thought is that it won't fully work. Some devices run more smoother than others. So a brand new iPhone5 will make that 'timer' seem SUPER FAST. But if you're on an old 3G then that timer might actually be somewhat slow.

    Did you see my post about making your own timer with the two real attributes?

    Timers are known to effect processing speed. But if that's your only timer then you should be alright. But if you have a lot of timers, then that's no good.
  • bluebyu25bluebyu25 Member Posts: 500
    It is my only timer, but I didnt think of testing in on the device and it reflecting its counting speed. I will have to keep that in mind. Could you point me to your post on timers you were referring to?
  • DrGlickertDrGlickert Member Posts: 1,135
    It's pretty simple really. Make three real attributes;

    game.TimeStart
    game.TimeEnd
    game.TimeDisplay

    So when the scene starts, or when you want your timer to start you;
    Change attribute: game.TimeStart to game.Time

    When you want your timer to stop you do;
    Change attribute: game.TimeEnd to game.Time

    Then to find out how long the player has been playing (the scene, the race, the level, etc) do;
    Change attribute game.TimeDisplay to game.TimeEnd-game.TimeStart

    This gives a time that the player played (or how long they were in the level, etc.) And you can use that to display the time.

    If you want to display the time the player is playing during the level you can use;

    Constrain attribute game.TimeDisplay to game.Time-game.TimeStart; you can use this in an custom font so the player can see how long they've been playing.

    Good luck!
  • bluebyu25bluebyu25 Member Posts: 500
    Nice! I will give this a go. Yea I was having issues because I need the player to have a 60 second timer start when they press play and I need it to stop and reset when the timer "ends" at 60 seconds and then reset it to 0 to try again. I think your advice will accomplish all of that, thanks for the thorough post.

    EDIT: Still messing around with it, but using this method, though, how would I restart the time back to 0 so I can start the level over again once they hit retry?
Sign In or Register to comment.