2d-gaming
Version:
This is an Angular package fo developing 2d games in angular. [Please report issues/questions/any ideas to better help this package](https://github.com/CWestBlue/2d-gaming/issues).
48 lines • 1.64 kB
JavaScript
import * as _ from 'lodash';
var ObjectArray = (function () {
function ObjectArray(item, howMany) {
this.item = item;
this.items = [];
this.howMany = howMany;
if (item && howMany) {
this.multiply(item, howMany);
}
else {
this.items.push(item);
}
}
// multiplys a single object
ObjectArray.prototype.multiply = function (item, howMany) {
for (var i = 0; i <= this.howMany; i++) {
this.items.push(this.item);
}
};
ObjectArray.prototype.update = function () {
var _this = this;
this.items.forEach(function (res) {
_this.item.game.gameObjects.add(res);
});
};
// removes objects from the array paramater and this object
ObjectArray.prototype.removeFromGame = function () {
this.items.forEach(function (item) {
var i = _.findIndex(item.game.gameObjects.items, function (o) { return o === item; });
if (i >= 0) {
item.game.context.clearRect(item.postion.xPos, item.postion.yPos, item.design.width, item.design.height);
item.game.gameObjects.items.splice(i, 1);
}
});
};
ObjectArray.prototype.add = function (item) {
this.items.push(item);
};
ObjectArray.prototype.addMulti = function (items) {
var _this = this;
items.forEach(function (res) {
_this.items.push(res);
});
};
return ObjectArray;
}());
export { ObjectArray };
//# sourceMappingURL=ammo.component.js.map