From 1c286c1ae5676d17a8adede35fcb84fadde00fe9 Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sat, 22 Mar 2014 23:31:26 -0700 Subject: [PATCH] Fix jshint issues in src/physics/p2 --- src/physics/p2/Body.js | 32 +++++++++++++-------------- src/physics/p2/BodyDebug.js | 16 +++++++------- src/physics/p2/CollisionGroup.js | 2 +- src/physics/p2/ContactMaterial.js | 2 +- src/physics/p2/DistanceConstraint.js | 2 +- src/physics/p2/GearConstraint.js | 2 +- src/physics/p2/LockConstraint.js | 2 +- src/physics/p2/Material.js | 2 +- src/physics/p2/PrismaticConstraint.js | 2 +- src/physics/p2/RevoluteConstraint.js | 2 +- src/physics/p2/Spring.js | 2 +- src/physics/p2/World.js | 14 ++++++------ 12 files changed, 39 insertions(+), 41 deletions(-) diff --git a/src/physics/p2/Body.js b/src/physics/p2/Body.js index 4bab0531e..6710aa54c 100644 --- a/src/physics/p2/Body.js +++ b/src/physics/p2/Body.js @@ -134,7 +134,7 @@ Phaser.Physics.P2.Body = function (game, sprite, x, y, mass) { /** * @property {Phaser.Physics.P2.BodyDebug} debugBody - Reference to the debug body. */ - this.debugBody = null + this.debugBody = null; // Set-up the default shape if (sprite) @@ -763,7 +763,7 @@ Phaser.Physics.P2.Body.prototype = { this.debugBody.destroy(); } - this.debugBody = null + this.debugBody = null; this.sprite = null; @@ -965,7 +965,7 @@ Phaser.Physics.P2.Body.prototype = { // top and tail var idx = path.length - 1; - if ( path[idx][0] === path[0][0] && path[idx][1] === path[0][1] ) + if (path[idx][0] === path[0][0] && path[idx][1] === path[0][1]) { path.pop(); } @@ -1123,7 +1123,7 @@ Phaser.Physics.P2.Body.prototype = { return createdFixtures; }, - + /** * Add a polygon fixture. This is used during #loadPhaserPolygon. * @@ -1136,28 +1136,26 @@ Phaser.Physics.P2.Body.prototype = { if (fixtureData.circle) { - var shape = new p2.Circle(this.world.pxm(fixtureData.circle.radius)) - shape.collisionGroup = fixtureData.filter.categoryBits - shape.collisionMask = fixtureData.filter.maskBits - shape.sensor = fixtureData.isSensor + var shape = new p2.Circle(this.world.pxm(fixtureData.circle.radius)); + shape.collisionGroup = fixtureData.filter.categoryBits; + shape.collisionMask = fixtureData.filter.maskBits; + shape.sensor = fixtureData.isSensor; var offset = p2.vec2.create(); - offset[0] = this.world.pxmi(fixtureData.circle.position[0] - this.sprite.width/2) - offset[1] = this.world.pxmi(fixtureData.circle.position[1] - this.sprite.height/2) - + offset[0] = this.world.pxmi(fixtureData.circle.position[0] - this.sprite.width/2); + offset[1] = this.world.pxmi(fixtureData.circle.position[1] - this.sprite.height/2); + this.data.addShape(shape, offset); - generatedShapes.push(shape) + generatedShapes.push(shape); } else { - polygons = fixtureData.polygons; - + var polygons = fixtureData.polygons; var cm = p2.vec2.create(); for (var i = 0; i < polygons.length; i++) { - shapes = polygons[i]; - + var shapes = polygons[i]; var vertices = []; for (var s = 0; s < shapes.length; s += 2) @@ -1755,7 +1753,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "debug", { if (value && !this.debugBody) { // This will be added to the global space - this.debugBody = new Phaser.Physics.P2.BodyDebug(this.game, this.data) + this.debugBody = new Phaser.Physics.P2.BodyDebug(this.game, this.data); } else if (!value && this.debugBody) { diff --git a/src/physics/p2/BodyDebug.js b/src/physics/p2/BodyDebug.js index 535a26482..85281d048 100644 --- a/src/physics/p2/BodyDebug.js +++ b/src/physics/p2/BodyDebug.js @@ -31,7 +31,7 @@ Phaser.Physics.P2.BodyDebug = function(game, body, settings) { debugPolygons: false, lineWidth: 1, alpha: 0.5 - } + }; this.settings = Phaser.Utils.extend(defaultSettings, settings); @@ -51,16 +51,16 @@ Phaser.Physics.P2.BodyDebug = function(game, body, settings) { */ this.canvas = new Phaser.Graphics(game); - this.canvas.alpha = this.settings.alpha + this.canvas.alpha = this.settings.alpha; this.add(this.canvas); this.draw(); -} +}; -Phaser.Physics.P2.BodyDebug.prototype = Object.create(Phaser.Group.prototype) -Phaser.Physics.P2.BodyDebug.prototype.constructor = Phaser.Physics.P2.BodyDebug +Phaser.Physics.P2.BodyDebug.prototype = Object.create(Phaser.Group.prototype); +Phaser.Physics.P2.BodyDebug.prototype.constructor = Phaser.Physics.P2.BodyDebug; Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, { @@ -106,7 +106,7 @@ Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, { if (obj instanceof p2.Body && obj.shapes.length) { - var l = obj.shapes.length + var l = obj.shapes.length; i = 0; @@ -149,7 +149,7 @@ Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, { this.drawRectangle(sprite, offset[0] * this.ppu, -offset[1] * this.ppu, angle, child.width * this.ppu, child.height * this.ppu, lineColor, color, lw); } - i++ + i++; } } @@ -424,4 +424,4 @@ Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, { } -}) +}); diff --git a/src/physics/p2/CollisionGroup.js b/src/physics/p2/CollisionGroup.js index f4270d3c4..8101915c4 100644 --- a/src/physics/p2/CollisionGroup.js +++ b/src/physics/p2/CollisionGroup.js @@ -18,4 +18,4 @@ Phaser.Physics.P2.CollisionGroup = function (bitmask) { */ this.mask = bitmask; -} +}; diff --git a/src/physics/p2/ContactMaterial.js b/src/physics/p2/ContactMaterial.js index 4f1328e78..230ad87ad 100644 --- a/src/physics/p2/ContactMaterial.js +++ b/src/physics/p2/ContactMaterial.js @@ -58,7 +58,7 @@ Phaser.Physics.P2.ContactMaterial = function (materialA, materialB, options) { p2.ContactMaterial.call(this, materialA, materialB, options); -} +}; Phaser.Physics.P2.ContactMaterial.prototype = Object.create(p2.ContactMaterial.prototype); Phaser.Physics.P2.ContactMaterial.prototype.constructor = Phaser.Physics.P2.ContactMaterial; diff --git a/src/physics/p2/DistanceConstraint.js b/src/physics/p2/DistanceConstraint.js index 45f8b0f7b..46d9f0b48 100644 --- a/src/physics/p2/DistanceConstraint.js +++ b/src/physics/p2/DistanceConstraint.js @@ -34,7 +34,7 @@ Phaser.Physics.P2.DistanceConstraint = function (world, bodyA, bodyB, distance, p2.DistanceConstraint.call(this, bodyA, bodyB, distance, maxForce); -} +}; Phaser.Physics.P2.DistanceConstraint.prototype = Object.create(p2.DistanceConstraint.prototype); Phaser.Physics.P2.DistanceConstraint.prototype.constructor = Phaser.Physics.P2.DistanceConstraint; diff --git a/src/physics/p2/GearConstraint.js b/src/physics/p2/GearConstraint.js index b13fa5a7a..5cd131bf4 100644 --- a/src/physics/p2/GearConstraint.js +++ b/src/physics/p2/GearConstraint.js @@ -35,7 +35,7 @@ Phaser.Physics.P2.GearConstraint = function (world, bodyA, bodyB, angle, ratio) p2.GearConstraint.call(this, bodyA, bodyB, options); -} +}; Phaser.Physics.P2.GearConstraint.prototype = Object.create(p2.GearConstraint.prototype); Phaser.Physics.P2.GearConstraint.prototype.constructor = Phaser.Physics.P2.GearConstraint; diff --git a/src/physics/p2/LockConstraint.js b/src/physics/p2/LockConstraint.js index cd8c3abba..0400d89d3 100644 --- a/src/physics/p2/LockConstraint.js +++ b/src/physics/p2/LockConstraint.js @@ -39,7 +39,7 @@ Phaser.Physics.P2.LockConstraint = function (world, bodyA, bodyB, offset, angle, p2.LockConstraint.call(this, bodyA, bodyB, options); -} +}; Phaser.Physics.P2.LockConstraint.prototype = Object.create(p2.LockConstraint.prototype); Phaser.Physics.P2.LockConstraint.prototype.constructor = Phaser.Physics.P2.LockConstraint; diff --git a/src/physics/p2/Material.js b/src/physics/p2/Material.js index 08209361e..fd9bc1951 100644 --- a/src/physics/p2/Material.js +++ b/src/physics/p2/Material.js @@ -21,7 +21,7 @@ Phaser.Physics.P2.Material = function (name) { p2.Material.call(this); -} +}; Phaser.Physics.P2.Material.prototype = Object.create(p2.Material.prototype); Phaser.Physics.P2.Material.prototype.constructor = Phaser.Physics.P2.Material; diff --git a/src/physics/p2/PrismaticConstraint.js b/src/physics/p2/PrismaticConstraint.js index d6002ceee..ba48e1029 100644 --- a/src/physics/p2/PrismaticConstraint.js +++ b/src/physics/p2/PrismaticConstraint.js @@ -44,7 +44,7 @@ Phaser.Physics.P2.PrismaticConstraint = function (world, bodyA, bodyB, lockRotat p2.PrismaticConstraint.call(this, bodyA, bodyB, options); -} +}; Phaser.Physics.P2.PrismaticConstraint.prototype = Object.create(p2.PrismaticConstraint.prototype); Phaser.Physics.P2.PrismaticConstraint.prototype.constructor = Phaser.Physics.P2.PrismaticConstraint; diff --git a/src/physics/p2/RevoluteConstraint.js b/src/physics/p2/RevoluteConstraint.js index 97f874815..327aea10a 100644 --- a/src/physics/p2/RevoluteConstraint.js +++ b/src/physics/p2/RevoluteConstraint.js @@ -37,7 +37,7 @@ Phaser.Physics.P2.RevoluteConstraint = function (world, bodyA, pivotA, bodyB, pi p2.RevoluteConstraint.call(this, bodyA, pivotA, bodyB, pivotB, maxForce); -} +}; Phaser.Physics.P2.RevoluteConstraint.prototype = Object.create(p2.RevoluteConstraint.prototype); Phaser.Physics.P2.RevoluteConstraint.prototype.constructor = Phaser.Physics.P2.RevoluteConstraint; diff --git a/src/physics/p2/Spring.js b/src/physics/p2/Spring.js index 22da2b6ec..47e20e12e 100644 --- a/src/physics/p2/Spring.js +++ b/src/physics/p2/Spring.js @@ -67,7 +67,7 @@ Phaser.Physics.P2.Spring = function (world, bodyA, bodyB, restLength, stiffness, p2.Spring.call(this, bodyA, bodyB, options); -} +}; Phaser.Physics.P2.Spring.prototype = Object.create(p2.Spring.prototype); Phaser.Physics.P2.Spring.prototype.constructor = Phaser.Physics.P2.Spring; diff --git a/src/physics/p2/World.js b/src/physics/p2/World.js index f428c07fb..4d2603e4d 100644 --- a/src/physics/p2/World.js +++ b/src/physics/p2/World.js @@ -37,7 +37,7 @@ Phaser.Physics.P2 = function (game, config) { * @property {number} frameRate - The frame rate the world will be stepped at. Defaults to 1 / 60, but you can change here. Also see useElapsedTime property. * @default */ - this.frameRate = 1 / 60; + this.frameRate = 1 / 60; /** * @property {boolean} useElapsedTime - If true the frameRate value will be ignored and instead p2 will step with the value of Game.Time.physicsElapsed, which is a delta time value. @@ -279,7 +279,7 @@ Phaser.Physics.P2.prototype = { if (object.hasOwnProperty('body') && object.body === null) { object.body = new Phaser.Physics.P2.Body(this.game, object, object.x, object.y, 1); - object.body.debug = debug + object.body.debug = debug; object.anchor.set(0.5); } @@ -579,7 +579,7 @@ Phaser.Physics.P2.prototype = { } else { - this.bounds = new p2.Body({ mass: 0, position:[this.pxmi(cx), this.pxmi(cy)] }); + this.bounds = new p2.Body({ mass: 0, position: [this.pxmi(cx), this.pxmi(cy)] }); } if (left) @@ -591,7 +591,7 @@ Phaser.Physics.P2.prototype = { this._wallShapes[0].collisionGroup = this.boundsCollisionGroup.mask; } - this.bounds.addShape(this._wallShapes[0], [this.pxmi(-hw), 0], 1.5707963267948966 ); + this.bounds.addShape(this._wallShapes[0], [this.pxmi(-hw), 0], 1.5707963267948966); } if (right) @@ -603,7 +603,7 @@ Phaser.Physics.P2.prototype = { this._wallShapes[1].collisionGroup = this.boundsCollisionGroup.mask; } - this.bounds.addShape(this._wallShapes[1], [this.pxmi(hw), 0], -1.5707963267948966 ); + this.bounds.addShape(this._wallShapes[1], [this.pxmi(hw), 0], -1.5707963267948966); } if (top) @@ -615,7 +615,7 @@ Phaser.Physics.P2.prototype = { this._wallShapes[2].collisionGroup = this.boundsCollisionGroup.mask; } - this.bounds.addShape(this._wallShapes[2], [0, this.pxmi(-hh)], -3.141592653589793 ); + this.bounds.addShape(this._wallShapes[2], [0, this.pxmi(-hh)], -3.141592653589793); } if (bottom) @@ -627,7 +627,7 @@ Phaser.Physics.P2.prototype = { this._wallShapes[3].collisionGroup = this.boundsCollisionGroup.mask; } - this.bounds.addShape(this._wallShapes[3], [0, this.pxmi(hh)] ); + this.bounds.addShape(this._wallShapes[3], [0, this.pxmi(hh)]); } this.world.addBody(this.bounds);