photonstorm/phaser-plugins — pull request #4 by ivanixgames (2014-07-28 19:34:43+00:00)
Title: Created SaveCPU plugin for Phaser

Hello,
A few months back, I noticed rather high cpu usage when using phaser 2.0.3. I traced the usage to the rendering section of phaser that executed even when no redrawing of the game screen was required.
At the time, I added a quick hack to the phaser code to test for a renderDirty flag which I would set true when I knew that the screen had to be updated. A few days back, I tried phaser 2.0.7 and found the same high cpu usage. I was about to provide patches to the dev branch of phaser when I realized I could create a plugin instead that could be added to games using older versions of phaser.

Use case scenarios include casual/puzzle games, menus that wait for user input, or for applications such as a slideshow where a lower frame rate can be used.

So I think that not only should it reduce CPU and keep a notebook cooler, it should also help save battery on mobile devices.

The plugin should work on phaser versions 2.0.3 to current of 2.0.7.
The code works by set renderType to HEADLESS when rendering should not occur. I took note that there is a main condition in phaser core loop that will bypass rendering section for this setting.

There are three ways to trigger rendering as described in the comments below.
Property renderOnFPS which set maximum FPS rate and renders when time exceeded.
Property renderOnPointerChanged, when true, will trigger rendering if pointer (mouse/touch) has changed.
Method forceRender which call be called to force a trigger.

Cheers