Skip to content

Commit 8d85a9b

Browse files
committed
Added jsdocs
1 parent 7c16368 commit 8d85a9b

1 file changed

Lines changed: 136 additions & 0 deletions

File tree

src/gameobjects/components/MatrixStack.js

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,74 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2018 Photon Storm Ltd.
4+
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
5+
*/
6+
7+
/**
8+
* Provides methods used for getting and setting the transform values of a Game Object.
9+
* Should be applied as a mixin and not used directly.
10+
*
11+
* @name Phaser.GameObjects.Components.MatrixStack
12+
* @since 3.2.0
13+
*/
14+
115
var MatrixStack = {
216

17+
/**
18+
* [description]
19+
*
20+
* @name Phaser.GameObjects.Components.MatrixStack#matrixStack
21+
* @type {Float32Array}
22+
* @private
23+
* @since 3.2.0
24+
*/
325
matrixStack: null,
26+
27+
/**
28+
* [description]
29+
*
30+
* @name Phaser.GameObjects.Components.MatrixStack#currentMatrix
31+
* @type {Float32Array}
32+
* @private
33+
* @since 3.2.0
34+
*/
435
currentMatrix: null,
36+
37+
/**
38+
* [description]
39+
*
40+
* @name Phaser.GameObjects.Components.MatrixStack#currentMatrixIndex
41+
* @type {integer}
42+
* @private
43+
* @since 3.2.0
44+
*/
545
currentMatrixIndex: 0,
646

47+
/**
48+
* [description]
49+
*
50+
* @method Phaser.GameObjects.Components.MatrixStack#initMatrixStack
51+
* @since 3.2.0
52+
*
53+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
54+
*/
755
initMatrixStack: function ()
856
{
957
this.matrixStack = new Float32Array(6000); // up to 1000 matrices
1058
this.currentMatrix = new Float32Array([ 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 ]);
1159
this.currentMatrixIndex = 0;
60+
1261
return this;
1362
},
1463

64+
/**
65+
* [description]
66+
*
67+
* @method Phaser.GameObjects.Components.MatrixStack#save
68+
* @since 3.2.0
69+
*
70+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
71+
*/
1572
save: function ()
1673
{
1774
if (this.currentMatrixIndex >= this.matrixStack.length) { return this; }
@@ -31,6 +88,14 @@ var MatrixStack = {
3188
return this;
3289
},
3390

91+
/**
92+
* [description]
93+
*
94+
* @method Phaser.GameObjects.Components.MatrixStack#restore
95+
* @since 3.2.0
96+
*
97+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
98+
*/
3499
restore: function ()
35100
{
36101
if (this.currentMatrixIndex <= 0) { return this; }
@@ -51,12 +116,36 @@ var MatrixStack = {
51116
return this;
52117
},
53118

119+
/**
120+
* [description]
121+
*
122+
* @method Phaser.GameObjects.Components.MatrixStack#loadIdentity
123+
* @since 3.2.0
124+
*
125+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
126+
*/
54127
loadIdentity: function ()
55128
{
56129
this.setTransform(1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
130+
57131
return this;
58132
},
59133

134+
/**
135+
* [description]
136+
*
137+
* @method Phaser.GameObjects.Components.MatrixStack#transform
138+
* @since 3.2.0
139+
*
140+
* @param {number} a - [description]
141+
* @param {number} b - [description]
142+
* @param {number} c - [description]
143+
* @param {number} d - [description]
144+
* @param {number} tx - [description]
145+
* @param {number} ty - [description]
146+
*
147+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
148+
*/
60149
transform: function (a, b, c, d, tx, ty)
61150
{
62151
var currentMatrix = this.currentMatrix;
@@ -77,6 +166,21 @@ var MatrixStack = {
77166
return this;
78167
},
79168

169+
/**
170+
* [description]
171+
*
172+
* @method Phaser.GameObjects.Components.MatrixStack#setTransform
173+
* @since 3.2.0
174+
*
175+
* @param {number} a - [description]
176+
* @param {number} b - [description]
177+
* @param {number} c - [description]
178+
* @param {number} d - [description]
179+
* @param {number} tx - [description]
180+
* @param {number} ty - [description]
181+
*
182+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
183+
*/
80184
setTransform: function (a, b, c, d, tx, ty)
81185
{
82186
var currentMatrix = this.currentMatrix;
@@ -91,6 +195,17 @@ var MatrixStack = {
91195
return this;
92196
},
93197

198+
/**
199+
* [description]
200+
*
201+
* @method Phaser.GameObjects.Components.MatrixStack#translate
202+
* @since 3.2.0
203+
*
204+
* @param {number} x - [description]
205+
* @param {number} y - [description]
206+
*
207+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
208+
*/
94209
translate: function (x, y)
95210
{
96211
var currentMatrix = this.currentMatrix;
@@ -107,6 +222,17 @@ var MatrixStack = {
107222
return this;
108223
},
109224

225+
/**
226+
* [description]
227+
*
228+
* @method Phaser.GameObjects.Components.MatrixStack#scale
229+
* @since 3.2.0
230+
*
231+
* @param {number} x - [description]
232+
* @param {number} y - [description]
233+
*
234+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
235+
*/
110236
scale: function (x, y)
111237
{
112238
var currentMatrix = this.currentMatrix;
@@ -123,6 +249,16 @@ var MatrixStack = {
123249
return this;
124250
},
125251

252+
/**
253+
* [description]
254+
*
255+
* @method Phaser.GameObjects.Components.MatrixStack#rotate
256+
* @since 3.2.0
257+
*
258+
* @param {number} t - The angle of rotation, in radians.
259+
*
260+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
261+
*/
126262
rotate: function (t)
127263
{
128264
var currentMatrix = this.currentMatrix;

0 commit comments

Comments
 (0)