Skip to content

Commit ea52b2e

Browse files
committed
Updated jsdocs
1 parent feabcda commit ea52b2e

6 files changed

Lines changed: 426 additions & 184 deletions

File tree

src/math/const.js

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,57 @@ var RND = require('./random-data-generator/RandomDataGenerator');
33
var MATH_CONST = {
44

55
/**
6-
* The value of PI * 2.
7-
*
8-
* @constant
9-
* @name Phaser.Math.PI2
10-
* @since 3.0.0
11-
* @type {number}
12-
*/
6+
* The value of PI * 2.
7+
*
8+
* @name Phaser.Math.PI2
9+
* @type {number}
10+
* @since 3.0.0
11+
*/
1312
PI2: Math.PI * 2,
1413

1514
/**
16-
* The value of PI * 0.5.
17-
*
18-
* @constant
19-
* @name Phaser.Math.TAU
20-
* @since 3.0.0
21-
* @type {number}
22-
*/
15+
* The value of PI * 0.5.
16+
*
17+
* @name Phaser.Math.TAU
18+
* @type {number}
19+
* @since 3.0.0
20+
*/
2321
TAU: Math.PI * 0.5,
2422

2523
/**
26-
* An epsilon value (1.0e-6)
27-
*
28-
* @constant
29-
* @name Phaser.Math.EPSILON
30-
* @since 3.0.0
31-
* @type {number}
32-
*/
24+
* An epsilon value (1.0e-6)
25+
*
26+
* @name Phaser.Math.EPSILON
27+
* @type {number}
28+
* @since 3.0.0
29+
*/
3330
EPSILON: 1.0e-6,
3431

3532
/**
36-
* For converting degrees to radians (PI / 180)
37-
*
38-
* @constant
39-
* @name Phaser.Math.DEG_TO_RAD
40-
* @since 3.0.0
41-
* @type {number}
42-
*/
33+
* For converting degrees to radians (PI / 180)
34+
*
35+
* @name Phaser.Math.DEG_TO_RAD
36+
* @type {number}
37+
* @since 3.0.0
38+
*/
4339
DEG_TO_RAD: Math.PI / 180,
4440

4541
/**
46-
* For converting radians to degrees (180 / PI)
47-
*
48-
* @constant
49-
* @name Phaser.Math.RAD_TO_DEG
50-
* @since 3.0.0
51-
* @type {number}
52-
*/
42+
* For converting radians to degrees (180 / PI)
43+
*
44+
* @name Phaser.Math.RAD_TO_DEG
45+
* @type {number}
46+
* @since 3.0.0
47+
*/
5348
RAD_TO_DEG: 180 / Math.PI,
5449

5550
/**
56-
* An instance of the Random Number Generator.
57-
*
58-
* @constant
59-
* @name Phaser.Math.RND
60-
* @since 3.0.0
61-
* @type {Phaser.Math.RandomDataGenerator}
62-
*/
51+
* An instance of the Random Number Generator.
52+
*
53+
* @name Phaser.Math.RND
54+
* @type {Phaser.Math.RandomDataGenerator}
55+
* @since 3.0.0
56+
*/
6357
RND: new RND()
6458

6559
};

src/math/index.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
var RND = require('./random-data-generator/RandomDataGenerator');
1+
var CONST = require('./const');
2+
var Extend = require('../utils/object/Extend');
23

34
/**
45
* @namespace Phaser.Math
56
*/
67

