Nikatlas 6 years ago
parent
commit
04c97a1699
3 changed files with 26 additions and 19 deletions
  1. 9 2
      src/Game/misc/Button.js
  2. 0 0
      src/Game/misc/ButtonArray.js
  3. 17 17
      src/Game/views/Menu.js

+ 9 - 2
src/Game/misc/Button.js

@@ -18,7 +18,14 @@ class Button extends PIXI.Sprite{
         this.imageURL = image || getParam('imageURL') || DefaultImageUrl;
         if(Gui) {
             this.Gui = Gui;
-            this.controller = Gui.add(this, 'imageURL').onFinishChange((v) => this.loadImage(v));
+            let position = {
+                x:0,
+                y:0
+            }
+            this.controllers = [];
+            this.controllers.push(Gui.add(this, 'imageURL').onFinishChange((v) => this.loadImage(v)));
+            this.controllers.push(Gui.add(position, 'x').onFinishChange((v) => this.position.x = v));
+            this.controllers.push(Gui.add(position, 'y').onFinishChange((v) => this.position.y = v));
         }
 
         this.anchor.set(0.5,0.5);
@@ -41,7 +48,7 @@ class Button extends PIXI.Sprite{
     }
 
     _kill() {
-        this.controller.remove();
+        this.controllers.forEach((e) => e.remove());
         this.textNode._kill();
         this.destroy();
     }

+ 0 - 0
src/Game/misc/ButtonArray.js


+ 17 - 17
src/Game/views/Menu.js

@@ -1,23 +1,23 @@
-import * as PIXI from 'pixi.js'
+import * as PIXI from 'pixi.js';
 
 const BUTTON_HEIGHT = 120;
 class Menu extends PIXI.Container{
-	constructor(app, config){
-		super();
-		this.stage = app.stage;
-		this.buttons = require('./menuConfigs/'+config).default || [];
-		this.calculatePositions();
-		this.buttons.forEach((e,i) => this.addChild(e));
-		this.test = "dsa";
-		this.position.set(app.screen.width/2, app.screen.height/2);
-	}
-	calculatePositions() {
-		let length = this.buttons.length;
-		let top = length * BUTTON_HEIGHT/2;
-		this.buttons.forEach((b,i) => {
-			b.position.set(0,-top + i*BUTTON_HEIGHT + BUTTON_HEIGHT/2);
-		});
-	}
+    constructor(app, config){
+        super();
+        this.stage = app.stage;
+        this.buttons = require('./menuConfigs/'+config).default || [];
+        this.calculatePositions();
+        this.buttons.forEach((e) => this.addChild(e));
+        this.test = 'dsa';
+        this.position.set(app.screen.width/2, app.screen.height/2);
+    }
+    calculatePositions() {
+        let length = this.buttons.length;
+        let top = length * BUTTON_HEIGHT/2;
+        this.buttons.forEach((b,i) => {
+            b.position.set(0,-top + i*BUTTON_HEIGHT + BUTTON_HEIGHT/2);
+        });
+    }
 }
 
 export default Menu;