play-co / devkit

HTML 5 game platform for browser and mobile
http://docs.gameclosure.com
627 stars 126 forks source link

Devkit Timer API #230

Open rogueSkib opened 9 years ago

rogueSkib commented 9 years ago

This has been a TODO forever, just wanted to formalize it here.

It's super useful to globally control the tick rate of a game, for easy slow-motion or to manage frame-rate. In the past, I would override the onTick function in timer.js, but timestep animate native accelerated code was not affected and ran off its own timer.

mgh commented 9 years ago

Native animations currently tick before timestep js ticks. There are at least two options:

  1. Have the js-tick function return an adjusted dt for native, requires switching the order of animation/timestep ticks. I'm not sure if the order matters.
  2. Add an additional, optional, callback for computing the dt before the main tick. Incurs additional overhead each tick, but probably not significant.

Either route would allow easy implementation of any of the features you mentioned in JS.