66
77var Bodies = require ( './lib/factory/Bodies' ) ;
88var Body = require ( './lib/body/Body' ) ;
9- var GetFastValue = require ( '../../utils/object/GetFastValue' ) ;
10- var Common = require ( './lib/core/Common' ) ;
11- var Vertices = require ( './lib/geometry/Vertices' ) ;
129var Bounds = require ( './lib/geometry/Bounds' ) ;
10+ var Common = require ( './lib/core/Common' ) ;
11+ var GetFastValue = require ( '../../utils/object/GetFastValue' ) ;
1312var Vector = require ( './lib/geometry/Vector' ) ;
14-
13+ var Vertices = require ( './lib/geometry/Vertices' ) ;
1514
1615/**
1716 * Use PhysicsEditorParser.parseBody() to build a Matter body object, based on a physics data file
@@ -25,33 +24,39 @@ var PhysicsEditorParser = {
2524 /**
2625 * Parses a body element exported by PhysicsEditor.
2726 *
28- * @method Phaser.Physics.Matter.PhysicsEditorParser#parseBody
27+ * @function Phaser.Physics.Matter.PhysicsEditorParser.parseBody
28+ * @since 3.10.0
2929 *
30- * @param {number } x - x position
31- * @param {number } y - y position
32- * @param {number } w - width
33- * @param {number } h - height
34- * @param {object } config - body configuration and fixture (child body) definitions
35- * @return {object } a matter body, consisting of several parts (child bodies)
30+ * @param {number } x - x position.
31+ * @param {number } y - y position.
32+ * @param {number } w - width.
33+ * @param {number } h - height.
34+ * @param {object } config - body configuration and fixture (child body) definitions.
35+ *
36+ * @return {object } A matter body, consisting of several parts (child bodies)
3637 */
3738 parseBody : function ( x , y , w , h , config )
3839 {
3940 var fixtureConfigs = GetFastValue ( config , 'fixtures' , [ ] ) ;
4041 var fixtures = [ ] ;
42+
4143 for ( var fc = 0 ; fc < fixtureConfigs . length ; fc ++ )
4244 {
4345 var fixtureParts = this . parseFixture ( fixtureConfigs [ fc ] ) ;
44- for ( var i = 0 ; i < fixtureParts . length ; i ++ )
46+
47+ for ( var i = 0 ; i < fixtureParts . length ; i ++ )
4548 {
4649 fixtures . push ( fixtureParts [ i ] ) ;
4750 }
4851 }
4952
5053 var matterConfig = Common . extend ( { } , false , config ) ;
54+
5155 delete matterConfig . fixtures ;
5256 delete matterConfig . type ;
5357
5458 var body = Body . create ( matterConfig ) ;
59+
5560 Body . setParts ( body , fixtures ) ;
5661 body . render . sprite . xOffset = body . position . x / w ;
5762 body . render . sprite . yOffset = body . position . y / h ;
@@ -64,18 +69,22 @@ var PhysicsEditorParser = {
6469 /**
6570 * Parses an element of the "fixtures" list exported by PhysicsEditor
6671 *
67- * @method Phaser.Physics.Matter.PhysicsEditorParser#parseFixture
72+ * @function Phaser.Physics.Matter.PhysicsEditorParser.parseFixture
73+ * @since 3.10.0
6874 *
6975 * @param {object } fixtureConfig - the fixture object to parse
70- * @return {object[] } - a list of matter bodies
76+ *
77+ * @return {object[] } - A list of matter bodies
7178 */
7279 parseFixture : function ( fixtureConfig )
7380 {
7481 var matterConfig = Common . extend ( { } , false , fixtureConfig ) ;
82+
7583 delete matterConfig . circle ;
7684 delete matterConfig . vertices ;
7785
7886 var fixtures ;
87+
7988 if ( fixtureConfig . circle )
8089 {
8190 var x = GetFastValue ( fixtureConfig . circle , 'x' ) ;
@@ -87,18 +96,20 @@ var PhysicsEditorParser = {
8796 {
8897 fixtures = this . parseVertices ( fixtureConfig . vertices , matterConfig ) ;
8998 }
99+
90100 return fixtures ;
91101 } ,
92102
93-
94103 /**
95- * Parses the "vertices" lists exported by PhysicsEditor
104+ * Parses the "vertices" lists exported by PhysicsEditor.
96105 *
97- * @method Phaser.Physics.Matter.PhysicsEditorParser#parseVertices
106+ * @function Phaser.Physics.Matter.PhysicsEditorParser.parseVertices
107+ * @since 3.10.0
98108 *
99- * @param {object } vertexSets - the vertex lists to parse
100- * @param {object } options - matter body options
101- * @return {object[] } - a list of matter bodies
109+ * @param {object } vertexSets - The vertex lists to parse.
110+ * @param {object } options - Matter body options.
111+ *
112+ * @return {object[] } - A list of matter bodies.
102113 */
103114 parseVertices : function ( vertexSets , options )
104115 {
0 commit comments