|
@@ -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{
|
|
class Button extends PIXI.Sprite{
|
|
constructor(props) {
|
|
constructor(props) {
|
|
super(PIXI.Texture.fromImage('/files/assets/ui/woodenbutton.png'));
|
|
super(PIXI.Texture.fromImage('/files/assets/ui/woodenbutton.png'));
|
|
-
|
|
|
|
let {
|
|
let {
|
|
|
|
+ image,
|
|
text,
|
|
text,
|
|
Gui
|
|
Gui
|
|
} = props;
|
|
} = 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.anchor.set(0.5,0.5);
|
|
this.interactive = true;
|
|
this.interactive = true;
|
|
this.buttonMode = 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);
|
|
this.addChild(this.textNode);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
_kill() {
|
|
_kill() {
|
|
- this.Gui.remove(this.controller);
|
|
|
|
this.destroy();
|
|
this.destroy();
|
|
}
|
|
}
|
|
|
|
|