Different movement speed with low fps

Hi!

I am doing something like this in one of my enemies (no physics involved here):

 timerEnemies = timer.performWithDelay( 20, function() enemies[i].y = enemies[i].y - enemies.speed end, 0 )

My point is that using a newer device like iPhone 6 plus with the XCode simulator, as the simulator has low fps, enemies are moving super slow.

My main character, the one the user controls, it uses physics and works fine with

physics.setTimeStep( 0 ) --time-based physics simulation

but with enemies I don’t know what to do about, because someone could manage to lower the frames per second to cheat, as the enemies move slower.

I should not worry about this matter or am I doing it wrong?

Thanks!

You are doing it wrong. 

What you are saying is every 20ms (e.g. 50 times per second) reduce the y by dy. But the performWithDelay is not so much an insistence as a request. In slower hardware and a busy application it may take 30ms, or 40ms or whatever. If it only does it every 40ms it will move ‘half as fast’.

What you need is to use the actual elapsed time which can be got from the system.timer. I have my own framework which does this and passes this value deltaTime to its routine - you can then multiply your speed by this value. This also makes it easy to express speed in manageable units.

Delta time? It has something to do with this tutorial right?

http://coronalabs.com/blog/2013/06/18/guest-tutorial-delta-time-in-corona/

I have to read it thoroughly.

Thank you Paul!  :lol:

Yes, that tutorial is excellent.

You are doing it wrong. 

What you are saying is every 20ms (e.g. 50 times per second) reduce the y by dy. But the performWithDelay is not so much an insistence as a request. In slower hardware and a busy application it may take 30ms, or 40ms or whatever. If it only does it every 40ms it will move ‘half as fast’.

What you need is to use the actual elapsed time which can be got from the system.timer. I have my own framework which does this and passes this value deltaTime to its routine - you can then multiply your speed by this value. This also makes it easy to express speed in manageable units.

Delta time? It has something to do with this tutorial right?

http://coronalabs.com/blog/2013/06/18/guest-tutorial-delta-time-in-corona/

I have to read it thoroughly.

Thank you Paul!  :lol:

Yes, that tutorial is excellent.