@koreez/phaser3-ninepatch
Version:
47 lines • 2.36 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 (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var NinePatch_1 = require("./ninepatch/NinePatch");
var NinePatchPlugin = (function (_super) {
__extends(NinePatchPlugin, _super);
function NinePatchPlugin(pluginManager) {
var _this = _super.call(this, pluginManager) || this;
pluginManager.game.cache.addCustom("ninePatch");
pluginManager.registerGameObject("ninePatch", _this.ninePatchFactory, _this.ninePatchCreator);
return _this;
}
NinePatchPlugin.prototype.ninePatchFactory = function (x, y, width, height, key, frame, patchesConfig) {
return this.scene.add.existing(new NinePatch_1.NinePatch(this.scene, x, y, width, height, key, frame, patchesConfig));
};
NinePatchPlugin.prototype.ninePatchCreator = function (config, addToScene) {
if (config === undefined) {
config = {};
}
var key = Phaser.Utils.Objects.GetAdvancedValue(config, "key", null);
var frame = Phaser.Utils.Objects.GetAdvancedValue(config, "frame", null);
var width = Phaser.Utils.Objects.GetAdvancedValue(config, "width", null);
var height = Phaser.Utils.Objects.GetAdvancedValue(config, "height", null);
var patchesConfig = Phaser.Utils.Objects.GetAdvancedValue(config, "patchesConfig", null);
var ninePatch = new NinePatch_1.NinePatch(this.scene, 0, 0, width, height, key, frame, patchesConfig);
if (addToScene !== undefined) {
config.add = addToScene;
}
Phaser.GameObjects.BuildGameObject(this.scene, ninePatch, config);
return ninePatch;
};
return NinePatchPlugin;
}(Phaser.Plugins.BasePlugin));
exports.NinePatchPlugin = NinePatchPlugin;
//# sourceMappingURL=NinePatchPlugin.js.map