I don't know if this has been asked already or if I'm just being blind, dumb and or stupid?
Is there a way (function or undocumented "feature") to retrieve a millisecond count / timer from some arbitrary point?
I'm tracking a value when a mouse move event occurs so I can accurately track velocity on a list view control but for the life of me I can't seem to find a way to get some accurate timings.
Anyone got a suggestion?
TIA
WhiteTree Games - Home, home on the web, where the bits and bytes they do play!
#MakeABetterGame! "Never give up, Never
NEVER give up!" -
Winston Churchill
Comments
Returned value is in seconds and this function uses the finest resolution timer for each platform
sometimes seconds are too large amount of time, when you are debugging the performance. You can include socket.lua file in your Gideros project and use socket.gettime()*1000 to get miliseconds
os.timer() returns double precision value and provides sub-millisecond accuracy
it's not mentioned in docs?
but it says "precise" in the docs.. uhmm.. :-\"
you could also state: you can set different properties for Sprite object using set method. Why bother listing them all? :P
Likes: ar2rsawseen
@Atilim I noticed the os.timer docs said returned a value in seconds - I didn't realise the precision was good enough to just multiply the value by 1000, no worries. I feel your pain I try to not have to write documentation if I can avoid it
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
We were simply "techdojscousering"
Likes: techdojo
Likes: ar2rsawseen
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
Likes: ar2rsawseen
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
The purpose, and the implementation (basic code sample).
It seems that I have been doing the same thing by using timer.new so I must misunderstand the purpose of this function.
To implement it I created a local function
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
for example, gtween.lua uses it to synchronize the tween according to time. as @techdojo said, one other usage is calculating the velocity of a swipe. and most probably @GregBug uses it in TNT Animator to precisely control timed based animation.
i used os.timer() in tnt animator and also on tnt particles engine.
www.tntengine.com
for ex. i used to test to see if lua math.sin / math.cos was slower than (look-up table) sin/cos table.
Likes: ar2rsawseen
www.tntengine.com
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
Or you wanted to say, that guys like @atilim are sensing code execution time, they don't need to measure it at all.
@atilim when starting Gideros app:
Whoops, it feels like this asset loaded by half of a millisecond longer than usual, need to fix that right now
Btw - the os.timer thing worked perfectly!
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
Likes: techdojo
iTunes: http://itunes.com/apps/glennbacon
Amazon: http://www.amazon.com/s/ref=bl_sr_mobile-apps?_encoding=UTF8&node=2350149011&field-brandtextbin=Glenn Bacon
My apps: http://www.yummyyellow.com
www.tntengine.com
(unless your starting with Episode 1 - but let's not go there...
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
Thanks for the clarifications, but I am not sure I totally get it.
Example
In a racing game (Mario Kart) at the beginning of the race : "Ready.... go!" and from there a counter is running until the player finishes the race.
Currently I create a timer, stop it, and start it at "go!".
Then I stop it when the player reaches the end of the race.
What would be different with os.timer?
From what I could understand, the only difference lies in the precision?
What would be the best way to get the time between two events (push button1, then push button2)?
In the event for button1 you use time1=os.timer() and in the event for button2 use time2=os.timer() then the the number of milliseconds between button1 and button2 would be deltams = (time2-time1)*1000, no need to setup a timer.
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
I didn't understand how to use it and if precision was the *only* difference.
Now I do, thank you