Skip to content

Commit 358b742

Browse files
committed
Added Alpha Actions.
1 parent 93d9e97 commit 358b742

6 files changed

Lines changed: 72 additions & 8 deletions

File tree

v3/src/actions/IncAlpha.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var IncAlpha = function (items, value)
2+
{
3+
for (var i = 0; i < items.length; i++)
4+
{
5+
items[i].alpha += value;
6+
}
7+
8+
return items;
9+
};
10+
11+
module.exports = IncAlpha;

v3/src/actions/SetAlpha.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var SetAlpha = function (items, value, step)
2+
{
3+
if (step === undefined) { step = 0; }
4+
5+
for (var i = 0; i < items.length; i++)
6+
{
7+
items[i].alpha = value + (i * step);
8+
}
9+
10+
return items;
11+
};
12+
13+
module.exports = SetAlpha;

v3/src/actions/SetXY.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
var SetXY = function (items, x, y)
1+
var SetXY = function (items, x, y, stepX, stepY)
22
{
3+
if (stepX === undefined) { stepX = 0; }
4+
if (stepY === undefined) { stepY = 0; }
5+
36
for (var i = 0; i < items.length; i++)
47
{
5-
items[i].x = x;
6-
items[i].y = y;
8+
items[i].x = x + (i * stepX);
9+
items[i].y = y + (i * stepY);
710
}
811

912
return items;

v3/src/actions/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ module.exports = {
44

55
Angle: require('./Angle'),
66
GridAlign: require('./GridAlign'),
7+
IncAlpha: require('./IncAlpha'),
78
IncX: require('./IncX'),
89
IncXY: require('./IncXY'),
910
IncY: require('./IncY'),
1011
PositionAroundCircle: require('./PositionAroundCircle'),
1112
Rotate: require('./Rotate'),
1213
RotateAround: require('./RotateAround'),
1314
RotateAroundDistance: require('./RotateAroundDistance'),
15+
SetAlpha: require('./SetAlpha'),
1416
SetRotation: require('./SetRotation'),
1517
SetVisible: require('./SetVisible'),
1618
SetX: require('./SetX'),

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: '37c7b2f0-13a7-11e7-8907-e12aa7288dfa'
2+
build: '00b50b50-13b6-11e7-a00b-efd0cd0ce446'
33
};
44
module.exports = CHECKSUM;

v3/src/gameobjects/layer/Layer.js

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
var Class = require('../../utils/Class');
33
var Set = require('../../structs/Set');
4+
var GetObjectValue = require('../../utils/object/GetObjectValue');
45
var Actions = require('../../actions/');
56
var Sprite = require('../sprite/Sprite');
67

@@ -97,10 +98,11 @@ var Layer = new Class({
9798
* @param {boolean} [exists=false] - The default exists state of the Sprite.
9899
* @return {array} An array containing all of the Sprites that were created.
99100
*/
100-
createMultiple: function (quantity, key, frame, visible)
101+
createMultiple: function (quantity, key, frame, options)
101102
{
102103
if (frame === undefined) { frame = null; }
103-
if (visible === undefined) { visible = true; }
104+
105+
var visible = GetObjectValue(options, 'visible', true);
104106

105107
if (!Array.isArray(key))
106108
{
@@ -126,6 +128,25 @@ var Layer = new Class({
126128
});
127129
});
128130

131+
// Post-creation options:
132+
133+
var x = GetObjectValue(options, 'x', 0);
134+
var y = GetObjectValue(options, 'y', 0);
135+
var stepX = GetObjectValue(options, 'stepX', 0);
136+
var stepY = GetObjectValue(options, 'stepY', 0);
137+
138+
this.setXY(x, y, stepX, stepY);
139+
140+
var rotation = GetObjectValue(options, 'rotation', 0);
141+
var stepRotation = GetObjectValue(options, 'stepRotation', 0);
142+
143+
this.setRotation(rotation, stepRotation);
144+
145+
var alpha = GetObjectValue(options, 'alpha', 1);
146+
var stepAlpha = GetObjectValue(options, 'stepAlpha', 0);
147+
148+
this.setAlpha(alpha, stepAlpha);
149+
129150
return entries;
130151
},
131152

@@ -167,6 +188,13 @@ var Layer = new Class({
167188
return this;
168189
},
169190

191+
incAlpha: function (value, step)
192+
{
193+
Actions.IncAlpha(this.children.entries, value, step);
194+
195+
return this;
196+
},
197+
170198
incX: function (value)
171199
{
172200
Actions.IncX(this.children.entries, value);
@@ -216,6 +244,13 @@ var Layer = new Class({
216244
return this;
217245
},
218246

247+
setAlpha: function (value, step)
248+
{
249+
Actions.SetAlpha(this.children.entries, value, step);
250+
251+
return this;
252+
},
253+
219254
setRotation: function (value, step)
220255
{
221256
Actions.SetRotation(this.children.entries, value, step);
@@ -237,9 +272,9 @@ var Layer = new Class({
237272
return this;
238273
},
239274

240-
setXY: function (x, y)
275+
setXY: function (x, y, stepX, stepY)
241276
{
242-
Actions.SetXY(this.children.entries, x, y);
277+
Actions.SetXY(this.children.entries, x, y, stepX, stepY);
243278

244279
return this;
245280
},

0 commit comments

Comments
 (0)