diff --git a/README.md b/README.md index cd61ed5da..b72d47585 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,7 @@ Updates: * Pausing the game will now mute audio and resuming will un-mute, unless it was muted via the game (fixes #439) * ScaleManager has 2 new events: ScaleManager.enterFullScreen and ScaleManager.leaveFullScreen, so you can respond to fullscreen changes directly. * RandomDataGenerator.integerInRange(min, max) now includes both `min` and `max` within its range (#501) +* Tween no longer copies all the object properties into the `_valuesStart` object on creation. Bug Fixes: diff --git a/examples/_site/view_full.html b/examples/_site/view_full.html index 2bbf93110..6e593eddb 100644 --- a/examples/_site/view_full.html +++ b/examples/_site/view_full.html @@ -91,6 +91,7 @@ + diff --git a/examples/_site/view_lite.html b/examples/_site/view_lite.html index 30e00f66b..1e9f01c74 100644 --- a/examples/_site/view_lite.html +++ b/examples/_site/view_lite.html @@ -91,6 +91,7 @@ + diff --git a/examples/tweens/easing.js b/examples/tweens/easing.js index c3a2174b2..5be7e59a7 100644 --- a/examples/tweens/easing.js +++ b/examples/tweens/easing.js @@ -31,16 +31,16 @@ function create() { // Also set the origin to the center since we don't want to // see the shadow scale to the left top. shadow.anchor.setTo(0.5, 0.5); - game.add.tween(shadow.scale).to({x: 1.0, y: 1.0}, 2400, Phaser.Easing.Bounce.Out); + game.add.tween(shadow.scale).to({x: 1.0, y: 1.0}, 2400, Phaser.Easing.Bounce.Out, true); // Add characters on top of shadows. - item = game.add.sprite(190 + 69 * i, -100, 'phaser', i); + item = game.add.sprite(190 + 69 * i, -50, 'phaser', i); // Set origin to the center to make the rotation look better. item.anchor.setTo(0.5, 0.5); // Add a simple bounce tween to each character's position. - tween = game.add.tween(item).to({y: 240}, 2400, Phaser.Easing.Bounce.Out); + tween = game.add.tween(item).to( { y: 245 }, 2400, Phaser.Easing.Bounce.Out, true); } } diff --git a/src/input/Gestures.js b/src/input/Gestures.js index 2ec5fa770..f5269c330 100644 --- a/src/input/Gestures.js +++ b/src/input/Gestures.js @@ -93,14 +93,16 @@ Phaser.Gestures.prototype = { */ remove: function (gesture) { - for(var i = this._gestures.length - 1; i >= 0; --i) + for (var i = this._gestures.length - 1; i >= 0; --i) { - if(this._gestures[i].gesture.name == new gesture().name) + if (this._gestures[i].gesture.name == new gesture().name) { delete this._gestures[i]; } } + this._gestures = this._gestures.filter(function(a){return typeof a !== 'undefined';}); + }, /** @@ -109,16 +111,18 @@ Phaser.Gestures.prototype = { */ update: function () { - if(this.active && this._pointers.length > 0) + if (this.active && this._pointers.length > 0) { var hasPointers = this._pointers.filter(function(p){return p.isDown;}).length > 0; - for(var i = this._gestures.length - 1; i >= 0; --i) + + for (var i = this._gestures.length - 1; i >= 0; --i) { - if(!this._gestures[i].hasStarted) + if (!this._gestures[i].hasStarted) { this._gestures[i].hasStarted = true; this._gestures[i].gesture.start(this._pointers); - if(this._gestures[i].onGestureStarted != null) + + if (this._gestures[i].onGestureStarted != null) { this._gestures[i].onGestureStarted(); } @@ -126,18 +130,22 @@ Phaser.Gestures.prototype = { else { var result = this._gestures[i].gesture.update(this._pointers); - if(result){ + + if (result) + { var data = this._gestures[i].gesture.getData(); - if(this._gestures[i].onGestureUpdated != null) + + if (this._gestures[i].onGestureUpdated != null) { this._gestures[i].onGestureUpdated(data); } } - if(!hasPointers) + if (!hasPointers) { this._gestures[i].gesture.stop(this._pointers); this._gestures[i].hasStarted = false; - if(this._gestures[i].onGestureStopped != null) + + if (this._gestures[i].onGestureStopped != null) { this._gestures[i].onGestureStopped(); } @@ -147,6 +155,7 @@ Phaser.Gestures.prototype = { this._pointers = this._pointers.filter(function(p){return p.isDown;}); } + }, /** @@ -157,32 +166,35 @@ Phaser.Gestures.prototype = { _updatePointerState: function (pointer) { var pointerObject = null; - for(var i = this._pointers.length - 1; i >= 0; --i) + + for (var i = this._pointers.length - 1; i >= 0; --i) { - if(this._pointers[i].pointer == pointer) + if (this._pointers[i].pointer == pointer) { pointerObject = this._pointers[i]; break; } } - if(pointerObject == null && pointer.isDown) + if (pointerObject == null && pointer.isDown) { pointerObject = { - pointer:pointer, - justPressed:true, - isUp:false, - isDown:true + pointer: pointer, + justPressed: true, + isUp: false, + isDown: true } + this._pointers.push(pointerObject); } - else if(pointerObject != null) + else if (pointerObject != null) { pointerObject.justPressed = false; pointerObject.isDown = pointer.isDown; pointerObject.isUp = pointer.isUp; } } + }; Phaser.Gestures.prototype.constructor = Phaser.Gestures; @@ -201,24 +213,29 @@ Phaser.Gestures.Helpers = { createOrFindPointerData: function(pointerArray, pointer) { var pointerObject = null; - for(var i = pointerArray.length - 1; i >= 0; --i) + + for (var i = pointerArray.length - 1; i >= 0; --i) { - if(pointerArray[i].pointer == pointer) + if (pointerArray[i].pointer == pointer) { pointerObject = pointerArray[i]; break; } } - if(pointerObject == null) + + if (pointerObject == null) { pointerObject = { pointer:pointer, isNew: true } + pointerArray.push(pointerObject); } + return pointerObject; } + }; Phaser.Gesture = {}; diff --git a/src/tween/Tween.js b/src/tween/Tween.js index f21cd6435..04ec8eb8b 100644 --- a/src/tween/Tween.js +++ b/src/tween/Tween.js @@ -158,11 +158,11 @@ Phaser.Tween = function (object, game) { */ this.pendingDelete = false; - // Set all starting values present on the target object - for (var field in object) - { - this._valuesStart[field] = parseFloat(object[field], 10); - } + // Set all starting values present on the target object - why? this will copy loads of properties we don't need - commenting out for now + // for (var field in object) + // { + // this._valuesStart[field] = parseFloat(object[field], 10); + // } /** * @property {Phaser.Signal} onStart - The onStart event is fired when the Tween begins. @@ -277,7 +277,7 @@ Phaser.Tween.prototype = { for (var property in this._valuesEnd) { // check if an Array was provided as property value - if (this._valuesEnd[property] instanceof Array) + if (Array.isArray(this._valuesEnd[property])) { if (this._valuesEnd[property].length === 0) { @@ -290,7 +290,7 @@ Phaser.Tween.prototype = { this._valuesStart[property] = this._object[property]; - if ((this._valuesStart[property] instanceof Array) === false) + if (!Array.isArray(this._valuesStart[property])) { this._valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings } diff --git a/src/utils/Debug.js b/src/utils/Debug.js index b6a4d6ad9..cc04125ac 100644 --- a/src/utils/Debug.js +++ b/src/utils/Debug.js @@ -581,15 +581,16 @@ Phaser.Utils.Debug.prototype = { this.start(); this.context.font = font; - this.context.fillStyle = color; - this.context.fillText(text, x, y); if (this.renderShadow) { this.context.fillStyle = 'rgb(0,0,0)'; - this.context.fillText(text, this.currentX + 1, this.currentY + 1); + this.context.fillText(text, x + 1, y + 1); } + this.context.fillStyle = color; + this.context.fillText(text, x, y); + this.stop(); },