Skip to content

Commit

Permalink
jsdoc and jshint fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
photonstorm committed Apr 11, 2014
1 parent 3d7ca63 commit a2b2d55
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 35 deletions.
27 changes: 12 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,7 @@ Updates
* p2.World.defaultFriction has been deprecated and is now p2.World.friction.
* p2.World now uses 4 bodies for the world boundaries, rather than 1 body with 4 shapes. This helps the broadphase massively.
* p2.World bounds are now included in the callback events such as beginContact and impact events.
* Thanks to @STuFF the Classes list in the API docs now indents sub-classes.

I created a collection class to easily access the fixtures of a created P2 Body.
This is especially useful in combination with PhysicsEditor and Body#addPhaserPolygon.

You can configure your whole collision grouping in PhysicsEditor and then you can later change the mask bits easily with this class. You bypassed phaser's body wrapper so you cannot (or want to) simply activate the collision groups in phaser.

You can also access parts (groups) and named fixtures by a group index or a fixture key - both properties can be set in PhysicsEditor with the custom phaser exporter.

Use cases:

Configure collision bits in PhysicsEditor and you want to change them later.
Place a sensor in your fixture and access this single fixture later (to disable temporarily)
Create a small body with threes fixtures (circle, circle + polygon/convex). Now you want that the polygon part to behave like rubber and assign a bouncing (restitution > 1) material. Assign a fixture key in PhysicsEditor and access the fixture like this. (see the image for the fixture I described)

* Thanks to @STuFF the Classes drop-down list in the API docs now indents the sub-classes.


New Features
Expand Down Expand Up @@ -137,6 +123,17 @@ New Features
* Group.remove has a new 'destroy' parameter (false by default), which will optionally call destroy on the item removed from the Group.
* Group.removeAll has a new 'destroy' parameter (false by default), which will optionally call destroy on the items removed from the Group.
* Group.removeBetween has a new 'destroy' parameter (false by default), which will optionally call destroy on the items removed from the Group.
* @georgiee created a new P2.FixtureList class to allow easy access the fixtures of a created P2 Body:

This is especially useful in combination with PhysicsEditor and P2.Body#addPhaserPolygon.

You can configure your whole collision grouping in PhysicsEditor and then you can later change the mask bits easily with this class. You can also access parts (groups) and named fixtures by a group index or a fixture key - both properties can be set in PhysicsEditor with the custom phaser exporter.

Use cases:

* Configure collision bits in PhysicsEditor and you want to change them later.
* Place a sensor in your fixture and access this single fixture later (to disable temporarily)
* Create a small body with threes fixtures (circle, circle + polygon/convex). Now you want that the polygon part to behave like rubber and assign a bouncing (restitution > 1) material. Assign a fixture key in PhysicsEditor and access the fixture like this. (see the image for the fixture I described)


Bug Fixes
Expand Down
1 change: 1 addition & 0 deletions build/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
echo <<<EOL
<script src="$path/src/physics/p2/World.js"></script>
<script src="$path/src/physics/p2/FixtureList.js"></script>
<script src="$path/src/physics/p2/PointProxy.js"></script>
<script src="$path/src/physics/p2/InversePointProxy.js"></script>
<script src="$path/src/physics/p2/Body.js"></script>
Expand Down
11 changes: 6 additions & 5 deletions src/physics/p2/Body.js
Original file line number Diff line number Diff line change
Expand Up @@ -790,11 +790,11 @@ Phaser.Physics.P2.Body.prototype = {
* Will automatically update the mass properties and bounding radius.
*
* @method Phaser.Physics.P2.Body#addShape
* @param {*} shape - The shape to add to the body.
* @param {p2.Shape} shape - The shape to add to the body.
* @param {number} [offsetX=0] - Local horizontal offset of the shape relative to the body center of mass.
* @param {number} [offsetY=0] - Local vertical offset of the shape relative to the body center of mass.
* @param {number} [rotation=0] - Local rotation of the shape relative to the body center of mass, specified in radians.
* @return {p2.Circle|p2.Rectangle|p2.Plane|p2.Line|p2.Particle} The shape that was added to the body.
* @return {p2.Shape} The shape that was added to the body.
*/
addShape: function (shape, offsetX, offsetY, rotation) {

Expand Down Expand Up @@ -1060,7 +1060,7 @@ Phaser.Physics.P2.Body.prototype = {
* If you only wish to apply it to a specific Shape in this Body then provide that as the 2nd parameter.
*
* @method Phaser.Physics.P2.Body#setMaterial
* @param {Phaser.Physics.Material} material - The Material that will be applied.
* @param {Phaser.Physics.P2.Material} material - The Material that will be applied.
* @param {p2.Shape} [shape] - An optional Shape. If not provided the Material will be added to all Shapes in this Body.
*/
setMaterial: function (material, shape) {
Expand Down Expand Up @@ -1097,7 +1097,7 @@ Phaser.Physics.P2.Body.prototype = {
* Reads the shape data from a physics data file stored in the Game.Cache and adds it as a polygon to this Body.
* The shape data format is based on the custom phaser export in.
*
* @method Phaser.Physics.P2.Body#loadPhaserPolygon
* @method Phaser.Physics.P2.Body#addPhaserPolygon
* @param {string} key - The key of the Physics Data file as stored in Game.Cache.
* @param {string} object - The key of the object within the Physics data file that you wish to load the shape data from.
*/
Expand Down Expand Up @@ -1133,8 +1133,9 @@ Phaser.Physics.P2.Body.prototype = {
/**
* Add a polygon fixture. This is used during #loadPhaserPolygon.
*
* @method Phaser.Physics.P2.Body#addPolygonFixture
* @method Phaser.Physics.P2.Body#addFixture
* @param {string} fixtureData - The data for the fixture. It contains: isSensor, filter (collision) and the actual polygon shapes.
* @return {array} An array containing the generated shapes for the given polygon.
*/
addFixture: function (fixtureData) {

Expand Down
16 changes: 1 addition & 15 deletions src/physics/p2/FixtureList.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
Phaser.Physics.P2.FixtureList = function (list) {

if (!(list instanceof Array))
if (!Array.isArray(list))
{
list = [list];
}
Expand Down Expand Up @@ -74,9 +74,6 @@ Phaser.Physics.P2.FixtureList.prototype = {

this.getFixtures(fixtureKey).forEach(setter);

// var fixtures = this.getFixtures(fixtureKey);
// fixtures.forEach(setter);

},

/**
Expand All @@ -92,9 +89,6 @@ Phaser.Physics.P2.FixtureList.prototype = {

this.getFixtures(fixtureKey).forEach(setter);

// fixtures = this.getFixtures(fixtureKey);
// fixtures.forEach(setter);

},

/**
Expand All @@ -110,9 +104,6 @@ Phaser.Physics.P2.FixtureList.prototype = {

this.getFixtures(fixtureKey).forEach(setter);

// fixtures = this.getFixtures(fixtureKey);
// fixtures.forEach(setter);

},

/**
Expand All @@ -128,9 +119,6 @@ Phaser.Physics.P2.FixtureList.prototype = {

this.getFixtures(fixtureKey).forEach(setter);

// fixtures = this.getFixtures(fixtureKey);
// fixtures.forEach(setter);

},

/**
Expand Down Expand Up @@ -220,8 +208,6 @@ Phaser.Physics.P2.FixtureList.prototype = {
_results.push(this.allFixtures = this.flatten(this.groupedFixtures));
}

// _results;

},

/**
Expand Down

0 comments on commit a2b2d55

Please sign in to comment.