photonstorm/phaser — pull request #704 by georgiee (2014-04-10 22:27:41+00:00)
Title: P2 Fixtures Collection Class

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)

```javascript
//preparedFixtures is a definition of two circles and a polygon. The polygon is named 'myPolygonFixture' to access it later
fixtures = body.addPhaserPolygon('physics','preparedFixtures')
fixtureList = Phaser.Physics.P2.FixtureList(fixtures)
//material was created somewhere else with world#createContactMaterial
fixtureList.setMaterial(material, 'myPolygonFixture')

//polygon will contain the created p2 convex
polygon = fixtureList.getFixtureByKey('myPolygonFixture')

//You could also change mask for all three fixtures in this list
polygon = fixtureList.setMask(2)
```

![screen shot 2014-04-11 at 00 26 15](https://cloud.githubusercontent.com/assets/1701755/2674303/2d561eea-c0ff-11e3-9c10-9251be116755.png)