Skip to content

Commit b4a7b92

Browse files
committed
Updated ShiftPosition to return the final erased position.
1 parent 5a871fc commit b4a7b92

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

v3/src/actions/ShiftPosition.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
// Iterate through items changing the position of each element to
22
// be that of the element that came before it in the array (or after it if direction = 1)
33
// The first items position is set to x/y.
4+
// The final x/y coords are returned
45

5-
var ShiftPosition = function (items, x, y, direction)
6+
var ShiftPosition = function (items, x, y, direction, output)
67
{
78
if (direction === undefined) { direction = 0; }
9+
if (output === undefined) { output = { x: 0, y: 0 }; }
10+
11+
var px;
12+
var py;
813

914
if (items.length > 1)
1015
{
1116
var i;
1217
var cx;
1318
var cy;
14-
var px;
15-
var py;
1619
var cur;
1720

1821
if (direction === 0)
@@ -78,11 +81,19 @@ var ShiftPosition = function (items, x, y, direction)
7881
}
7982
else
8083
{
84+
px = items[0].x;
85+
py = items[0].y;
86+
8187
items[0].x = x;
8288
items[0].y = y;
8389
}
8490

85-
return items;
91+
// Return the final set of coordinates as they're effectively lost from the shift and may be needed
92+
93+
output.x = px;
94+
output.y = py;
95+
96+
return output;
8697
};
8798

8899
module.exports = ShiftPosition;

v3/src/checksum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var CHECKSUM = {
2-
build: '54effe90-54f3-11e7-845d-d91b54e9fe70'
2+
build: '39f826c0-54fe-11e7-90c1-d1d02aa41ae8'
33
};
44
module.exports = CHECKSUM;

v3/src/gameobjects/layer/Layer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,9 @@ var Layer = new Class({
416416
return this;
417417
},
418418

419-
shiftPosition: function (x, y, direction)
419+
shiftPosition: function (x, y, direction, output)
420420
{
421-
Actions.ShiftPosition(this.children.entries, x, y, direction);
421+
Actions.ShiftPosition(this.children.entries, x, y, direction, output);
422422

423423
return this;
424424
},

0 commit comments

Comments
 (0)