Timers vs Runtimes

Hi everyone. i am using a timer to count the time and another timer to check every milisecond, because when my local variable game change to true, it will activate the code inside on this timer, but i should use a timer every milisecond or a runtime? and give me better options, better clean up memory, better performance and can crash less times.

Runtime function or…

local function StarsPhysics (event)  
 --code  
 end  
  
 StarsPhysicsTimer = timer.performWithDelay(1, StarsPhysics, 0)  
 StarsPhysicsTimerPause = timer.pause (StarsPhysicsTimer)  
  

[import]uid: 26056 topic_id: 22129 reply_id: 322129[/import]

Hey Blickon,

Have you tried running your code with Profiler, to see
if there is any difference…:slight_smile: (or What difference?)
Just wondering…

Happy Coding,

Larry
Willow Road games
[import]uid: 107633 topic_id: 22129 reply_id: 87958[/import]

I believe it is better to use a Runtime listener; I forget the actual reasoning behind this (will try to find that out) but I had a discussion about this with another member of the team a few months back and was advised as such :slight_smile: [import]uid: 52491 topic_id: 22129 reply_id: 88017[/import]

I’m pretty sure that you would want to use a Runtime. I don’t even think that timers support 1 as a value, I’m pretty sure that the minimum is 10.

Regards,
Jordan Schuetz
Ninja Pig Studios [import]uid: 29181 topic_id: 22129 reply_id: 88035[/import]

Timers support 1 as a value [import]uid: 84637 topic_id: 22129 reply_id: 88039[/import]

Hi people, thanks for all the helps, i think that runtime can be better than timers, but dont have the 100% certainty, but i am having some problem to resolve my problem with popUps, i am running my runtime on game.lua and then click on my pause button, and go to pause.lua, it is the file of popUp, when i click on the pause button i can stop the runtime because the pause button is inside of game.lua.but when the popUp is opened i only can touch on a button inside of my popUp menu to kill the pause menu and back to the game, but i cant start the runtime function, because it is on game.lua not on popUp, exist any way to resolve it?

some like:
Game.lua

  
-- Running my runtime  
-- and when touch on pause button go to pause.lua (it is a popUp) and stop the runtime.  

pause.lua (popUp)

--touch on a button inside this popUp to back to the game.lua, but i need to start again the runtime by touching on this button.  

Grateful for the helps [import]uid: 26056 topic_id: 22129 reply_id: 88047[/import]