Merge pull request #2643 from deargle/group-align-documentation-fix

fix documentation for group.align -- row and column were swapped
This commit is contained in:
Richard Davey 2016-07-20 12:08:22 +01:00 committed by GitHub
commit dc6d3e2680

View file

@ -705,7 +705,7 @@ Phaser.Group.prototype.updateZ = function () {
*
* `Group.align(-1, 8, 32, 32)`
*
* ... will align the children so that there are 8 columns vertically (the second argument),
* ... will align the children so that there are 8 rows vertically (the second argument),
* and each row will contain 6 sprites, except the last one, which will contain 5 (totaling 48)
*
* You can also do:
@ -723,26 +723,26 @@ Phaser.Group.prototype.updateZ = function () {
* The final argument; `offset` lets you start the alignment from a specific child index.
*
* @method Phaser.Group#align
* @param {integer} rows - The number of rows, or width, of the grid. Set to -1 for a dynamic width.
* @param {integer} columns - The number of columns, or height, of the grid. Set to -1 for a dynamic height.
* @param {integer} columns - The number of columns, or width, of the grid. Set to -1 for a dynamic width.
* @param {integer} rows - The number of rows, or height, of the grid. Set to -1 for a dynamic height.
* @param {integer} cellWidth - The width of each grid cell, in pixels.
* @param {integer} cellHeight - The height of each grid cell, in pixels.
* @param {integer} [position] - The position constant. One of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`.
* @param {integer} [offset=0] - Optional index to start the alignment from. Defaults to zero, the first child in the Group, but can be set to any valid child index value.
*/
Phaser.Group.prototype.align = function (rows, columns, cellWidth, cellHeight, position, offset) {
Phaser.Group.prototype.align = function (columns, rows, cellWidth, cellHeight, position, offset) {
if (position === undefined) { position = Phaser.TOP_LEFT; }
if (offset === undefined) { offset = 0; }
if (this.children.length === 0 || offset > this.children.length || (rows === -1 && columns === -1))
if (this.children.length === 0 || offset > this.children.length || (columns === -1 && rows === -1))
{
return;
}
var r = new Phaser.Rectangle(0, 0, cellWidth, cellHeight);
var w = (rows * cellWidth);
var h = (columns * cellHeight);
var w = (columns * cellWidth);
var h = (rows * cellHeight);
for (var i = offset; i < this.children.length; i++)
{
@ -757,7 +757,7 @@ Phaser.Group.prototype.align = function (rows, columns, cellWidth, cellHeight, p
continue;
}
if (rows === -1)
if (columns === -1)
{
// We keep laying them out horizontally until we've done them all
r.y += cellHeight;
@ -768,7 +768,7 @@ Phaser.Group.prototype.align = function (rows, columns, cellWidth, cellHeight, p
r.y = 0;
}
}
else if (columns === -1)
else if (rows === -1)
{
// We keep laying them out vertically until we've done them all
r.x += cellWidth;