Skip to content

Commit

Permalink
Group.hasProperty fixed to not use hasOwnProperty, but a series of `i…
Browse files Browse the repository at this point in the history
…n` checks (thanks @mgiuffrida for the idea, phaserjs#829)
  • Loading branch information
photonstorm committed May 19, 2014
1 parent 1a7305b commit c9656e4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ Version 2.0.5 - "Tanchico" - in development
* If an object was drag enabled with bringToTop, the onDragStop event wouldn't fire until the mouse was next moved (thanks @alpera, fix #813)
* RetroFont.text would throw WebGL errors due to an issue with Pixi.RenderTexture. Fixed in Phaser and submitted code to Pixi.
* RenderTexture.resize would throw WebGL errors due to an issue with Pixi.RenderTexture. Fixed in Phaser and submitted code to Pixi.
* Group.hasProperty fixed to not use hasOwnProperty, but a series of `in` checks (thanks @mgiuffrida for the idea, #829)


### To Do
Expand Down
10 changes: 5 additions & 5 deletions src/core/Group.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,19 +643,19 @@ Phaser.Group.prototype.hasProperty = function (child, key) {

var len = key.length;

if (len === 1 && child.hasOwnProperty(key[0]))
if (len === 1 && key[0] in child)
{
return true;
}
else if (len === 2 && child.hasOwnProperty(key[0]) && child[key[0]].hasOwnProperty(key[1]))
else if (len === 2 && key[0] in child && key[1] in child[key[0]])
{
return true;
}
else if (len === 3 && child.hasOwnProperty(key[0]) && child[key[0]].hasOwnProperty(key[1]) && child[key[0]][key[1]].hasOwnProperty(key[2]))
else if (len === 3 && key[0] in child && key[1] in child[key[0]] && key[2] in child[key[0]][key[1]])
{
return true;
}
else if (len === 4 && child.hasOwnProperty(key[0]) && child[key[0]].hasOwnProperty(key[1]) && child[key[0]][key[1]].hasOwnProperty(key[2]) && child[key[0]][key[1]][key[2]].hasOwnProperty(key[3]))
else if (len === 4 && key[0] in child && key[1] in child[key[0]] && key[2] in child[key[0]][key[1]] && key[3] in child[key[0]][key[1]][key[2]])
{
return true;
}
Expand Down Expand Up @@ -696,7 +696,7 @@ Phaser.Group.prototype.setProperty = function (child, key, value, operation, for

// We can't force a property in and the child doesn't have it, so abort.
// Equally we can't add, subtract, multiply or divide a property value if it doesn't exist, so abort in those cases too.
if (!this.hasProperty(child, key, value) && (!force || operation > 0))
if (!this.hasProperty(child, key) && (!force || operation > 0))
{
return false;
}
Expand Down
6 changes: 4 additions & 2 deletions src/input/Pointer.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,15 +385,15 @@ Phaser.Pointer.prototype = {
this.screenX = event.screenX;
this.screenY = event.screenY;

if (this.isMouse && this.game.input.mouse.locked && !fromClick) {
if (this.isMouse && this.game.input.mouse.locked && !fromClick)
{
this.rawMovementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
this.rawMovementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;

this.movementX += this.rawMovementX;
this.movementY += this.rawMovementY;
}


this.x = (this.pageX - this.game.stage.offset.x) * this.game.input.scale.x;
this.y = (this.pageY - this.game.stage.offset.y) * this.game.input.scale.y;

Expand Down Expand Up @@ -662,8 +662,10 @@ Phaser.Pointer.prototype = {
* @method Phaser.Pointer#resetMovement
*/
resetMovement: function() {

this.movementX = 0;
this.movementY = 0;

}

};
Expand Down

0 comments on commit c9656e4

Please sign in to comment.