refreshing something every 100 ms

I have a timer.performWithDelay that’s supposed to happen every 100 seconds. i.e:

timer.performWithDelay( 100, whateverTest, 0 )  

Now I remember reading somewhere that by default the runtime refreshes 6 times a second or something? After some print testing, it seems to be doing it about 8.5 times a second. Now I tried something else where:

function TestOne()  
 firstTest = firstTest + 0.1  
 firstText.text = firstTest  
 print( firstTest )  
end  
  
function TestTwo()  
 firstTest = firstTest + 0.1  
 firstText.text = firstTest  
 print( firstTest )  
end  
  
function TeztOne()  
timer.performWithDelay( 200, TestTwo, 0 )  
end  
  
timer.performWithDelay( 200, TestOne, 0 )  
timer.performWithDelay( 100, TeztOne, 1 )  

This was just a test, I still want a single timer that happens every 100 ms, unfortunately that test didn’t work either. My question is do I have to change how many times the game checks itself, and how do I change that again since I’m not familiar with the syntax. Also, would my app be using much more resources if I change the refresh rate even though I don’t have any runtime listeners? Only on touch/tap events and timers? Thanks in advance for any help or suggestions
[import]uid: 77199 topic_id: 31399 reply_id: 331399[/import]

Hi,
What isn’t working with the 100 ms timer code? Is it just not firing at exactly 100 ms every time? Perhaps you’re getting results that vary slightly each timer iteration?

It’s hard to predict and get exact time figures in the Runtime sense. How often the game “checks itself” is going to vary slightly by what happens during each particular check, the speed of the device you’re running on, memory remaining, and other actions that occur at the same time, etc.

Not sure if there’s a solution to this if you need perfect, exact 100 ms iterations that can’t stray more than a couple milliseconds on any occurrence… sorry!

Brent

[import]uid: 9747 topic_id: 31399 reply_id: 125527[/import]

Thanks for the reply. If it were a few milliseconds away only that’d be perfectly fine, but it seems like much more. I made two timers this time, one with 100 delay and the other with 1000, here’s the result.

http://imageshack.us/a/img840/7664/coronab.png

Edit: For example in the screenshot it counts down from 16. The one that goes down every second ends up reaching 0 while the one with 100ms only reaches 2.2 I think it was. Anyway it wasn’t under 1.5. So that’s waaaaaay behind either way =(

Edit2: Second pic with the results showing it only reaches 2.5

http://imageshack.us/a/img40/2690/corona2.png [import]uid: 77199 topic_id: 31399 reply_id: 125532[/import]

How often the game “checks itself” is going to vary slightly by what happens during each particular check, the speed of the device you’re running on, memory remaining, and other actions that occur at the same time, etc. Watch movies Online [import]uid: 181805 topic_id: 31399 reply_id: 125534[/import]

I think that since all the code execution in corona apps happens in between frames, if your app is set to 60 fps, the “time graininess” of any time-related stuff has to be 17 ms. That is, if you specify 100ms, it may fire at any time from 100 to 117 ms.

The trick is not to rely on the precision of timing of when the timer fires or when the enterFrame event occurs, but base any movement or changes on the actual time elapsed (using something like system.getTimer() ). [import]uid: 160496 topic_id: 31399 reply_id: 125549[/import]

Hi,
What isn’t working with the 100 ms timer code? Is it just not firing at exactly 100 ms every time? Perhaps you’re getting results that vary slightly each timer iteration?

It’s hard to predict and get exact time figures in the Runtime sense. How often the game “checks itself” is going to vary slightly by what happens during each particular check, the speed of the device you’re running on, memory remaining, and other actions that occur at the same time, etc.

Not sure if there’s a solution to this if you need perfect, exact 100 ms iterations that can’t stray more than a couple milliseconds on any occurrence… sorry!

Brent

[import]uid: 9747 topic_id: 31399 reply_id: 125527[/import]

Thanks for the reply. If it were a few milliseconds away only that’d be perfectly fine, but it seems like much more. I made two timers this time, one with 100 delay and the other with 1000, here’s the result.

http://imageshack.us/a/img840/7664/coronab.png

Edit: For example in the screenshot it counts down from 16. The one that goes down every second ends up reaching 0 while the one with 100ms only reaches 2.2 I think it was. Anyway it wasn’t under 1.5. So that’s waaaaaay behind either way =(

Edit2: Second pic with the results showing it only reaches 2.5

http://imageshack.us/a/img40/2690/corona2.png [import]uid: 77199 topic_id: 31399 reply_id: 125532[/import]

How often the game “checks itself” is going to vary slightly by what happens during each particular check, the speed of the device you’re running on, memory remaining, and other actions that occur at the same time, etc. Watch movies Online [import]uid: 181805 topic_id: 31399 reply_id: 125534[/import]

I think that since all the code execution in corona apps happens in between frames, if your app is set to 60 fps, the “time graininess” of any time-related stuff has to be 17 ms. That is, if you specify 100ms, it may fire at any time from 100 to 117 ms.

The trick is not to rely on the precision of timing of when the timer fires or when the enterFrame event occurs, but base any movement or changes on the actual time elapsed (using something like system.getTimer() ). [import]uid: 160496 topic_id: 31399 reply_id: 125549[/import]