|
@@ -1,4 +1,5 @@
|
|
import * as PIXI from 'pixi.js';
|
|
import * as PIXI from 'pixi.js';
|
|
|
|
+import { getParam } from '../helpers/url.js';
|
|
|
|
|
|
class Loader extends PIXI.Container{
|
|
class Loader extends PIXI.Container{
|
|
|
|
|
|
@@ -7,16 +8,21 @@ class Loader extends PIXI.Container{
|
|
|
|
|
|
this.GameLayer = GameLayer;
|
|
this.GameLayer = GameLayer;
|
|
|
|
|
|
- this.component = '';
|
|
|
|
|
|
+ var comp = getParam('component');
|
|
|
|
+ this.component = comp || '';
|
|
|
|
+
|
|
|
|
|
|
let app = GameLayer.app;
|
|
let app = GameLayer.app;
|
|
this.gui = GameLayer.gui();
|
|
this.gui = GameLayer.gui();
|
|
this.router = GameLayer.router();
|
|
this.router = GameLayer.router();
|
|
- this.position.set(app.screen.width/2, app.screen.height/2);
|
|
|
|
|
|
+ this.position.set(app.screen.width/2, app.screen.height/2);
|
|
|
|
|
|
|
|
|
|
this.controller = this.gui.add(this, 'component');
|
|
this.controller = this.gui.add(this, 'component');
|
|
this.controller.onFinishChange((value) => this.loadComponent(value));
|
|
this.controller.onFinishChange((value) => this.loadComponent(value));
|
|
|
|
+
|
|
|
|
+ if(this.component)
|
|
|
|
+ this.loadComponent(this.component);
|
|
}
|
|
}
|
|
|
|
|
|
destroy() {
|
|
destroy() {
|
|
@@ -24,12 +30,12 @@ class Loader extends PIXI.Container{
|
|
}
|
|
}
|
|
|
|
|
|
loadComponent = (component) => {
|
|
loadComponent = (component) => {
|
|
- if(this.instance) {
|
|
|
|
|
|
+ if (this.instance) {
|
|
this.removeChild(this.instance);
|
|
this.removeChild(this.instance);
|
|
this.instance._kill();
|
|
this.instance._kill();
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
- if(component.length < 3)return;
|
|
|
|
|
|
+ if (component.length < 3) return;
|
|
let ctor = require('../Game/misc/' + component).default;
|
|
let ctor = require('../Game/misc/' + component).default;
|
|
this.instance = new ctor({GameLayer: this.GameLayer, Router: this.router, Gui: this.gui});
|
|
this.instance = new ctor({GameLayer: this.GameLayer, Router: this.router, Gui: this.gui});
|
|
this.addChild(this.instance);
|
|
this.addChild(this.instance);
|