I got the seconds going well:
local incrementedNum = 0;
local countingSeconds = display.newText("0", 0,0, native.systemFont, 16\*2);
countingSeconds.xScale = .5;
countingSeconds.yScale = .5;
countingSeconds:setReferencePoint(display.BottomRightReferencePoint);
countingSeconds.x = \_W-20;
countingSeconds.y = \_H-20;
local function CountUp(e)
incrementedNum = incrementedNum + 1;
countingSeconds.text = incrementedNum;
end
timer.performWithDelay(1000, CountUp, -1);
This puts the Seconds counter in the bottom right of the screen.
How would I do the same thing with milliseconds, counting up?
Here’s the catch, seconds with decimal places to represent the milliseconds.
examples:
4.34
4.34654
For anyone who is wondering why, I have some audio files, exported from Audacity. And Audacity lets me mark segments of the audiofile into milliseconds. From what I can see, I can get to about 6 decimal places in an audio file. I’m sure I won’t be really needing to work with 6 decimals, but it would be lovely to learn how to work with milliseconds with seconds and specified decimal places, if possible.
Here’s what I’ve attempted:
local incrementedNum = 0;
local markTime = system.getTimer();
local countingSeconds = display.newText("0", 0,0, native.systemFont, 16\*2);
countingSeconds.xScale = .5;
countingSeconds.yScale = .5;
countingSeconds:setReferencePoint(display.BottomRightReferencePoint);
countingSeconds.x = \_W-20;
countingSeconds.y = \_H-20;
local function CountUp(e)
incrementedNum = system.getTimer() - markTime;
countingSeconds.text = incrementedNum;
end
timer.performWithDelay(1, CountUp, -1); --1 millisecond
This definitely counts, but I’m getting only 2 decimal places.
if 22 seconds have passed, it would look like this: 22000.00
I suspect some math will have to be thrown into the mix here, but I feel I should ask around first, if there are better ways to work with decimal places as milliseconds. [import]uid: 154122 topic_id: 27297 reply_id: 327297[/import]