mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 06:28:30 +00:00
Added Alpha Actions.
This commit is contained in:
parent
93d9e97fa6
commit
358b74237a
6 changed files with 72 additions and 8 deletions
11
v3/src/actions/IncAlpha.js
Normal file
11
v3/src/actions/IncAlpha.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
var IncAlpha = function (items, value)
|
||||
{
|
||||
for (var i = 0; i < items.length; i++)
|
||||
{
|
||||
items[i].alpha += value;
|
||||
}
|
||||
|
||||
return items;
|
||||
};
|
||||
|
||||
module.exports = IncAlpha;
|
13
v3/src/actions/SetAlpha.js
Normal file
13
v3/src/actions/SetAlpha.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
var SetAlpha = function (items, value, step)
|
||||
{
|
||||
if (step === undefined) { step = 0; }
|
||||
|
||||
for (var i = 0; i < items.length; i++)
|
||||
{
|
||||
items[i].alpha = value + (i * step);
|
||||
}
|
||||
|
||||
return items;
|
||||
};
|
||||
|
||||
module.exports = SetAlpha;
|
|
@ -1,9 +1,12 @@
|
|||
var SetXY = function (items, x, y)
|
||||
var SetXY = function (items, x, y, stepX, stepY)
|
||||
{
|
||||
if (stepX === undefined) { stepX = 0; }
|
||||
if (stepY === undefined) { stepY = 0; }
|
||||
|
||||
for (var i = 0; i < items.length; i++)
|
||||
{
|
||||
items[i].x = x;
|
||||
items[i].y = y;
|
||||
items[i].x = x + (i * stepX);
|
||||
items[i].y = y + (i * stepY);
|
||||
}
|
||||
|
||||
return items;
|
||||
|
|
|
@ -4,6 +4,7 @@ module.exports = {
|
|||
|
||||
Angle: require('./Angle'),
|
||||
GridAlign: require('./GridAlign'),
|
||||
IncAlpha: require('./IncAlpha'),
|
||||
IncX: require('./IncX'),
|
||||
IncXY: require('./IncXY'),
|
||||
IncY: require('./IncY'),
|
||||
|
@ -11,6 +12,7 @@ module.exports = {
|
|||
Rotate: require('./Rotate'),
|
||||
RotateAround: require('./RotateAround'),
|
||||
RotateAroundDistance: require('./RotateAroundDistance'),
|
||||
SetAlpha: require('./SetAlpha'),
|
||||
SetRotation: require('./SetRotation'),
|
||||
SetVisible: require('./SetVisible'),
|
||||
SetX: require('./SetX'),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var CHECKSUM = {
|
||||
build: '37c7b2f0-13a7-11e7-8907-e12aa7288dfa'
|
||||
build: '00b50b50-13b6-11e7-a00b-efd0cd0ce446'
|
||||
};
|
||||
module.exports = CHECKSUM;
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
var Class = require('../../utils/Class');
|
||||
var Set = require('../../structs/Set');
|
||||
var GetObjectValue = require('../../utils/object/GetObjectValue');
|
||||
var Actions = require('../../actions/');
|
||||
var Sprite = require('../sprite/Sprite');
|
||||
|
||||
|
@ -97,10 +98,11 @@ var Layer = new Class({
|
|||
* @param {boolean} [exists=false] - The default exists state of the Sprite.
|
||||
* @return {array} An array containing all of the Sprites that were created.
|
||||
*/
|
||||
createMultiple: function (quantity, key, frame, visible)
|
||||
createMultiple: function (quantity, key, frame, options)
|
||||
{
|
||||
if (frame === undefined) { frame = null; }
|
||||
if (visible === undefined) { visible = true; }
|
||||
|
||||
var visible = GetObjectValue(options, 'visible', true);
|
||||
|
||||
if (!Array.isArray(key))
|
||||
{
|
||||
|
@ -126,6 +128,25 @@ var Layer = new Class({
|
|||
});
|
||||
});
|
||||
|
||||
// Post-creation options:
|
||||
|
||||
var x = GetObjectValue(options, 'x', 0);
|
||||
var y = GetObjectValue(options, 'y', 0);
|
||||
var stepX = GetObjectValue(options, 'stepX', 0);
|
||||
var stepY = GetObjectValue(options, 'stepY', 0);
|
||||
|
||||
this.setXY(x, y, stepX, stepY);
|
||||
|
||||
var rotation = GetObjectValue(options, 'rotation', 0);
|
||||
var stepRotation = GetObjectValue(options, 'stepRotation', 0);
|
||||
|
||||
this.setRotation(rotation, stepRotation);
|
||||
|
||||
var alpha = GetObjectValue(options, 'alpha', 1);
|
||||
var stepAlpha = GetObjectValue(options, 'stepAlpha', 0);
|
||||
|
||||
this.setAlpha(alpha, stepAlpha);
|
||||
|
||||
return entries;
|
||||
},
|
||||
|
||||
|
@ -167,6 +188,13 @@ var Layer = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
incAlpha: function (value, step)
|
||||
{
|
||||
Actions.IncAlpha(this.children.entries, value, step);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
incX: function (value)
|
||||
{
|
||||
Actions.IncX(this.children.entries, value);
|
||||
|
@ -216,6 +244,13 @@ var Layer = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
setAlpha: function (value, step)
|
||||
{
|
||||
Actions.SetAlpha(this.children.entries, value, step);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
setRotation: function (value, step)
|
||||
{
|
||||
Actions.SetRotation(this.children.entries, value, step);
|
||||
|
@ -237,9 +272,9 @@ var Layer = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
setXY: function (x, y)
|
||||
setXY: function (x, y, stepX, stepY)
|
||||
{
|
||||
Actions.SetXY(this.children.entries, x, y);
|
||||
Actions.SetXY(this.children.entries, x, y, stepX, stepY);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue