Skip to content

Latest commit

 

History

History
38 lines (21 loc) · 1 KB

README.md

File metadata and controls

38 lines (21 loc) · 1 KB

delta-time

delta time is simple module for time based animations for Corona SDK. It is supposed to work with enterFrame event.

deltatime.getTime()

This function returns the actual number of milliseconds that have gone by since the previous frame.

deltatime.restart()

Start counting delta time from 0. It is useful if you don't use deltatime.getTime() for a while.

Example:

local dt = require( 'deltatime' )

local player = display.newRect( 100, 100, 50, 50 )

local function loop( event )

	-- Move player object 50 pixels per second
	local dx = 50 * dt.getTime()

	player:translate( dx, 0 )

end

Runtime:addEventListener( 'enterFrame', loop )

Run

To run code you need install Corona SDK

License

This project is licensed under the MIT License - see the LICENSE.md file for details.