@mai3/phaser-sdk
Version:
A UI component library based on the Phaser game engine
49 lines (48 loc) • 2.17 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { Container } from ".";
var EnemyContainer = /** @class */ (function (_super) {
__extends(EnemyContainer, _super);
function EnemyContainer(scene, config) {
var _this = _super.call(this, scene, config) || this;
_this._config = config;
_this.Type = "EnemyContainer";
_this.reDraw(config);
return _this;
}
EnemyContainer.prototype.reDraw = function (config) {
var _a, _b, _c;
this._config = config;
var width = (_a = config.width) !== null && _a !== void 0 ? _a : 0;
var height = (_b = config.height) !== null && _b !== void 0 ? _b : 0;
// Create a background rectangle to give the container bounds
var background = this.scene.add.rectangle(0, 0, width, height);
background.setOrigin(0, 0);
this.add(background);
this.setSize(width, height);
this.setPosition(config.x, config.y);
this.setDepth((_c = config === null || config === void 0 ? void 0 : config.depth) !== null && _c !== void 0 ? _c : 1);
this.setScrollFactor(config.isScrollFactor ? 0 : 1);
this.updateConfig(config);
this.RefreshBounds();
this.setEventInteractive();
};
EnemyContainer.prototype.destroy = function (fromScene) {
_super.prototype.destroy.call(this, fromScene);
};
return EnemyContainer;
}(Container));
export { EnemyContainer };