GoodBoyDigital/pixi.js — pull request #322 by MikkoH (2013-09-10 21:18:29+00:00)
Title: New Class called Time to control frame rate of MovieClips

This one is a bit controversial. (Sorry)

But I was reading some blog posts and the biggest issue people had with Pixi was that there was nothing to control the frame rate of MovieClips.

I created a Class called Time which will control the frame rate of all MovieClips by multiplying the ```animationSpeed``` of MovieClips by ```Time.timeScale```.

```Time.timeScale``` is set according to the target frame rate. So for instance if your sprite sheets were exported at 30fps your target frame rate should be set to 30fps. You can access targetFrameRate via ```Time. targetFrameRate```.

```Time.timeScale``` is updated every time the render function of renderers is called. By doing ```PIXI.Time.update();```

There is also a property called ```Time.minFrameRate``` which makes sure if the renderer doesn't render for a long time that animations wont "jump" many frames ahead because the developer has chosen not to render for awhile. An example of when this could happen is if DOM based UI comes up and you don't want the renderer to run.

```Time.timeScale``` can also be used to do programmatic animations independent of frame rate. So for instance if at 60fps you wanted to move an item by 10px per frame you'd do something like:

```mySprite.position.x += 10;```

But lets say the frame rate drops to 30fps we'll actually be moving much slower across the screen. So the above can be changed to be:

```mySprite.position.x += 10 * PIXI.Time.timeScale;```

Anyway like I said this is a bit controversial cause it limits ALL MovieClips but in some way it's nice to have a global way to do this. Putting it out there for discussion.