Class: Phaser.FlexGrid
Constructor
new FlexGrid(manager, width, height)
WARNING: This is an EXPERIMENTAL class. The API will change significantly in the coming versions and is incomplete.
Please try to avoid using in production games with a long time to build.
This is also why the documentation is incomplete.
FlexGrid is a a responsive grid manager that works in conjunction with the ScaleManager RESIZE scaling mode and FlexLayers
to provide for game object positioning in a responsive manner.
Parameters
Name | Type | Description |
---|---|---|
manager | Phaser.ScaleManager | The ScaleManager. |
width | number | The width of the game. |
height | number | The height of the game. |
- Source code: core/FlexGrid.js (Line 21)
Public Properties
- Source code: core/FlexGrid.js (Line 26)
- Source code: core/FlexGrid.js (Line 31)
- Source code: core/FlexGrid.js (Line 46)
- Source code: core/FlexGrid.js (Line 55)
game : Phaser.Game
A reference to the currently running Game.
manager : Phaser.ScaleManager
A reference to the ScaleManager.
[readonly] positionCustom
Properties:
Name | Type | Description |
---|---|---|
position | Phaser.Point | - |
[readonly] scaleCustom
Properties:
Name | Type | Description |
---|---|---|
scaleFactor | Phaser.Point | The scale factor based on the game dimensions vs. the scaled dimensions. |
Public Methods
- Source code: core/FlexGrid.js (Line 104)
- Source code: core/FlexGrid.js (Line 194)
- Source code: core/FlexGrid.js (Line 141)
- Source code: core/FlexGrid.js (Line 170)
- Source code: core/FlexGrid.js (Line 299)
- Source code: core/FlexGrid.js (Line 284)
- Source code: core/FlexGrid.js (Line 240)
- Source code: core/FlexGrid.js (Line 256)
- Source code: core/FlexGrid.js (Line 218)
- Source code: core/FlexGrid.js (Line 77)
createCustomLayer(width, height, children) → {Phaser.FlexLayer}
A custom layer is centered on the game and maintains its aspect ratio as it scales up and down.
Parameters
Name | Type | Argument | Description |
---|---|---|---|
width | number | Width of this layer in pixels. | |
height | number | Height of this layer in pixels. | |
children | Array.<PIXI.DisplayObject> | <optional> | An array of children that are used to populate the FlexLayer. |
Returns
The Layer object.
createFixedLayer(children) → {Phaser.FlexLayer}
A fixed layer is centered on the game and is the size of the required dimensions and is never scaled.
Parameters
Name | Type | Argument | Description |
---|---|---|---|
children | Array.<PIXI.DisplayObject> | <optional> | An array of children that are used to populate the FlexLayer. |
Returns
The Layer object.
createFluidLayer(children) → {Phaser.FlexLayer}
A fluid layer is centered on the game and maintains its aspect ratio as it scales up and down.
Parameters
Name | Type | Argument | Description |
---|---|---|---|
children | array | <optional> | An array of children that are used to populate the FlexLayer. |
Returns
The Layer object.
createFullLayer(children) → {Phaser.FlexLayer}
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.
Parameters
Name | Type | Argument | Description |
---|---|---|---|
children | array | <optional> | An array of children that are used to populate the FlexLayer. |
Returns
The Layer object.
debug()
Call in the render function to output the bounds rects.
fitSprite(sprite)
Fits a sprites width to the bounds.
Parameters
Name | Type | Description |
---|---|---|
sprite | Phaser.Sprite | The Sprite to fit. |
onResize(width, height)
Called when the game container changes dimensions.
Parameters
Name | Type | Description |
---|---|---|
width | number | The new width of the game container. |
height | number | The new height of the game container. |
refresh()
Updates all internal vars such as the bounds and scale values.
reset()
Resets the layer children references
setSize(width, height)
Sets the core game size. This resets the w/h parameters and bounds.
Parameters
Name | Type | Description |
---|---|---|
width | number | The new dimensions. |
height | number | The new dimensions. |
© 2016 Richard Davey, Photon Storm Ltd.
Licensed under the MIT License.
http://phaser.io/docs/2.6.2/Phaser.FlexGrid.html