55*/
66
77/**
8- * A responsive grid manager.
8+ * WARNING: This is an EXPERIMENTAL class. The API will change significantly in the coming versions and is incomplete.
9+ * Please try to avoid using in production games with a long time to build.
10+ * This is also why the documentation is incomplete.
11+ *
12+ * FlexGrid is a a responsive grid manager that works in conjunction with the ScaleManager RESIZE scaling mode and FlexLayers
13+ * to provide for game object positioning in a responsive manner.
914*
1015* @class Phaser.FlexGrid
1116* @constructor
1217* @param {Phaser.ScaleManager } manager - The ScaleManager.
18+ * @param {number } width - The width of the game.
19+ * @param {number } height - The height of the game.
1320*/
1421Phaser . FlexGrid = function ( manager , width , height ) {
1522
@@ -59,6 +66,13 @@ Phaser.FlexGrid = function (manager, width, height) {
5966
6067Phaser . FlexGrid . prototype = {
6168
69+ /**
70+ * Sets the core game size. This resets the w/h parameters and bounds.
71+ *
72+ * @method setSize
73+ * @param {number } width - The new dimensions.
74+ * @param {number } height - The new dimensions.
75+ */
6276 setSize : function ( width , height ) {
6377
6478 // These are locked and don't change until setSize is called again
@@ -83,6 +97,7 @@ Phaser.FlexGrid.prototype = {
8397 * A fluid layer is centered on the game and maintains its aspect ratio as it scales up and down.
8498 *
8599 * @method createFluidLayer
100+ * @param {array } [children] - An array of children that are used to populate the FlexLayer.
86101 * @return {Phaser.FlexLayer } The Layer object.
87102 */
88103 createFluidLayer : function ( children ) {
@@ -106,6 +121,7 @@ Phaser.FlexGrid.prototype = {
106121 * A full layer is placed at 0,0 and extends to the full size of the game. Children are scaled according to the fluid ratios.
107122 *
108123 * @method createFullLayer
124+ * @param {array } [children] - An array of children that are used to populate the FlexLayer.
109125 * @return {Phaser.FlexLayer } The Layer object.
110126 */
111127 createFullLayer : function ( children ) {
@@ -129,6 +145,7 @@ Phaser.FlexGrid.prototype = {
129145 * A fixed layer is centered on the game and is the size of the required dimensions and is never scaled.
130146 *
131147 * @method createFixedLayer
148+ * @param {array } [children] - An array of children that are used to populate the FlexLayer.
132149 * @return {Phaser.FlexLayer } The Layer object.
133150 */
134151 createFixedLayer : function ( children ) {
@@ -148,6 +165,11 @@ Phaser.FlexGrid.prototype = {
148165
149166 } ,
150167
168+ /**
169+ * Resets the layer children references
170+ *
171+ * @method reset
172+ */
151173 reset : function ( ) {
152174
153175 for ( var i = 0 ; i < this . layers . length ; i ++ )
@@ -161,12 +183,24 @@ Phaser.FlexGrid.prototype = {
161183
162184 } ,
163185
186+ /**
187+ * Called when the game container changes dimensions.
188+ *
189+ * @method onResize
190+ * @param {number } width - The new width of the game container.
191+ * @param {number } height - The new height of the game container.
192+ */
164193 onResize : function ( width , height ) {
165194
166195 this . refresh ( width , height ) ;
167196
168197 } ,
169198
199+ /**
200+ * Updates all internal vars such as the bounds and scale values.
201+ *
202+ * @method refresh
203+ */
170204 refresh : function ( ) {
171205
172206 this . multiplier = Math . min ( ( this . manager . height / this . height ) , ( this . manager . width / this . width ) ) ;
@@ -190,22 +224,26 @@ Phaser.FlexGrid.prototype = {
190224
191225 } ,
192226
227+ /**
228+ * Call in the render function to output the bounds rects.
229+ *
230+ * @method debug
231+ */
193232 debug : function ( ) {
194233
195234 // for (var i = 0; i < this.layers.length; i++)
196235 // {
197236 // this.layers[i].debug();
198237 // }
199238
200- // this.game.debug.text(this.boundsFull.width + ' x ' + this.boundsFull.height, this.boundsFull.x + 4, this.boundsFull.y + 16);
201- // this.game.debug.geom(this.boundsFull, 'rgba(0,0,255,0.9', false);
239+ this . game . debug . text ( this . boundsFull . width + ' x ' + this . boundsFull . height , this . boundsFull . x + 4 , this . boundsFull . y + 16 ) ;
240+ this . game . debug . geom ( this . boundsFull , 'rgba(0,0,255,0.9' , false ) ;
202241
203242 this . game . debug . text ( this . boundsFluid . width + ' x ' + this . boundsFluid . height , this . boundsFluid . x + 4 , this . boundsFluid . y + 16 ) ;
204243 this . game . debug . geom ( this . boundsFluid , 'rgba(255,0,0,0.9' , false ) ;
205244
206- // this.game.debug.text(this.boundsNone.width + ' x ' + this.boundsNone.height, this.boundsNone.x + 4, this.boundsNone.y + 16);
207- // this.game.debug.geom(this.boundsNone, 'rgba(0,255,0,0.9', false);
208- // this.game.debug.text(this.scaleFluid.x + ' x ' + this.scaleFluid.y, this.boundsFluid.x + 4, this.boundsFluid.y + 16);
245+ this . game . debug . text ( this . boundsNone . width + ' x ' + this . boundsNone . height , this . boundsNone . x + 4 , this . boundsNone . y + 16 ) ;
246+ this . game . debug . geom ( this . boundsNone , 'rgba(0,255,0,0.9' , false ) ;
209247
210248 }
211249
0 commit comments