From 21c0be4d021fc4cc5737e20caff0c3f1fc3e2006 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Fri, 21 Mar 2014 18:37:54 +0000 Subject: [PATCH] BitmapDatas when used as Game Object textures in WebGL now update themselves properly. Timer.ms now correctly reports the ms time even if the Timer has been paused (thanks Nambew, fix #624) --- README.md | 2 ++ src/gameobjects/BitmapData.js | 1 - src/gameobjects/Image.js | 2 +- src/gameobjects/Sprite.js | 2 +- src/gameobjects/TileSprite.js | 2 +- src/time/Timer.js | 10 +++++++++- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f6fe05e1c..b7aa3c4f0 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,8 @@ Bug Fixes * p2 revolute pivots were wrongly signed (thanks georgiee, fix #621) * P2.Body.loadPolygon no longer modifies the Cache array (fix #613) * The volume given in Sound.play now over-rides that set in Sound.addMarker if specified (fix #623) +* BitmapDatas when used as Game Object textures in WebGL now update themselves properly. +* Timer.ms now correctly reports the ms time even if the Timer has been paused (thanks Nambew, fix #624) Updated diff --git a/src/gameobjects/BitmapData.js b/src/gameobjects/BitmapData.js index 634c50b07..eb35e5a6f 100644 --- a/src/gameobjects/BitmapData.js +++ b/src/gameobjects/BitmapData.js @@ -364,7 +364,6 @@ Phaser.BitmapData.prototype = { */ render: function () { -console.log('bmd dity'); if (this.game.renderType === Phaser.WEBGL && this.dirty) { // Only needed if running in WebGL, otherwise this array will never get cleared down diff --git a/src/gameobjects/Image.js b/src/gameobjects/Image.js index 55d6b6e20..c7097acfc 100644 --- a/src/gameobjects/Image.js +++ b/src/gameobjects/Image.js @@ -225,7 +225,7 @@ Phaser.Image.prototype.loadTexture = function (key, frame) { } else if (key instanceof Phaser.BitmapData) { - this.key = key.key; + this.key = key; this.setTexture(key.texture); return; } diff --git a/src/gameobjects/Sprite.js b/src/gameobjects/Sprite.js index 3211967b8..945f6f929 100644 --- a/src/gameobjects/Sprite.js +++ b/src/gameobjects/Sprite.js @@ -354,7 +354,7 @@ Phaser.Sprite.prototype.loadTexture = function (key, frame) { } else if (key instanceof Phaser.BitmapData) { - this.key = key.key; + this.key = key; this.setTexture(key.texture); return; } diff --git a/src/gameobjects/TileSprite.js b/src/gameobjects/TileSprite.js index 5399fb345..f70147b12 100644 --- a/src/gameobjects/TileSprite.js +++ b/src/gameobjects/TileSprite.js @@ -341,7 +341,7 @@ Phaser.TileSprite.prototype.loadTexture = function (key, frame) { } else if (key instanceof Phaser.BitmapData) { - this.key = key.key; + this.key = key; this.setTexture(key.texture); return; } diff --git a/src/time/Timer.js b/src/time/Timer.js index 8e05ea594..ce5e34fad 100644 --- a/src/time/Timer.js +++ b/src/time/Timer.js @@ -85,6 +85,12 @@ Phaser.Timer = function (game, autoDestroy) { */ this._pauseStarted = 0; + /** + * @property {number} _pauseTotal - Total paused time. + * @private + */ + this._pauseTotal = 0; + /** * @property {number} _now - The current start-time adjusted time. * @private @@ -450,6 +456,8 @@ Phaser.Timer.prototype = { { var pauseDuration = this.game.time.now - this._pauseStarted; + this._pauseTotal += pauseDuration; + for (var i = 0; i < this.events.length; i++) { this.events[i].tick += pauseDuration; @@ -570,7 +578,7 @@ Object.defineProperty(Phaser.Timer.prototype, "length", { Object.defineProperty(Phaser.Timer.prototype, "ms", { get: function () { - return this._now - this._started; + return this._now - this._started - this._pauseTotal; } });