intervals and timeouts using a delta tick. Useful for timing things with games.
var tic = require('tic')();
var clearInterval = tic.interval(function(param1) {
console.log(param1 + ' 5 tick seconds!');
}, 5000, 'Every');
var clearTimeout = tic.timeout(function() {
console.log('Only once after 10 tick seconds!');
}, 10000);
game.on('tick', function(dt) {
tic.tick(dt);
});
Returns an instance of a Tic timer.
Runs the function fn
at the given time
interval.
Runs the function fn
only once at the given time
.
Use to advance the timer.
With npm do:
npm install tic
- 1.0.0 - delta optional in tick
- 0.2.1 - fix bug with clearing timer
- 0.2.0 - now returns an instance of Tic for multiple timers
- 0.1.0 - initial release
Copyright (c) 2014 Kyle Robinson Young
Licensed under the MIT license.