7-
module.exports = {
8-
9-
// Consts
10-
PI2: Math.PI * 2,
11-
TAU: Math.PI * 0.5,
12-
EPSILON: 1.0e-6,
13-
DEG_TO_RAD: Math.PI / 180,
14-
RAD_TO_DEG: 180 / Math.PI,
15-
16-
// Random Data Generator
17-
RND: new RND(),
8+
var PhaserMath = {
189

1910
// Collections of functions
2011
Angle: require('./angle/'),
@@ -71,3 +62,11 @@ module.exports = {
7162
RotateVec3: require('./RotateVec3')
7263

7364
};
65+
66+
// Merge in the consts
67+
68+
PhaserMath = Extend(false, PhaserMath, CONST);
69+
70+
// Export it
71+
72+
module.exports = PhaserMath;

src/tilemaps/Formats.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,43 @@
1+
/**
2+
* @namespace Phaser.Tilemaps.Formats
3+
*/
4+
15
module.exports = {
26

7+
/**
8+
* CSV Map Type
9+
*
10+
* @name Phaser.Tilemaps.Formats.CSV
11+
* @type {number}
12+
* @since 3.0.0
13+
*/
314
CSV: 0,
15+
16+
/**
17+
* Tiled JSON Map Type
18+
*
19+
* @name Phaser.Tilemaps.Formats.TILED_JSON
20+
* @type {number}
21+
* @since 3.0.0
22+
*/
423
TILED_JSON: 1,
24+
25+
/**
26+
* 2D Array Map Type
27+
*
28+
* @name Phaser.Tilemaps.Formats.ARRAY_2D
29+
* @type {number}
30+
* @since 3.0.0
31+
*/
532
ARRAY_2D: 2,
33+
34+
/**
35+
* Weltmeister (Impact.js) Map Type
36+
*
37+
* @name Phaser.Tilemaps.Formats.WELTMEISTER
38+
* @type {number}
39+
* @since 3.0.0
40+
*/
641
WELTMEISTER: 3
742

843
};

src/tilemaps/ImageCollection.js

Lines changed: 90 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ var Class = require('../utils/Class');
22

33
/**
44
* @classdesc
5-
* An Image Collection is a special tileset containing mulitple images, with no slicing into each image.
5+
* An Image Collection is a special Tile Set containing multiple images, with no slicing into each image.
66
*
77
* Image Collections are normally created automatically when Tiled data is loaded.
88
*
9-
* @class Phaser.ImageCollection
9+
* @class ImageCollection
10+
* @memberOf Phaser.Tilemaps
1011
* @constructor
12+
* @since 3.0.0
13+
*
1114
* @param {string} name - The name of the image collection in the map data.
1215
* @param {integer} firstgid - The first image index this image collection contains.
1316
* @param {integer} [width=32] - Width of widest image (in pixels).
@@ -28,99 +31,130 @@ var ImageCollection = new Class({
2831
if (spacing === undefined) { spacing = 0; }
2932

3033
/**
31-
* The name of the Image Collection.
32-
* @property {string} name
34+
* The name of the Image Collection.
35+
*
36+
* @name Phaser.Tilemaps.ImageCollection#name
37+
* @type {string}
38+
* @since 3.0.0
3339
*/
3440
this.name = name;
3541

3642
/**
37-
* The Tiled firstgid value.
38-
* This is the starting index of the first image index this Image Collection contains.
39-
* @property {integer} firstgid
40-
*/
43+
* The Tiled firstgid value.
44+
* This is the starting index of the first image index this Image Collection contains.
45+
*
46+
* @name Phaser.Tilemaps.ImageCollection#firstgid
47+
* @type {integer}
48+
* @since 3.0.0
49+
*/
4150
this.firstgid = firstgid | 0;
4251

4352
/**
44-
* The width of the widest image (in pixels).
45-
* @property {integer} imageWidth
46-
* @readonly
47-
*/
53+
* The width of the widest image (in pixels).
54+
*
55+
* @name Phaser.Tilemaps.ImageCollection#imageWidth
56+
* @type {integer}
57+
* @readOnly
58+
* @since 3.0.0
59+
*/
4860
this.imageWidth = width | 0;
4961

5062
/**
51-
* The height of the tallest image (in pixels).
52-
* @property {integer} imageHeight
53-
* @readonly
54-
*/
63+
* The height of the tallest image (in pixels).
64+
*
65+
* @name Phaser.Tilemaps.ImageCollection#imageHeight
66+
* @type {integer}
67+
* @readOnly
68+
* @since 3.0.0
69+
*/
5570
this.imageHeight = height | 0;
5671

5772
/**
58-
* The margin around the images in the collection (in pixels).
59-
* Use `setSpacing` to change.
60-
* @property {integer} imageMarge
61-
* @readonly
62-
*/
63-
// Modified internally
73+
* The margin around the images in the collection (in pixels).
74+
* Use `setSpacing` to change.
75+
*
76+
* @name Phaser.Tilemaps.ImageCollection#imageMarge
77+
* @type {integer}
78+
* @readOnly
79+
* @since 3.0.0
80+
*/
6481
this.imageMargin = margin | 0;
6582

6683
/**
67-
* The spacing between each image in the collection (in pixels).
68-
* Use `setSpacing` to change.
69-
* @property {integer} imageSpacing
70-
* @readonly
71-
*/
84+
* The spacing between each image in the collection (in pixels).
85+
* Use `setSpacing` to change.
86+
*
87+
* @name Phaser.Tilemaps.ImageCollection#imageSpacing
88+
* @type {integer}
89+
* @readOnly
90+
* @since 3.0.0
91+
*/
7292
this.imageSpacing = spacing | 0;
7393

7494
/**
75-
* Image Collection-specific properties that are typically defined in the Tiled editor.
76-
* @property {object} properties
77-
*/
95+
* Image Collection-specific properties that are typically defined in the Tiled editor.
96+
*
97+
* @name Phaser.Tilemaps.ImageCollection#properties
98+
* @type {object}
99+
* @since 3.0.0
100+
*/
78101
this.properties = properties || {};
79102

80103
/**
81-
* The cached images that are a part of this collection.
82-
* @property {array} images
83-
* @readonly
84-
*/
85-
// Modified internally
104+
* The cached images that are a part of this collection.
105+
*
106+
* @name Phaser.Tilemaps.ImageCollection#images
107+
* @type {array}
108+
* @readOnly
109+
* @since 3.0.0
110+
*/
86111
this.images = [];
87112

88113
/**
89-
* The total number of images in the image collection.
90-
* @property {integer} total
91-
* @readonly
92-
*/
93-
// Modified internally
114+
* The total number of images in the image collection.
115+
*
116+
* @name Phaser.Tilemaps.ImageCollection#total
117+
* @type {integer}
118+
* @readOnly
119+
* @since 3.0.0
120+
*/
94121
this.total = 0;
95122
},
96123

97124
/**
98-
* Returns true if and only if this image collection contains the given image index.
99-
*
100-
* @method Phaser.ImageCollection#containsImageIndex
101-
* @param {integer} imageIndex - The image index to search for.
102-
* @return {boolean} True if this Image Collection contains the given index.
103-
*/
125+
* Returns true if and only if this image collection contains the given image index.
126+
*
127+
* @method Phaser.Tilemaps.ImageCollection#containsImageIndex
128+
* @since 3.0.0
129+
*
130+
* @param {integer} imageIndex - The image index to search for.
131+
*
132+
* @return {boolean} True if this Image Collection contains the given index.
133+
*/
104134
containsImageIndex: function (imageIndex)
105135
{
106-
return (
107-
imageIndex >= this.firstgid && imageIndex < (this.firstgid + this.total)
108-
);
109-
136+
return (imageIndex >= this.firstgid && imageIndex < (this.firstgid + this.total));
110137
},
111138

112139
/**
113-
* Add an image to this Image Collection.
114-
*
115-
* @method Phaser.ImageCollection#addImage
116-
* @param {integer} gid - The gid of the image in the Image Collection.
117-
* @param {string} image - The the key of the image in the Image Collection and in the cache.
118-
*/
140+
* Add an image to this Image Collection.
141+
*
142+
* @method Phaser.Tilemaps.ImageCollection#addImage
143+
* @since 3.0.0
144+
*
145+
* @param {integer} gid - The gid of the image in the Image Collection.
146+
* @param {string} image - The the key of the image in the Image Collection and in the cache.
147+
*
148+
* @return {Phaser.Tilemaps.ImageCollection} This ImageCollection object.
149+
*/
119150
addImage: function (gid, image)
120151
{
121152
this.images.push({ gid: gid, image: image });
122153
this.total++;
154+
155+
return this;
123156
}
157+
124158
});
125159

126160
module.exports = ImageCollection;

0 commit comments

Comments
 (0)