minutes and seconds with custom fonts
patapple
Member Posts: 873
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?
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_DK Posts: 92Below 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_DK Posts: 92Have 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
Cheers
Thanks a lot
P.s: i only need minutes and seconds
thanks a lot
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)