Timer score

PixelPunPixelPun Member Posts: 324
edited November -1 in Working with GS (Mac)
I just need a simple timer that will count up as a high score. I have looked all over the forums but haven't been able to find one. The score will be the time the actor stays alive... so it needs to count up automatically.... any help would be greatly appreciated.... thanks.

Comments

  • stanimationstanimation Member Posts: 406
    also check FireMapleGames demo on clocks. It's really good. Go to his profile page.
  • synthesissynthesis Member Posts: 1,693
    When the clock is supposed to start...spawn a "clock" actor.

    Then inside that clock actor...
    Create an attribute (integer) called "timeKeeper"
    Create a game boolean attribute called "stopTime"

    Then in the actor behavior builder...have the following:

    display text self.timeKeeper

    Rule: When self.stopTime = False
    Constrain attribute self.timeKeeper to floor(self.Time)

    This will tie the actors internal clock to an integer value. The floor just rounds it down to remove decimals.

    Then in the game...change game.stopTime to True with the game is over...which will freeze the time.

    Note:
    This will only track a seconds count. You will need to do some other arithmetic to get it to read minutes and seconds...and there are demos on how to do that.

    @Mateen...
    Spawning every .1 seconds to track a time is very inefficient and not the best way to go. Try something like above.
  • gazjmgazjm Member Posts: 578
    You could also have a game/scene attribute called score, then have a rule such as below

    timer every 1 second
    change attribute score to score+1

    You can then use the custom fonts template or display.text rule to display the figure as the time/score.
Sign In or Register to comment.