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

@callmehiphop/ticker

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@callmehiphop/ticker

Simple event-based fixed-rate game loop.

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ticker

Simple event based game loop based on the Game Programming Patterns Game Loop chapter.

Install

$ npm install --save @callmehiphop/ticker

Usage

const Ticker = require('@callmehiphop/ticker');
const ticker = new Ticker();

ticker.on('update', (dt) => {
  // update all the things!
});

ticker.on('render', () => {
  // render all the things!
});

// stop the ticker
ticker.stop();

// resume the ticker
ticker.resume();

API

new Ticker(el, [fps])

el

Type: canvas

HTML element to be passed into requestAnimationFrame - presumably canvas.

fps

Type: number
Default: 60

Desired frames per second, this will alter how often the update event is fired.

const canvas = document.getElementById('my-canvas');
const ticker = new Ticker(canvas, 30);

ticker.on('update', handler)

Indicates models should be updated with provided delta time.

handler(dt)

Type: function

ticker.on('update', (dt) => {
  // Update all your models.
});

ticker.on('render', handler)

Indicates that you should draw the current state of your models.

handler(frameStep)

frameStep is how far into the current frame we are.

Type: function

ticker.on('render', (frameStep) => {
  // Render all your models.
});

ticker.stop()

Stops the ticker.

ticker.stop();

ticker.resume()

Resumes the ticker.

ticker.resume();

License

MIT

Keywords

FAQs

Package last updated on 06 Oct 2016

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