Time DEMO

firemaplegamesfiremaplegames Member Posts: 3,211
edited November -1 in Working with GS (Mac)
Hey,

I made a quick demo showing various ways to work with time in GameSalad:

http://gamesalad.com/game/play/34021

Feel free to use it however you want!

Best,
Joe

Comments

  • ktfrightktfright Member Posts: 964
    thanks!
  • JoshKahaneJoshKahane Member Posts: 470
    This is really great. I remember a game I gave up on a while ago now as I couldn't create a timer which was actually in time.

    How can I create a timer (exactly like the raw time) which has two decimal places and can be changed to have 1 and no decimal places?

    I have made one before by just making a real attribute and displaying it with a timer rule saying every 0.01 seconds add 0.01 but its a super slow clock. I want it to run at the speed of a clock. Thanks.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    awesome!
  • firemaplegamesfiremaplegames Member Posts: 3,211
    glad I could help!
  • firemaplegamesfiremaplegames Member Posts: 3,211
    i'll see what i can do...
    i'll try to add it later today.
  • JCFordJCFord Member Posts: 785
    A big thank you from me, this is great - well done!
  • firemaplegamesfiremaplegames Member Posts: 3,211
    I just quickly added tenths and hundredths of a second to the standard time...

    I'll see about thousandths...

    Although, to be honest, I don't think it will be fast enough on an iPhone to realistically capture that...

    I'll look into it later.

    Joe
  • firemaplegamesfiremaplegames Member Posts: 3,211
    sure.

    If you look at the standard time Actor in the demo, and open its expression editor. you'll see the code for generating the time.( it's a million miles long...)

    each chunk of code between each ".." represents a digit in the display.

    Here is is broken out onto separate lines:

    hours, 1st digit...................floor(floor( game.Time /3600)/10)
    hours, 2nd digit..................floor(floor( game.Time /3600)%10)
    minutes, 1st digit...............floor(floor(( game.Time /3600)/60)/10)
    minutes, 2nd digit..............floor((floor( game.Time %3600)/60)%10)
    seconds, 1st digit..............floor(( game.Time %60)/10)
    seconds, 2nd digit.............floor( game.Time %10)
    tenths of a second............(floor( game.Time *10)%10)
    hundredths of a second....floor(floor( game.Time *100)%10)

    For what you just asked, just use from minutes, 2nd digit, to the bottom line.

    You'll need to use the concatenate operator in between each line to string it all together in the expression editor. The concatenate operator is two periods [..] If you need the colon as well, put that in quotes like this: [..":"..]
  • firemaplegamesfiremaplegames Member Posts: 3,211
    hmmm.

    instead of updating the timer every 1 second, can you update it every 0.01 second?

    I hear what you're saying though, but I don't know the answer. Somebody more mathematical would have to answer it....
  • firemaplegamesfiremaplegames Member Posts: 3,211
    or when you pause, can you store all the digits as separate attributes? then load them back in when you unpause?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    or when you hit pause, record that time: startPauseTime

    and a new attribute called pausedTime.

    When you unpause, subtract startPausedTime from game.Time and add it to pausedTime.

    Then subtract pausedTime from game.Time when you do your display calculations.

    Just thinking out loud here. basically subtract the time the game is paused from the current time to account for that offset.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    hmmm.

    if you toggle the start/stop button in the demo, it subtracts real numbers from each other.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    ok, i'm working on a demo, I'll see if I can get it working...
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Ok, I figured it out...

    Here is a little demo showing how to pause/resume a time display...

    http://gamesalad.com/game/play/34237

    You're trying to make me think on a Sunday!
Sign In or Register to comment.