Skip to content

Commit 6d8b702

Browse files
authored
Merge pull request phaserjs#3423 from orblazer/fix-types
Fix types
2 parents ff7119d + bf630f7 commit 6d8b702

6 files changed

Lines changed: 73 additions & 35 deletions

File tree

src/curves/path/Path.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ var Path = new Class({
733733
* @method Phaser.Curves.Path#toJSON
734734
* @since 3.0.0
735735
*
736-
* @return {object} [description]
736+
* @return {JSONPath} [description]
737737
*/
738738
toJSON: function ()
739739
{

src/data/DataManager.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,18 @@ var DataManager = new Class({
104104
* @method Phaser.Data.DataManager#getAll
105105
* @since 3.0.0
106106
*
107-
* @return {object} [description]
107+
* @return {Object.<string, any>} [description]
108108
*/
109109
getAll: function ()
110110
{
111111
var results = {};
112112

113113
for (var key in this.list)
114114
{
115-
results[key] = this.list[key];
115+
if(this.list.hasOwnProperty(key))
116+
{
117+
results[key] = this.list[key];
118+
}
116119
}
117120

118121
return results;

src/gameobjects/GameObject.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ var GameObject = new Class({
157157
* @since 3.0.0
158158
*
159159
* @param {boolean} value - True if this Game Object should be set as active, false if not.
160-
*
160+
*
161161
* @return {Phaser.GameObjects.GameObject} This GameObject.
162162
*/
163163
setActive: function (value)
@@ -175,7 +175,7 @@ var GameObject = new Class({
175175
* @since 3.0.0
176176
*
177177
* @param {string} value - The name to be given to this Game Object.
178-
*
178+
*
179179
* @return {Phaser.GameObjects.GameObject} This GameObject.
180180
*/
181181
setName: function (value)
@@ -212,7 +212,7 @@ var GameObject = new Class({
212212
*
213213
* @param {string} key - The key of the property to be stored.
214214
* @param {any} value - The value to store with the key. Can be a string, number, array or object.
215-
*
215+
*
216216
* @return {Phaser.GameObjects.GameObject} This GameObject.
217217
*/
218218
setData: function (key, value)
@@ -234,7 +234,7 @@ var GameObject = new Class({
234234
* @since 3.0.0
235235
*
236236
* @param {string} key - The key of the property to be retrieved.
237-
*
237+
*
238238
* @return {any} The data, if present in the Data Store.
239239
*/
240240
getData: function (key)
@@ -256,7 +256,7 @@ var GameObject = new Class({
256256
* @param {any} [shape] - A geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used.
257257
* @param {function} [callback] - A callback to be invoked when the Game Object is interacted with.
258258
* @param {boolean} [dropZone=false] - Should this Game Object be treated as a drop zone target?
259-
*
259+
*
260260
* @return {Phaser.GameObjects.GameObject} This GameObject.
261261
*/
262262
setInteractive: function (shape, callback, dropZone)
@@ -282,7 +282,7 @@ var GameObject = new Class({
282282
* @method Phaser.GameObjects.GameObject#toJSON
283283
* @since 3.0.0
284284
*
285-
* @return {object} A JSON representation of the Game Object.
285+
* @return {JSONGameObject} A JSON representation of the Game Object.
286286
*/
287287
toJSON: function ()
288288
{
@@ -305,13 +305,13 @@ var GameObject = new Class({
305305
/**
306306
* Destroys this Game Object removing it from the Display List and Update List and
307307
* severing all ties to parent resources.
308-
*
308+
*
309309
* Also removes itself from the Input Manager and Physics Manager if previously enabled.
310-
*
310+
*
311311
* Use this to remove a Game Object from your game if you don't ever plan to use it again.
312312
* As long as no reference to it exists within your own code it should become free for
313313
* garbage collection by the browser.
314-
*
314+
*
315315
* If you just want to temporarily disable an object then look at using the
316316
* Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected.
317317
*
@@ -364,7 +364,7 @@ var GameObject = new Class({
364364
this.scene = undefined;
365365

366366
this.emit('destroy');
367-
367+
368368
this.removeAllListeners();
369369
}
370370

src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ var DynamicBitmapText = new Class({
309309
*
310310
* @param {boolean} round - [description]
311311
*
312-
* @return {object} [description]
312+
* @return {TextBounds} [description]
313313
*/
314314
getTextBounds: function (round)
315315
{
@@ -323,7 +323,7 @@ var DynamicBitmapText = new Class({
323323

324324
/**
325325
* [description]
326-
*
326+
*
327327
* @name Phaser.GameObjects.DynamicBitmapText#width
328328
* @type {number}
329329
* @since 3.0.0
@@ -340,7 +340,7 @@ var DynamicBitmapText = new Class({
340340

341341
/**
342342
* [description]
343-
*
343+
*
344344
* @name Phaser.GameObjects.DynamicBitmapText#height
345345
* @type {number}
346346
* @since 3.0.0

src/gameobjects/bitmaptext/static/BitmapText.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@ var ParseFromAtlas = require('../ParseFromAtlas');
1212
var ParseRetroFont = require('../ParseRetroFont');
1313
var Render = require('./BitmapTextRender');
1414

15+
/**
16+
* @typedef {object} TextBounds
17+
*
18+
* @param {object} local - [description]
19+
* @param {number} local.x - [description]
20+
* @param {number} local.y - [description]
21+
* @param {number} local.width - [description]
22+
* @param {number} local.height - [description]
23+
* @param {object} global - [description]
24+
* @param {number} global.x - [description]
25+
* @param {number} global.y - [description]
26+
* @param {number} global.width - [description]
27+
* @param {number} global.height - [description]
28+
*/
29+
1530
/**
1631
* @classdesc
1732
* [description]
@@ -171,21 +186,6 @@ var BitmapText = new Class({
171186
return this;
172187
},
173188

174-
// {
175-
// local: {
176-
// x,
177-
// y,
178-
// width,
179-
// height
180-
// },
181-
// global: {
182-
// x,
183-
// y,
184-
// width,
185-
// height
186-
// }
187-
// }
188-
189189
/**
190190
* [description]
191191
*
@@ -194,7 +194,7 @@ var BitmapText = new Class({
194194
*
195195
* @param {boolean} round - [description]
196196
*
197-
* @return {object} [description]
197+
* @return {TextBounds} [description]
198198
*/
199199
getTextBounds: function (round)
200200
{
@@ -208,7 +208,7 @@ var BitmapText = new Class({
208208

209209
/**
210210
* [description]
211-
*
211+
*
212212
* @name Phaser.GameObjects.BitmapText#width
213213
* @type {number}
214214
* @since 3.0.0
@@ -226,7 +226,7 @@ var BitmapText = new Class({
226226

227227
/**
228228
* [description]
229-
*
229+
*
230230
* @name Phaser.GameObjects.BitmapText#height
231231
* @type {number}
232232
* @since 3.0.0
@@ -248,7 +248,7 @@ var BitmapText = new Class({
248248
* @method Phaser.GameObjects.BitmapText#toJSON
249249
* @since 3.0.0
250250
*
251-
* @return {object} [description]
251+
* @return {JSONGameObject} [description]
252252
*/
253253
toJSON: function ()
254254
{

src/gameobjects/components/ToJSON.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,44 @@
44
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
55
*/
66

7+
/**
8+
* @typedef {object} JSONGameObject
9+
*
10+
* @property {string} name - The name of this Game Object.
11+
* @property {string} type - A textual representation of this Game Object, i.e. `sprite`.
12+
* @property {number} x - The x position of this Game Object.
13+
* @property {number} y - The y position of this Game Object.
14+
* @property {object} scale - The scale of this Game Object
15+
* @property {number} scale.x - The horizontal scale of this Game Object.
16+
* @property {number} scale.y - The vertical scale of this Game Object.
17+
* @property {object} origin - The origin of this Game Object.
18+
* @property {float} origin.x - The horizontal origin of this Game Object.
19+
* @property {float} origin.y - The vertical origin of this Game Object.
20+
* @property {boolean} flipX - The horizontally flipped state of the Game Object.
21+
* @property {boolean} flipY - The vertically flipped state of the Game Object.
22+
* @property {number} rotation - The angle of this Game Object in radians.
23+
* @property {float} alpha - The alpha value of the Game Object.
24+
* @property {boolean} visible - The visible state of the Game Object.
25+
* @property {integer} scaleMode - The Scale Mode being used by this Game Object.
26+
* @property {integer|string} blendMode - Sets the Blend Mode being used by this Game Object.
27+
* @property {string} textureKey - The texture key of this Game Object.
28+
* @property {string} frameKey - The frame key of this Game Object.
29+
* @property {object} data - The data of this Game Object.
30+
*/
31+
732
// Default Game Object JSON export
833
// Is extended further by Game Object specific implementations
934

35+
/**
36+
* [description]
37+
*
38+
* @method Phaser.GameObjects.Components.ToJSON
39+
* @since 3.0.0
40+
*
41+
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
42+
*
43+
* @return {JSONGameObject} [description]
44+
*/
1045
var ToJSON = function (gameObject)
1146
{
1247
var out = {

0 commit comments

Comments
 (0)