phaser/v3/src/gameobjects/layer/Layer.js

70 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-03-22 23:16:44 +00:00
var Class = require('../../utils/Class');
var Set = require('../../structs/Set');
2017-03-22 23:16:44 +00:00
var Layer = new Class({
initialize:
function Layer (children)
2017-03-22 23:16:44 +00:00
{
this.children = new Set(children);
2017-03-22 23:16:44 +00:00
},
// Layer management methods:
2017-03-22 23:16:44 +00:00
add: function (child)
2017-03-23 00:07:41 +00:00
{
this.children.set(child);
2017-03-23 00:07:41 +00:00
return this;
2017-03-22 23:16:44 +00:00
},
addMultiple: function (children)
2017-03-22 23:16:44 +00:00
{
if (Array.isArray(children))
2017-03-22 23:16:44 +00:00
{
for (var i = 0; i < children.length; i++)
{
this.children.set(children[i]);
}
2017-03-22 23:16:44 +00:00
}
2017-03-23 00:07:41 +00:00
return this;
2017-03-22 23:16:44 +00:00
},
remove: function (child)
2017-03-23 00:07:41 +00:00
{
this.children.delete(child);
2017-03-23 00:07:41 +00:00
return this;
2017-03-22 23:16:44 +00:00
},
clear: function ()
2017-03-23 00:07:41 +00:00
{
this.children.clear();
2017-03-23 00:07:41 +00:00
return this;
2017-03-22 23:16:44 +00:00
},
// Child Update Methods
2017-03-23 00:07:41 +00:00
addX: require('./actions/AddX'),
addY: require('./actions/AddY'),
addXY: require('./actions/AddXY'),
setX: require('./actions/SetX'),
setY: require('./actions/SetY'),
setXY: require('./actions/SetXY'),
2017-03-23 00:07:41 +00:00
rotate: require('./actions/Rotate'),
angle: require('./actions/Angle'),
setRotation: require('./actions/SetRotation'),
setVisible: require('./actions/SetVisible'),
2017-03-27 16:34:49 +00:00
toggleVisible: require('./actions/ToggleVisible'),
align: require('./actions/Align')
2017-03-22 23:16:44 +00:00
});
2017-03-23 00:07:41 +00:00
module.exports = Layer;