Skip to content

Commit 0ca9567

Browse files
committed
Update JSDoc on Cameras
1 parent 13324dd commit 0ca9567

3 files changed

Lines changed: 74 additions & 17 deletions

File tree

src/cameras/2d/Camera.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@ var TransformMatrix = require('../../gameobjects/components/TransformMatrix');
1111
var ValueToColor = require('../../display/color/ValueToColor');
1212
var Vector2 = require('../../math/Vector2');
1313

14+
/**
15+
* @typedef {object} JSONCamera
16+
*
17+
* @property {string} name - The name of the camera
18+
* @property {number} x - The horizontal position of camera
19+
* @property {number} y - The vertical position of camera
20+
* @property {number} width - The width size of camera
21+
* @property {number} height - The height size of camera
22+
* @property {number} zoom - The zoom of camera
23+
* @property {number} rotation - The rotation of camera
24+
* @property {boolean} roundPixels - The round pixels st status of camera
25+
* @property {number} scrollX - The horizontal scroll of camera
26+
* @property {number} scrollY - The vertical scroll of camera
27+
* @property {string} backgroundColor - The background color of camera
28+
* @property {object} [bounds] - The bounds of camera // TODO 19/03/2018 Create BoundsObject ({x:number,y:number,width:number,height:number})
29+
*/
30+
1431
/**
1532
* @classdesc
1633
* [description]
@@ -939,7 +956,7 @@ var Camera = new Class({
939956
* @method Phaser.Cameras.Scene2D.Camera#setBackgroundColor
940957
* @since 3.0.0
941958
*
942-
* @param {integer} color - [description]
959+
* @param {string|number|InputColorObject} color - [description]
943960
*
944961
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
945962
*/
@@ -1226,7 +1243,7 @@ var Camera = new Class({
12261243
* @method Phaser.Cameras.Scene2D.Camera#toJSON
12271244
* @since 3.0.0
12281245
*
1229-
* @return {object} [description]
1246+
* @return {JSONCamera} [description]
12301247
*/
12311248
toJSON: function ()
12321249
{
@@ -1323,7 +1340,7 @@ var Camera = new Class({
13231340
{
13241341
this._shakeOffsetX = (Math.random() * intensity * this.width * 2 - intensity * this.width) * this.zoom;
13251342
this._shakeOffsetY = (Math.random() * intensity * this.height * 2 - intensity * this.height) * this.zoom;
1326-
1343+
13271344
if (this.roundPixels)
13281345
{
13291346
this._shakeOffsetX |= 0;

src/cameras/controls/FixedKeyControl.js

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ var GetValue = require('../../utils/object/GetValue');
1414
// speed: float OR { x: 0, y: 0 }
1515
// })
1616

17+
/**
18+
* @typedef {object} FixedKeyControlConfig
19+
*
20+
* @property {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera that this Control will update.
21+
* @property {Phaser.Input.Keyboard.Key} [left] - The Key to be pressed that will move the Camera left.
22+
* @property {Phaser.Input.Keyboard.Key} [right] - The Key to be pressed that will move the Camera right.
23+
* @property {Phaser.Input.Keyboard.Key} [up] - The Key to be pressed that will move the Camera up.
24+
* @property {Phaser.Input.Keyboard.Key} [zoomIn] - The Key to be pressed that will zoom the Camera in.
25+
* @property {Phaser.Input.Keyboard.Key} [zoomOut] - The Key to be pressed that will zoom the Camera out.
26+
* @property {float} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed.
27+
* @property {float|{x:float,y:float}} [speed=0] - The horizontal and vertical speed the camera will move.
28+
*/
29+
1730
/**
1831
* @classdesc
1932
* [description]
@@ -23,7 +36,7 @@ var GetValue = require('../../utils/object/GetValue');
2336
* @constructor
2437
* @since 3.0.0
2538
*
26-
* @param {object} config - [description]
39+
* @param {FixedKeyControlConfig} config - [description]
2740
*/
2841
var FixedKeyControl = new Class({
2942

@@ -45,7 +58,7 @@ var FixedKeyControl = new Class({
4558
* The Key to be pressed that will move the Camera left.
4659
*
4760
* @name Phaser.Cameras.Controls.FixedKeyControl#left
48-
* @type {Phaser.Input.Keyboard}
61+
* @type {Phaser.Input.Keyboard.Key}
4962
* @default null
5063
* @since 3.0.0
5164
*/
@@ -55,7 +68,7 @@ var FixedKeyControl = new Class({
5568
* The Key to be pressed that will move the Camera right.
5669
*
5770
* @name Phaser.Cameras.Controls.FixedKeyControl#right
58-
* @type {Phaser.Input.Keyboard}
71+
* @type {Phaser.Input.Keyboard.Key}
5972
* @default null
6073
* @since 3.0.0
6174
*/
@@ -65,7 +78,7 @@ var FixedKeyControl = new Class({
6578
* The Key to be pressed that will move the Camera up.
6679
*
6780
* @name Phaser.Cameras.Controls.FixedKeyControl#up
68-
* @type {Phaser.Input.Keyboard}
81+
* @type {Phaser.Input.Keyboard.Key}
6982
* @default null
7083
* @since 3.0.0
7184
*/
@@ -75,7 +88,7 @@ var FixedKeyControl = new Class({
7588
* The Key to be pressed that will move the Camera down.
7689
*
7790
* @name Phaser.Cameras.Controls.FixedKeyControl#down
78-
* @type {Phaser.Input.Keyboard}
91+
* @type {Phaser.Input.Keyboard.Key}
7992
* @default null
8093
* @since 3.0.0
8194
*/
@@ -85,7 +98,7 @@ var FixedKeyControl = new Class({
8598
* The Key to be pressed that will zoom the Camera in.
8699
*
87100
* @name Phaser.Cameras.Controls.FixedKeyControl#zoomIn
88-
* @type {Phaser.Input.Keyboard}
101+
* @type {Phaser.Input.Keyboard.Key}
89102
* @default null
90103
* @since 3.0.0
91104
*/
@@ -95,7 +108,7 @@ var FixedKeyControl = new Class({
95108
* The Key to be pressed that will zoom the Camera out.
96109
*
97110
* @name Phaser.Cameras.Controls.FixedKeyControl#zoomOut
98-
* @type {Phaser.Input.Keyboard}
111+
* @type {Phaser.Input.Keyboard.Key}
99112
* @default null
100113
* @since 3.0.0
101114
*/
@@ -119,6 +132,7 @@ var FixedKeyControl = new Class({
119132
* @default 0
120133
* @since 3.0.0
121134
*/
135+
this.speedX = 0;
122136

123137
/**
124138
* The vertical speed the camera will move.
@@ -128,6 +142,8 @@ var FixedKeyControl = new Class({
128142
* @default 0
129143
* @since 3.0.0
130144
*/
145+
this.speedY = 0
146+
131147
var speed = GetValue(config, 'speed', null);
132148

133149
if (typeof speed === 'number')

src/cameras/controls/SmoothedKeyControl.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ var GetValue = require('../../utils/object/GetValue');
2121
// maxSpeed: 1.0
2222
// };
2323

24+
/**
25+
* @typedef {object} SmoothedKeyControlConfig
26+
*
27+
* @property {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera that this Control will update.
28+
* @property {Phaser.Input.Keyboard.Key} [left] - The Key to be pressed that will move the Camera left.
29+
* @property {Phaser.Input.Keyboard.Key} [right] - The Key to be pressed that will move the Camera right.
30+
* @property {Phaser.Input.Keyboard.Key} [up] - The Key to be pressed that will move the Camera up.
31+
* @property {Phaser.Input.Keyboard.Key} [zoomIn] - The Key to be pressed that will zoom the Camera in.
32+
* @property {Phaser.Input.Keyboard.Key} [zoomOut] - The Key to be pressed that will zoom the Camera out.
33+
* @property {float} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed.
34+
* @property {float|{x:float,y:float}} [acceleration=0] - The horizontal and vertical acceleration the camera will move.
35+
* @property {float|{x:float,y:float}} [drag=0] - The horizontal and vertical drag applied to the camera when it is moving.
36+
* @property {float|{x:float,y:float}} [maxSpeed=0] - The maximum horizontal and vertical speed the camera will move.
37+
*/
38+
2439
/**
2540
* @classdesc
2641
* [description]
@@ -30,7 +45,7 @@ var GetValue = require('../../utils/object/GetValue');
3045
* @constructor
3146
* @since 3.0.0
3247
*
33-
* @param {object} config - [description]
48+
* @param {SmoothedKeyControlConfig} config - [description]
3449
*/
3550
var SmoothedKeyControl = new Class({
3651

@@ -52,7 +67,7 @@ var SmoothedKeyControl = new Class({
5267
* The Key to be pressed that will move the Camera left.
5368
*
5469
* @name Phaser.Cameras.Controls.SmoothedKeyControl#left
55-
* @type {Phaser.Input.Keyboard}
70+
* @type {Phaser.Input.Keyboard.Key}
5671
* @default null
5772
* @since 3.0.0
5873
*/
@@ -62,7 +77,7 @@ var SmoothedKeyControl = new Class({
6277
* The Key to be pressed that will move the Camera right.
6378
*
6479
* @name Phaser.Cameras.Controls.SmoothedKeyControl#right
65-
* @type {Phaser.Input.Keyboard}
80+
* @type {Phaser.Input.Keyboard.Key}
6681
* @default null
6782
* @since 3.0.0
6883
*/
@@ -72,7 +87,7 @@ var SmoothedKeyControl = new Class({
7287
* The Key to be pressed that will move the Camera up.
7388
*
7489
* @name Phaser.Cameras.Controls.SmoothedKeyControl#up
75-
* @type {Phaser.Input.Keyboard}
90+
* @type {Phaser.Input.Keyboard.Key}
7691
* @default null
7792
* @since 3.0.0
7893
*/
@@ -82,7 +97,7 @@ var SmoothedKeyControl = new Class({
8297
* The Key to be pressed that will move the Camera down.
8398
*
8499
* @name Phaser.Cameras.Controls.SmoothedKeyControl#down
85-
* @type {Phaser.Input.Keyboard}
100+
* @type {Phaser.Input.Keyboard.Key}
86101
* @default null
87102
* @since 3.0.0
88103
*/
@@ -92,7 +107,7 @@ var SmoothedKeyControl = new Class({
92107
* The Key to be pressed that will zoom the Camera in.
93108
*
94109
* @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomIn
95-
* @type {Phaser.Input.Keyboard}
110+
* @type {Phaser.Input.Keyboard.Key}
96111
* @default null
97112
* @since 3.0.0
98113
*/
@@ -102,7 +117,7 @@ var SmoothedKeyControl = new Class({
102117
* The Key to be pressed that will zoom the Camera out.
103118
*
104119
* @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomOut
105-
* @type {Phaser.Input.Keyboard}
120+
* @type {Phaser.Input.Keyboard.Key}
106121
* @default null
107122
* @since 3.0.0
108123
*/
@@ -126,6 +141,7 @@ var SmoothedKeyControl = new Class({
126141
* @default 0
127142
* @since 3.0.0
128143
*/
144+
this.accelX = 0;
129145

130146
/**
131147
* The vertical acceleration the camera will move.
@@ -135,6 +151,8 @@ var SmoothedKeyControl = new Class({
135151
* @default 0
136152
* @since 3.0.0
137153
*/
154+
this.accelY = 0;
155+
138156
var accel = GetValue(config, 'acceleration', null);
139157

140158
if (typeof accel === 'number')
@@ -156,6 +174,7 @@ var SmoothedKeyControl = new Class({
156174
* @default 0
157175
* @since 3.0.0
158176
*/
177+
this.dragX = 0;
159178

160179
/**
161180
* The vertical drag applied to the camera when it is moving.
@@ -165,6 +184,8 @@ var SmoothedKeyControl = new Class({
165184
* @default 0
166185
* @since 3.0.0
167186
*/
187+
this.dragY = 0;
188+
168189
var drag = GetValue(config, 'drag', null);
169190

170191
if (typeof drag === 'number')
@@ -186,6 +207,7 @@ var SmoothedKeyControl = new Class({
186207
* @default 0
187208
* @since 3.0.0
188209
*/
210+
this.maxSpeedX = 0;
189211

190212
/**
191213
* The maximum vertical speed the camera will move.
@@ -195,6 +217,8 @@ var SmoothedKeyControl = new Class({
195217
* @default 0
196218
* @since 3.0.0
197219
*/
220+
this.maxSpeedY = 0;
221+
198222
var maxSpeed = GetValue(config, 'maxSpeed', null);
199223

200224
if (typeof maxSpeed === 'number')

0 commit comments

Comments
 (0)