mirror of
https://github.com/photonstorm/phaser
synced 2024-12-01 00:49:41 +00:00
method docs
This commit is contained in:
parent
af847de963
commit
277afa1415
1 changed files with 9 additions and 3 deletions
|
@ -1095,7 +1095,14 @@ Phaser.Physics.P2.Body.prototype = {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
loadPhaserPolygon: function (key, object, options) {
|
/**
|
||||||
|
* 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 PhysicsEditor
|
||||||
|
* @method Phaser.Physics.P2.Body#loadPhaserPolygon
|
||||||
|
* @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.
|
||||||
|
*/
|
||||||
|
loadPhaserPolygon: function (key, object) {
|
||||||
var data = this.game.cache.getPhysicsData(key, object);
|
var data = this.game.cache.getPhysicsData(key, object);
|
||||||
//cycle through the fixtures
|
//cycle through the fixtures
|
||||||
for (var i = 0; i < data.length; i++)
|
for (var i = 0; i < data.length; i++)
|
||||||
|
@ -1123,7 +1130,7 @@ Phaser.Physics.P2.Body.prototype = {
|
||||||
console.log('addPolygonFixture', fixtureData)
|
console.log('addPolygonFixture', fixtureData)
|
||||||
|
|
||||||
if (fixtureData.circle){
|
if (fixtureData.circle){
|
||||||
//a circle has unfortunately no position in p2
|
//a circle has unfortunately no position in p2. pretty useless.
|
||||||
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
|
||||||
|
@ -1211,7 +1218,6 @@ Phaser.Physics.P2.Body.prototype = {
|
||||||
for (var i = 0; i < data.length; i++)
|
for (var i = 0; i < data.length; i++)
|
||||||
{
|
{
|
||||||
var vertices = [];
|
var vertices = [];
|
||||||
console.log(data[i].filter.categoryBits)
|
|
||||||
for (var s = 0; s < data[i].shape.length; s += 2)
|
for (var s = 0; s < data[i].shape.length; s += 2)
|
||||||
{
|
{
|
||||||
vertices.push([ this.world.pxmi(data[i].shape[s]), this.world.pxmi(data[i].shape[s + 1]) ]);
|
vertices.push([ this.world.pxmi(data[i].shape[s]), this.world.pxmi(data[i].shape[s + 1]) ]);
|
||||||
|
|
Loading…
Reference in a new issue