Game.lockRender is a new property. If false Phaser will automatically render the display list every update. If true the render loop will be skipped. You can toggle this value at run-time to gain exact control over when Phaser renders. This can be useful in certain types of game or application. Please note that if you don't render the display list then none of the game object transforms will be updated, so use this value carefully.

This commit is contained in:
photonstorm 2014-12-02 09:03:06 +00:00
parent def662f28f
commit 35e2893db4
5 changed files with 33 additions and 5 deletions

View file

@ -163,6 +163,7 @@ correctly (this may disagree with CSS breakpoints but it aligns the with
actual CSS width), without applying a window height/width expansion as
required on mobile browsers.
* Signals have been heavily restructured to cut down on the number that are generated in-game. New signal proxies manage the setting and creation as required, cutting down on the volume of run-time object creation significantly. No user code needs to change, however if you did override Phaser.Signal or Sprite.Events then please be aware of the changes by inspecting the source (and commit #1389 by @pnstickne).
* Game.lockRender is a new property. If `false` Phaser will automatically render the display list every update. If `true` the render loop will be skipped. You can toggle this value at run-time to gain exact control over when Phaser renders. This can be useful in certain types of game or application. Please note that if you don't render the display list then none of the game object transforms will be updated, so use this value carefully.
### Updates
@ -224,6 +225,9 @@ removal of the automatic closure, results in a very lightweight
* Time.elapsedMS holds the number of milliseconds since the last Game loop, regardless of raF or setTimout being used.
* Incorrectly prepared tilemap images (with dimensions not evenly divisible by the tile dimensions) would render incorrectly when compared to the display seen in Tiled. The Phaser tilemap code has been adjusted to match the way Tiled deals with this, which should help if you're using tileset images that contain extra padding/margin pixels. Additional console warnings have been added. However the fact remains that you should carefully prepare your tilesets before using them. Crop off extra padding, make sure they are the right dimensions (thanks @SoulBeaver for the report and @pnstickne for the fix #1371)
* Text.setShadow has had the default `color` value changed from `rgba(0,0,0,0)` to `rgba(0,0,0,1)` so it appears as a black shadow by default - before the alpha channel made it invisible.
* Math.getRandom will now return `null` if random selection is missing, or array has no entries (thanks @pnstickne #1395)
* Array.transposeArray has had a small off-by-one error fixed. It didn't effect the results but meant returned arrays were 1 element bigger than needed (thanks @nextht #1394)
* State.preRender is now sent two parameters: a reference to the Phaser.Game instance and a new parameter: `elapsedTime` which is the time elapsed since the last update.
### Bug Fixes

View file

@ -10,7 +10,7 @@
*/
var Phaser = Phaser || {
VERSION: '2.2.0-RC12',
VERSION: '2.2.0-RC13',
GAMES: [],
AUTO: 0,

View file

@ -238,6 +238,15 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
*/
this.particles = null;
/**
* If `false` Phaser will automatically render the display list every update. If `true` the render loop will be skipped.
* You can toggle this value at run-time to gain exact control over when Phaser renders. This can be useful in certain types of game or application.
* Please note that if you don't render the display list then none of the game object transforms will be updated, so use this value carefully.
* @property {boolean} lockRender
* @default
*/
this.lockRender = false;
/**
* @property {boolean} stepping - Enable core loop stepping with Game.enableStep().
* @default
@ -813,7 +822,15 @@ Phaser.Game.prototype = {
},
/**
* Renders the display list. Called automatically by Game.update.
* Runs the Render cycle.
* It starts by calling State.preRender. In here you can do any last minute adjustments of display objects as required.
* It then calls the renderer, which renders the entire display list, starting from the Stage object and working down.
* It then calls plugin.render on any loaded plugins, in the order in which they were enabled.
* After this State.render is called. Any rendering that happens here will take place on-top of the display list.
* Finally plugin.postRender is called on any loaded plugins, in the order in which they were enabled.
* This method is called automatically by Game.update, you don't need to call it directly.
* Should you wish to have fine-grained control over when Phaser renders then use the `Game.lockRender` boolean.
* Phaser will only render when this boolean is `false`.
*
* @method Phaser.Game#updateRender
* @protected
@ -821,7 +838,12 @@ Phaser.Game.prototype = {
*/
updateRender: function (elapsedTime) {
this.state.preRender();
if (this.lockRender)
{
return;
}
this.state.preRender(elapsedTime);
this.renderer.render(this.stage);
this.plugins.render(elapsedTime);

View file

@ -662,12 +662,13 @@ Phaser.StateManager.prototype = {
/**
* @method Phaser.StateManager#preRender
* @protected
* @param {number} elapsedTime - The time elapsed since the last update.
*/
preRender: function () {
preRender: function (elapsedTime) {
if (this.onPreRenderCallback)
{
this.onPreRenderCallback.call(this.callbackContext, this.game);
this.onPreRenderCallback.call(this.callbackContext, this.game, elapsedTime);
}
},

View file

@ -1155,6 +1155,7 @@ declare module Phaser {
isBooted: boolean;
isRunning: boolean;
load: Phaser.Loader;
lockRender: boolean;
make: Phaser.GameObjectCreator;
math: Phaser.Math;
net: Phaser.Net;