From 2f605250b3758d383c50740e351269beffbaee56 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 28 Jun 2017 14:16:01 +0100 Subject: [PATCH] Added SetZ Action and exposed via Group --- v3/src/actions/SetZ.js | 13 +++++++++++++ v3/src/actions/index.js | 1 + v3/src/gameobjects/group/Group.js | 7 +++++++ 3 files changed, 21 insertions(+) create mode 100644 v3/src/actions/SetZ.js diff --git a/v3/src/actions/SetZ.js b/v3/src/actions/SetZ.js new file mode 100644 index 000000000..18abf2e48 --- /dev/null +++ b/v3/src/actions/SetZ.js @@ -0,0 +1,13 @@ +var SetZ = function (items, value, step) +{ + if (step === undefined) { step = 0; } + + for (var i = 0; i < items.length; i++) + { + items[i].z = value + (i * step); + } + + return items; +}; + +module.exports = SetZ; diff --git a/v3/src/actions/index.js b/v3/src/actions/index.js index f77ccd3e1..8fee517a0 100644 --- a/v3/src/actions/index.js +++ b/v3/src/actions/index.js @@ -36,6 +36,7 @@ module.exports = { SetX: require('./SetX'), SetXY: require('./SetXY'), SetY: require('./SetY'), + SetZ: require('./SetZ'), ShiftPosition: require('./ShiftPosition'), SmootherStep: require('./SmootherStep'), SmoothStep: require('./SmoothStep'), diff --git a/v3/src/gameobjects/group/Group.js b/v3/src/gameobjects/group/Group.js index 91cfa5494..531855728 100644 --- a/v3/src/gameobjects/group/Group.js +++ b/v3/src/gameobjects/group/Group.js @@ -430,6 +430,13 @@ var Group = new Class({ return this; }, + setZ: function (value, step) + { + Actions.SetZ(this.children.entries, value, step); + + return this; + }, + shiftPosition: function (x, y, direction, output) { Actions.ShiftPosition(this.children.entries, x, y, direction, output);