mirror of
https://github.com/photonstorm/phaser
synced 2024-12-03 18:10:10 +00:00
Updated ShiftPosition to return the final erased position.
This commit is contained in:
parent
5a871fcabe
commit
b4a7b9246d
3 changed files with 18 additions and 7 deletions
|
@ -1,18 +1,21 @@
|
||||||
// Iterate through items changing the position of each element to
|
// Iterate through items changing the position of each element to
|
||||||
// be that of the element that came before it in the array (or after it if direction = 1)
|
// be that of the element that came before it in the array (or after it if direction = 1)
|
||||||
// The first items position is set to x/y.
|
// The first items position is set to x/y.
|
||||||
|
// The final x/y coords are returned
|
||||||
|
|
||||||
var ShiftPosition = function (items, x, y, direction)
|
var ShiftPosition = function (items, x, y, direction, output)
|
||||||
{
|
{
|
||||||
if (direction === undefined) { direction = 0; }
|
if (direction === undefined) { direction = 0; }
|
||||||
|
if (output === undefined) { output = { x: 0, y: 0 }; }
|
||||||
|
|
||||||
|
var px;
|
||||||
|
var py;
|
||||||
|
|
||||||
if (items.length > 1)
|
if (items.length > 1)
|
||||||
{
|
{
|
||||||
var i;
|
var i;
|
||||||
var cx;
|
var cx;
|
||||||
var cy;
|
var cy;
|
||||||
var px;
|
|
||||||
var py;
|
|
||||||
var cur;
|
var cur;
|
||||||
|
|
||||||
if (direction === 0)
|
if (direction === 0)
|
||||||
|
@ -78,11 +81,19 @@ var ShiftPosition = function (items, x, y, direction)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
px = items[0].x;
|
||||||
|
py = items[0].y;
|
||||||
|
|
||||||
items[0].x = x;
|
items[0].x = x;
|
||||||
items[0].y = y;
|
items[0].y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
return items;
|
// Return the final set of coordinates as they're effectively lost from the shift and may be needed
|
||||||
|
|
||||||
|
output.x = px;
|
||||||
|
output.y = py;
|
||||||
|
|
||||||
|
return output;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = ShiftPosition;
|
module.exports = ShiftPosition;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
var CHECKSUM = {
|
var CHECKSUM = {
|
||||||
build: '54effe90-54f3-11e7-845d-d91b54e9fe70'
|
build: '39f826c0-54fe-11e7-90c1-d1d02aa41ae8'
|
||||||
};
|
};
|
||||||
module.exports = CHECKSUM;
|
module.exports = CHECKSUM;
|
|
@ -416,9 +416,9 @@ var Layer = new Class({
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
shiftPosition: function (x, y, direction)
|
shiftPosition: function (x, y, direction, output)
|
||||||
{
|
{
|
||||||
Actions.ShiftPosition(this.children.entries, x, y, direction);
|
Actions.ShiftPosition(this.children.entries, x, y, direction, output);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue