Răsfoiți Sursa

Button from Text

Nikatlas 6 ani în urmă
părinte
comite
8aca6e233d
3 a modificat fișierele cu 9 adăugiri și 15 ștergeri
  1. 3 0
      src/Game/app.js
  2. 6 13
      src/Game/misc/Button.js
  3. 0 2
      src/components/Playground.jsx

+ 3 - 0
src/Game/app.js

@@ -19,11 +19,13 @@ class App {
 		// this._router.addRoute('Login', new Menu(this.app, 'LoginMenuConfig.js'));
 		// this._router.addRoute('Test', new Menu(this.app, 'TestMenuConfig.js'));
 	}
+
 	destroy() {
 		this.app.view.style.display = 'none';
 		this.animateables = [];
 		this._router.clear();
 	}
+
 	init() {
 		this.app.view.style.display = 'block';
 		//this._router.go("Login");
@@ -32,6 +34,7 @@ class App {
 	router() {
 		return this._router;	
 	}
+
 	gui() {
 		return this._gui;
 	}

+ 6 - 13
src/Game/misc/Button.js

@@ -1,32 +1,25 @@
-import * as PIXI from 'pixi.js'
+import * as PIXI from 'pixi.js';
+import Text from './Text.js';
+
 class Button extends PIXI.Sprite{
     constructor(props) {
         super(PIXI.Texture.fromImage('/files/assets/ui/woodenbutton.png'));
-        
         let {
+            image,
             text,
             Gui
         } = props;
 
-
-        this.text = text || '';
-
-        if(Gui) {
-            this.Gui =  Gui;
-            this.controller = Gui.add(this, 'text').onFinishChange((v) => this.textNode.setText(v));
-        }
-        
         this.anchor.set(0.5,0.5);
         this.interactive = true;
         this.buttonMode = true;
-        this.textNode = new PIXI.Text(text,{fontFamily : 'Arial', fontSize: 24, fill : 0xFFFFFF, align : 'center'});
-        this.textNode.anchor.set(0.5, 0.5);
+
+        this.textNode = new Text(props);
         this.addChild(this.textNode);
     }
 
 
     _kill() {
-        this.Gui.remove(this.controller);
         this.destroy();
     }
 

+ 0 - 2
src/components/Playground.jsx

@@ -14,14 +14,12 @@ class Playground extends Component {
        	const gui = GameLayer.gui();
 
        	const route = new Loader(GameLayer);
-
        	router.addRoute('Loader', route);
        	router.go('Loader');
 	}
 
 	componentDidMount() {
        GameLayer.init();
-       
 	}
 	componentWillUnmount() {
        GameLayer.destroy();