I can't seem to find the right string.format parameter to display the 0 before single digit.
I need to display this 09:03 instead of 9:3
Can anyone help?
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
I can't seem to find the right string.format parameter to display the 0 before single digit.
I need to display this 09:03 instead of 9:3
Can anyone help?
print( string.format("%02d:%02d", 9, 3 ) )
Yes!!! Thank you very much!
Perfect question!
How about getting zeros in this context?
local hiScoreText = display.newText( hiScore,100, 10, native.systemFontBold, 18)
I am trying to do something like: 0000002540 where hiscore = 2540 for instance. I tried:
local hiScoreText = display.newText(string.format("%06d", hiScore),100, 10, native.systemFontBold, 18)
AND
local hiScoreText = display.newText( "%06d"..hiScore,100, 10, native.systemFontBold, 18)
But no luck. All this does is move the hiScore a little bit to the right but no zeros in the front of the hiScore
Any ideas?
Thanks a lot.
Mo
1 2 | local hiscore = 2540 local hiScoreText = display.newText( string.format ( "%010d", hiscore ),100, 10, native.systemFontBold, 18) |
THANKS ojnab!!!!
As usual you guys rock in this forum. Work like a charm. I was also forgetting to format my hiscore/score updates so of course at the start your solution did not "work". For newbie (like me) out there make sure your format your updates like:
hiScoreText.text = string.format ( "%010d", hiScore )
Thanks again ojnab. I appreciate it.
Mo