mirror of
https://github.com/photonstorm/phaser
synced 2024-12-18 00:53:42 +00:00
Fix jshint issues in src/physics/p2
This commit is contained in:
parent
b375daa3f6
commit
1c286c1ae5
12 changed files with 39 additions and 41 deletions
|
@ -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.
|
* @property {Phaser.Physics.P2.BodyDebug} debugBody - Reference to the debug body.
|
||||||
*/
|
*/
|
||||||
this.debugBody = null
|
this.debugBody = null;
|
||||||
|
|
||||||
// Set-up the default shape
|
// Set-up the default shape
|
||||||
if (sprite)
|
if (sprite)
|
||||||
|
@ -763,7 +763,7 @@ Phaser.Physics.P2.Body.prototype = {
|
||||||
this.debugBody.destroy();
|
this.debugBody.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.debugBody = null
|
this.debugBody = null;
|
||||||
|
|
||||||
this.sprite = null;
|
this.sprite = null;
|
||||||
|
|
||||||
|
@ -965,7 +965,7 @@ Phaser.Physics.P2.Body.prototype = {
|
||||||
// top and tail
|
// top and tail
|
||||||
var idx = path.length - 1;
|
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();
|
path.pop();
|
||||||
}
|
}
|
||||||
|
@ -1123,7 +1123,7 @@ Phaser.Physics.P2.Body.prototype = {
|
||||||
return createdFixtures;
|
return createdFixtures;
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a polygon fixture. This is used during #loadPhaserPolygon.
|
* Add a polygon fixture. This is used during #loadPhaserPolygon.
|
||||||
*
|
*
|
||||||
|
@ -1136,28 +1136,26 @@ Phaser.Physics.P2.Body.prototype = {
|
||||||
|
|
||||||
if (fixtureData.circle)
|
if (fixtureData.circle)
|
||||||
{
|
{
|
||||||
var shape = new p2.Circle(this.world.pxm(fixtureData.circle.radius))
|
var shape = new p2.Circle(this.world.pxm(fixtureData.circle.radius));
|
||||||
shape.collisionGroup = fixtureData.filter.categoryBits
|
shape.collisionGroup = fixtureData.filter.categoryBits;
|
||||||
shape.collisionMask = fixtureData.filter.maskBits
|
shape.collisionMask = fixtureData.filter.maskBits;
|
||||||
shape.sensor = fixtureData.isSensor
|
shape.sensor = fixtureData.isSensor;
|
||||||
|
|
||||||
var offset = p2.vec2.create();
|
var offset = p2.vec2.create();
|
||||||
offset[0] = this.world.pxmi(fixtureData.circle.position[0] - this.sprite.width/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)
|
offset[1] = this.world.pxmi(fixtureData.circle.position[1] - this.sprite.height/2);
|
||||||
|
|
||||||
this.data.addShape(shape, offset);
|
this.data.addShape(shape, offset);
|
||||||
generatedShapes.push(shape)
|
generatedShapes.push(shape);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
polygons = fixtureData.polygons;
|
var polygons = fixtureData.polygons;
|
||||||
|
|
||||||
var cm = p2.vec2.create();
|
var cm = p2.vec2.create();
|
||||||
|
|
||||||
for (var i = 0; i < polygons.length; i++)
|
for (var i = 0; i < polygons.length; i++)
|
||||||
{
|
{
|
||||||
shapes = polygons[i];
|
var shapes = polygons[i];
|
||||||
|
|
||||||
var vertices = [];
|
var vertices = [];
|
||||||
|
|
||||||
for (var s = 0; s < shapes.length; s += 2)
|
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)
|
if (value && !this.debugBody)
|
||||||
{
|
{
|
||||||
// This will be added to the global space
|
// 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)
|
else if (!value && this.debugBody)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,7 @@ Phaser.Physics.P2.BodyDebug = function(game, body, settings) {
|
||||||
debugPolygons: false,
|
debugPolygons: false,
|
||||||
lineWidth: 1,
|
lineWidth: 1,
|
||||||
alpha: 0.5
|
alpha: 0.5
|
||||||
}
|
};
|
||||||
|
|
||||||
this.settings = Phaser.Utils.extend(defaultSettings, settings);
|
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 = new Phaser.Graphics(game);
|
||||||
|
|
||||||
this.canvas.alpha = this.settings.alpha
|
this.canvas.alpha = this.settings.alpha;
|
||||||
|
|
||||||
this.add(this.canvas);
|
this.add(this.canvas);
|
||||||
|
|
||||||
this.draw();
|
this.draw();
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
Phaser.Physics.P2.BodyDebug.prototype = Object.create(Phaser.Group.prototype)
|
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.constructor = Phaser.Physics.P2.BodyDebug;
|
||||||
|
|
||||||
Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, {
|
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)
|
if (obj instanceof p2.Body && obj.shapes.length)
|
||||||
{
|
{
|
||||||
var l = obj.shapes.length
|
var l = obj.shapes.length;
|
||||||
|
|
||||||
i = 0;
|
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);
|
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, {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
});
|
||||||
|
|
|
@ -18,4 +18,4 @@ Phaser.Physics.P2.CollisionGroup = function (bitmask) {
|
||||||
*/
|
*/
|
||||||
this.mask = bitmask;
|
this.mask = bitmask;
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
|
@ -58,7 +58,7 @@ Phaser.Physics.P2.ContactMaterial = function (materialA, materialB, options) {
|
||||||
|
|
||||||
p2.ContactMaterial.call(this, 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 = Object.create(p2.ContactMaterial.prototype);
|
||||||
Phaser.Physics.P2.ContactMaterial.prototype.constructor = Phaser.Physics.P2.ContactMaterial;
|
Phaser.Physics.P2.ContactMaterial.prototype.constructor = Phaser.Physics.P2.ContactMaterial;
|
||||||
|
|
|
@ -34,7 +34,7 @@ Phaser.Physics.P2.DistanceConstraint = function (world, bodyA, bodyB, distance,
|
||||||
|
|
||||||
p2.DistanceConstraint.call(this, bodyA, bodyB, distance, maxForce);
|
p2.DistanceConstraint.call(this, bodyA, bodyB, distance, maxForce);
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
Phaser.Physics.P2.DistanceConstraint.prototype = Object.create(p2.DistanceConstraint.prototype);
|
Phaser.Physics.P2.DistanceConstraint.prototype = Object.create(p2.DistanceConstraint.prototype);
|
||||||
Phaser.Physics.P2.DistanceConstraint.prototype.constructor = Phaser.Physics.P2.DistanceConstraint;
|
Phaser.Physics.P2.DistanceConstraint.prototype.constructor = Phaser.Physics.P2.DistanceConstraint;
|
||||||
|
|
|
@ -35,7 +35,7 @@ Phaser.Physics.P2.GearConstraint = function (world, bodyA, bodyB, angle, ratio)
|
||||||
|
|
||||||
p2.GearConstraint.call(this, bodyA, bodyB, options);
|
p2.GearConstraint.call(this, bodyA, bodyB, options);
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
Phaser.Physics.P2.GearConstraint.prototype = Object.create(p2.GearConstraint.prototype);
|
Phaser.Physics.P2.GearConstraint.prototype = Object.create(p2.GearConstraint.prototype);
|
||||||
Phaser.Physics.P2.GearConstraint.prototype.constructor = Phaser.Physics.P2.GearConstraint;
|
Phaser.Physics.P2.GearConstraint.prototype.constructor = Phaser.Physics.P2.GearConstraint;
|
||||||
|
|
|
@ -39,7 +39,7 @@ Phaser.Physics.P2.LockConstraint = function (world, bodyA, bodyB, offset, angle,
|
||||||
|
|
||||||
p2.LockConstraint.call(this, bodyA, bodyB, options);
|
p2.LockConstraint.call(this, bodyA, bodyB, options);
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
Phaser.Physics.P2.LockConstraint.prototype = Object.create(p2.LockConstraint.prototype);
|
Phaser.Physics.P2.LockConstraint.prototype = Object.create(p2.LockConstraint.prototype);
|
||||||
Phaser.Physics.P2.LockConstraint.prototype.constructor = Phaser.Physics.P2.LockConstraint;
|
Phaser.Physics.P2.LockConstraint.prototype.constructor = Phaser.Physics.P2.LockConstraint;
|
||||||
|
|
|
@ -21,7 +21,7 @@ Phaser.Physics.P2.Material = function (name) {
|
||||||
|
|
||||||
p2.Material.call(this);
|
p2.Material.call(this);
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
Phaser.Physics.P2.Material.prototype = Object.create(p2.Material.prototype);
|
Phaser.Physics.P2.Material.prototype = Object.create(p2.Material.prototype);
|
||||||
Phaser.Physics.P2.Material.prototype.constructor = Phaser.Physics.P2.Material;
|
Phaser.Physics.P2.Material.prototype.constructor = Phaser.Physics.P2.Material;
|
||||||
|
|
|
@ -44,7 +44,7 @@ Phaser.Physics.P2.PrismaticConstraint = function (world, bodyA, bodyB, lockRotat
|
||||||
|
|
||||||
p2.PrismaticConstraint.call(this, bodyA, bodyB, options);
|
p2.PrismaticConstraint.call(this, bodyA, bodyB, options);
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
Phaser.Physics.P2.PrismaticConstraint.prototype = Object.create(p2.PrismaticConstraint.prototype);
|
Phaser.Physics.P2.PrismaticConstraint.prototype = Object.create(p2.PrismaticConstraint.prototype);
|
||||||
Phaser.Physics.P2.PrismaticConstraint.prototype.constructor = Phaser.Physics.P2.PrismaticConstraint;
|
Phaser.Physics.P2.PrismaticConstraint.prototype.constructor = Phaser.Physics.P2.PrismaticConstraint;
|
||||||
|
|
|
@ -37,7 +37,7 @@ Phaser.Physics.P2.RevoluteConstraint = function (world, bodyA, pivotA, bodyB, pi
|
||||||
|
|
||||||
p2.RevoluteConstraint.call(this, bodyA, pivotA, bodyB, pivotB, maxForce);
|
p2.RevoluteConstraint.call(this, bodyA, pivotA, bodyB, pivotB, maxForce);
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
Phaser.Physics.P2.RevoluteConstraint.prototype = Object.create(p2.RevoluteConstraint.prototype);
|
Phaser.Physics.P2.RevoluteConstraint.prototype = Object.create(p2.RevoluteConstraint.prototype);
|
||||||
Phaser.Physics.P2.RevoluteConstraint.prototype.constructor = Phaser.Physics.P2.RevoluteConstraint;
|
Phaser.Physics.P2.RevoluteConstraint.prototype.constructor = Phaser.Physics.P2.RevoluteConstraint;
|
||||||
|
|
|
@ -67,7 +67,7 @@ Phaser.Physics.P2.Spring = function (world, bodyA, bodyB, restLength, stiffness,
|
||||||
|
|
||||||
p2.Spring.call(this, bodyA, bodyB, options);
|
p2.Spring.call(this, bodyA, bodyB, options);
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
Phaser.Physics.P2.Spring.prototype = Object.create(p2.Spring.prototype);
|
Phaser.Physics.P2.Spring.prototype = Object.create(p2.Spring.prototype);
|
||||||
Phaser.Physics.P2.Spring.prototype.constructor = Phaser.Physics.P2.Spring;
|
Phaser.Physics.P2.Spring.prototype.constructor = Phaser.Physics.P2.Spring;
|
||||||
|
|
|
@ -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.
|
* @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
|
* @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.
|
* @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)
|
if (object.hasOwnProperty('body') && object.body === null)
|
||||||
{
|
{
|
||||||
object.body = new Phaser.Physics.P2.Body(this.game, object, object.x, object.y, 1);
|
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);
|
object.anchor.set(0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,7 +579,7 @@ Phaser.Physics.P2.prototype = {
|
||||||
}
|
}
|
||||||
else
|
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)
|
if (left)
|
||||||
|
@ -591,7 +591,7 @@ Phaser.Physics.P2.prototype = {
|
||||||
this._wallShapes[0].collisionGroup = this.boundsCollisionGroup.mask;
|
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)
|
if (right)
|
||||||
|
@ -603,7 +603,7 @@ Phaser.Physics.P2.prototype = {
|
||||||
this._wallShapes[1].collisionGroup = this.boundsCollisionGroup.mask;
|
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)
|
if (top)
|
||||||
|
@ -615,7 +615,7 @@ Phaser.Physics.P2.prototype = {
|
||||||
this._wallShapes[2].collisionGroup = this.boundsCollisionGroup.mask;
|
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)
|
if (bottom)
|
||||||
|
@ -627,7 +627,7 @@ Phaser.Physics.P2.prototype = {
|
||||||
this._wallShapes[3].collisionGroup = this.boundsCollisionGroup.mask;
|
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);
|
this.world.addBody(this.bounds);
|
||||||
|
|
Loading…
Reference in a new issue