mirror of
https://github.com/photonstorm/phaser
synced 2024-12-18 09:03:29 +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;
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue