Skip to content
/ tic Public

⌛ setInterval/setTimeout using a delta tick. Useful for timing things with games.

License

Notifications You must be signed in to change notification settings

shama/tic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tic

intervals and timeouts using a delta tick. Useful for timing things with games.

tic

example

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);
});

api

require('tic')()

Returns an instance of a Tic timer.

tic.interval(fn, time, [param1, param2, ...])

Runs the function fn at the given time interval.

tic.timeout(fn, time, [param1, param2, ...])

Runs the function fn only once at the given time.

tic.tick([delta])

Use to advance the timer.

install

With npm do:

npm install tic

release history

  • 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

license

Copyright (c) 2014 Kyle Robinson Young
Licensed under the MIT license.

About

⌛ setInterval/setTimeout using a delta tick. Useful for timing things with games.

Resources

License

Stars

Watchers

Forks

Packages

No packages published