minutes and seconds with custom fonts

patapplepatapple Member Posts: 873
edited July 2012 in Working with GS (Mac)
hi guys,

i need to create a timer of 5 minutes. I already created the expression font but i have no idea how to display minutes and seconds separately in 2 actors.
any idea?

Best Answers

  • HC_DKHC_DK Posts: 92
    edited July 2012 Accepted Answer
    Below is the code for HOURS, MINUTES and SECONDS. Only one line for each actor.

    I asume that your graphics are named 0.png, 1.png and so on.

    Use a CONSTRAIN ATTRIBUTE: self.Image to floor(floor(( game.YourTimer %3600)/60)/10)..".png"

    HOURS:
    floor(floor(( game.YourTimer %3600)/60)/10)
    floor((floor( game.CountdownTimer %3600)/60)%10)

    MINUTES:
    floor(( game.YourTimer %60)/10)
    floor( game.YourTimer %10)

    SECONDS:
    (floor( game.YourTimer *10)%10)
    floor(floor(3600 game.YourTimer *100)%10)

    Hope you can use it.

    HC
  • HC_DKHC_DK Posts: 92
    Accepted Answer
    Have a look at the file @tshirtbooth linked to.
    Look at the timer in the bottom, first line is what I explained in my previous post.

    The difference between what I wrote and the example file is the example file uses the CHANGE IMAGE behaviour inside a rule for each picture and the "code" I gave you it changes the image without the rule.

    But as I wrote in the previous post, in your MINUTE actor use a CONSTRAIN ATTRIBUTE.
    - In the first field, navigate to Image in the actor, ending of with self.Image
    - In the second field, use the expression button (black e) and insert the code for minute: floor( game.YourTimer %10)

Answers

  • maxbeaumontmaxbeaumont Member Posts: 616
    I would watch this video that Gilles did, It should help you with what you need.



    Cheers
  • patapplepatapple Member Posts: 873
    @HenrikChristensen hi, perfectly what i need but i don't understand where i need to put this expressions. Can you do a screenshot please? :)

    Thanks a lot

    P.s: i only need minutes and seconds
  • patapplepatapple Member Posts: 873
    I'm having problems and i can't create this system. anyone can create a blank project with a timer of 5 minutes with custom font?

    thanks a lot :)
  • patapplepatapple Member Posts: 873
    Problem fixed. Thanks to @tshirtbooth for the template :))
  • games4fungames4fun Member Posts: 185
    I using this template and when the time is 3599 seconds it shows 69:69 instead of 59:59 anyone know what to do to fix this problem.
  • greenrhynogreenrhyno Member, PRO Posts: 152
    edited August 2012
    Thanks for these resources @tshirtbooth (via @firemaplegames) and @HC_DK. I ended up looking at that template, then using HC_DK's example to keep things simple.

    One thing I did notice is that I think HC_DK's examples are labeled wrong. The labels from the top should be:
    Minutes
    Seconds
    Hundreds of seconds

    and hours would just be:

    (tens of hours)
    floor( game.YourTimer/36000)
    (hours)
    floor( game.YourTimer/3600)

    @games4fun - If you are using the template that was provided as a download, the math for the tens of minutes and tens of seconds digits seems a little complex to me. In the template, the formula is like this for tens of minutes (where self.divisor is set to 100):

    floor(((floor( game.Time )-(floor((floor( game.Time )/3600))*3600))/60)% self.divisor )/( self.divisor /10)

    I tried to work through that but it gets confusing. I think it should still give you a 5 in the tens of minutes place, but maybe there is a rounding error that is occurring as the timer approaches 3600 and game.Time/3600 approaches too close to 1.

    You could try using the math that @HC_DK provided which I think is simpler and would give you a 5 in the tens of seconds digit at that time. Like I said earlier, I think HC_DK just has them labeled wrong, for the ones you are having trouble with, I think they should be:

    Tens of minutes:
    floor(floor(( game.YourTimer %3600)/60)/10)

    Tens of seconds:
    floor(( game.YourTimer %60)/10)
  • KCDKCD Member Posts: 24
    A little lost. Trying to get "Minutes:Seconds" to countdown to "0:00". I am using the template but cannot get it to countdown to zero. Is there any templates or videos to watch for this.
Sign In or Register to comment.