I need to make a timer exactly like the one in Red Bit Escape

The timer starts at 0.00 and it counts up. Once the actor dies, the timer stops and the screen stops (screen pauses when the actor dies) and the time that has elapsed is displayed. I really need help with this, this is the last part and my game well be finished. PLEASE HELP!!

Comments

  • SocksSocks London, UK.Member Posts: 12,822

    Rule: When actor dies

    Change self.XXXX to roundTo( self.Time ,2)
    Display Text: XXXX

    Otherwise:

    Display Text: roundTo(self.Time,2)

  • tiger27tiger27 Member Posts: 127

    What socks said, but if you're using pc roundTo will be floor.

  • Ceoready_45Ceoready_45 Member, PRO Posts: 18

    hey socks, thanks but i think have the older version of gamesalad. I dont see or know what you mean when you say ( Change self.XXXX to roundTo ).What is Change self.XXXX to roundTo ? Please explain or do you have a tutorial on youtube or something? Thanks so much

  • Ceoready_45Ceoready_45 Member, PRO Posts: 18

    @tiger27 said:
    What socks said, but if you're using pc roundTo will be floor.

    @Socks said:
    Rule: When actor dies

    Change self.XXXX to roundTo( self.Time ,2)
    Display Text: XXXX

    Otherwise:

    Display Text: roundTo(self.Time,2)

    hey socks, thanks but i think have the older version of gamesalad. I dont see or know what you mean when you say ( Change self.XXXX to roundTo ).What is Change self.XXXX to roundTo ? Please explain or do you have a tutorial on youtube or something? Thanks so much

  • SocksSocks London, UK.Member Posts: 12,822

    @Ceoready_45 said:

    Like this . . .

  • Ceoready_45Ceoready_45 Member, PRO Posts: 18

    @socks
    I get what your saying, but I don't see where the XXXX is. I know when I select the actor, that's where self comes from but I don't see or know to select in order to see the XXXX part. I really can't express how grateful I am for you helping me with this.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Self or "actor" attributes are either built-in by default (e.g. self.Name, self.Time, self.Position.Y, self.Size.Width, etc.) or added as custom attributes. To add an attribute, open an actor and click on the + button. Give it a name (you can name it XXXX or something more descriptive... up to you). Then use that attribute in the behavior as @Socks showed above.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Ceoready_45Ceoready_45 Member, PRO Posts: 18

    @tatiang thank you so much, that's the part I didn't get. Here goes nothing, I'm going to give it ah go right now. Also, you commented on my first post and you told me to use round( and socks is saying to use roundTo( which is correct?

  • Ceoready_45Ceoready_45 Member, PRO Posts: 18

    @socks @tatiang what is roundTo or round? I don't see that option and when I use it, it comes up add an invalid expression. Also @tatiang I went to your YouTube page going to find a timer tut, I think this would be the perfect time for it, if you have the time. Thanks so much

  • SocksSocks London, UK.Member Posts: 12,822

    @Ceoready_45 said:
    socks tatiang what is roundTo or round?

    'round' rounds a number to the nearest whole number.

    round(44.1392) would give you 44
    round 9.8765 would give you 10

    'roundTo' rounds a number to a specific number of decimal points.

    roundTo(44.1392,1) would give you 44.1
    roundTo(44.1392,2) would give you 44.13
    roundTo(44.1392,3) would give you 44.139
    roundTo(44.1392,4) would give you 44.1392

    @Ceoready_45 said:
    I don't see that option and when I use it, it comes up add an invalid expression.

    You've most probably entered the expression incorrectly.

  • tiger27tiger27 Member Posts: 127

    @Ceoready_45 I think It's (on pc) Ceil=RoundTo, Floor=Round

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2015

    @tiger27 said:
    Ceoready_45 I think It's (on pc) Ceil=RoundTo, Floor=Round

    ceil ('ceiling') will always round up.

    ceil (55.12) = 56
    ceil (55.22) = 56
    ceil (55.32) = 56
    ceil (55.42) = 56
    ceil (55.52) = 56
    ceil (55.62) = 56
    ceil (55.72) = 56

    floor will always round down.

    floor (55.12) = 55
    floor (55.22) = 55
    floor (55.32) = 55
    floor (55.42) = 55
    floor (55.52) = 55
    floor (55.62) = 55
    floor (55.72) = 55

    Neither will give you decimal point values.

    You could use prec ('precision') which is formatted exactly the same as roundTo, so . . .

    prec(44.1392,1) would give you 44.1
    prec(44.1392,2) would give you 44.13
    prec(44.1392,3) would give you 44.139
    prec(44.1392,4) would give you 44.1392

    Or if you really wanted to you could employ some maths to increase the value of the timer / clock (or whatever you want to use) by 2 places, basically multiply it by 100, then use floor to chop off any decimal places, then divide it by 100 to return it to its correct value, but now it has two decimal places, like this:

    (floor( game.time*100))/100

    So let's say the current game time is 8.384712

    • First we multiply it by 100, so we get 838.4712
    • Now we use 'floor' to round it down, so we get 838
    • Then we divide it by 100, so we get 8.38
    • So 8.384712 becomes 8.38

    . . . .

    @Ceoready_45

    Notes: When doing a time like this set the text to 'range left' to prevent it from leaping around (when on the default 'centred') as its overall width changes between values. Also it's important to stick the above lowercase/uppercase conventions - so Ceil will not work whereas ceil will, same deal with things like roundTo and floor.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @Ceoready_45 said:
    Also tatiang I went to your YouTube page going to find a timer tut, I think this would be the perfect time for it, if you have the time. Thanks so much

    What in particular would you like to know? The Timer behavior is pretty straight forward but I'm happy to answer questions about it. Or do you mean a tutorial that explains how to make a countdown or stopwatch timer?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Ceoready_45Ceoready_45 Member, PRO Posts: 18

    @tiger27 @tatiang @Socks you guys are great, again I can't think you guys enough. Which actor do I set this rule under the timer actor or the actor that dies?

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2015

    @Ceoready_45 said:
    Which actor do I set this rule under the timer actor or the actor that dies?

    Wherever you want.

    Basic logic . . . .

    When player is alive

    Display incrementing clock

    otherwise

    Copy current clock time to a final time attribute
    Display final time attribute

  • Ceoready_45Ceoready_45 Member, PRO Posts: 18

    @Socks @tatiang @tiger27 I wanna thank you guys so much for you time patience with me. You have no idea how much you guys helped me. I finally got it to work. Thanks so much again.

Sign In or Register to comment.