Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gamestdio/clock

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gamestdio/clock

A simple clock/ticker implementation to track elapsed/delta time.

  • 1.1.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.6K
decreased by-0.73%
Maintainers
1
Weekly downloads
 
Created
Source

@gamestdio/clock Build Status

A simple clock/ticker implementation to track delta/elapsed time.

2kb minified

API

  • new Clock([useInterval=false])
  • clock.start([useInterval=false])
  • clock.stop()
  • clock.tick()
  • clock.elapsedTime
  • clock.deltaTime
  • clock.currentTime

Usage example

There's two ways you can use clock.js: manual or automatic.

Automatic

By initializing Clock with true as the first argument, a interval will be created, in which tick() is called 60 times per second.

import * as Clock from '@gamestdio/clock';
let clock = new Clock(true);

You can also call start(true) to create the interval.

import * as Clock from '@gamestdio/clock';
let clock = new Clock();
clock.start(true);

Manual usage

You call tick() manually in your existing loop.

import * as Clock from '@gamestdio/clock';
var clock = new Clock();

setInterval(function() {
  clock.tick();
  console.log("Delta time: ", clock.deltaTime);
  console.log("Elapsed time: ", clock.elapsedTime);
  console.log("Current time: ", clock.currentTime);
}, 1000 / 60);

License

MIT

Keywords

FAQs

Package last updated on 28 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc