|
@@ -1,6 +1,5 @@
|
|
import * as PIXI from 'pixi.js';
|
|
import * as PIXI from 'pixi.js';
|
|
//import Text from './Text.js';
|
|
//import Text from './Text.js';
|
|
-import { getParam } from '../../../helpers/url';
|
|
|
|
|
|
|
|
import dragAndDrop from '../../../helpers/dragAndDrop';
|
|
import dragAndDrop from '../../../helpers/dragAndDrop';
|
|
|
|
|
|
@@ -23,13 +22,12 @@ class Card extends GuiableContainer{
|
|
constructor(props) {
|
|
constructor(props) {
|
|
super(props);
|
|
super(props);
|
|
let {
|
|
let {
|
|
- image,
|
|
|
|
x,
|
|
x,
|
|
y
|
|
y
|
|
} = props;
|
|
} = props;
|
|
|
|
|
|
// Properties Component
|
|
// Properties Component
|
|
- this.imageURL = image || getParam('imageURL');
|
|
|
|
|
|
+ //this.imageURL = image || getParam('imageURL');
|
|
this.position.set(x,y);
|
|
this.position.set(x,y);
|
|
|
|
|
|
this.x = x || 0;
|
|
this.x = x || 0;
|
|
@@ -37,7 +35,7 @@ class Card extends GuiableContainer{
|
|
|
|
|
|
// GUI
|
|
// GUI
|
|
this.addFolder('Card');
|
|
this.addFolder('Card');
|
|
- this.addToFolder('Card', this, 'imageURL').onFinishChange((v) => this.loadImage(v));
|
|
|
|
|
|
+ //this.addToFolder('Card', this, 'imageURL').onFinishChange((v) => this.loadImage(v));
|
|
this.addToFolder('Card', this, 'x').onFinishChange((v) => this.position.x = v);
|
|
this.addToFolder('Card', this, 'x').onFinishChange((v) => this.position.x = v);
|
|
this.addToFolder('Card', this, 'y').onFinishChange((v) => this.position.y = v);
|
|
this.addToFolder('Card', this, 'y').onFinishChange((v) => this.position.y = v);
|
|
this.addToFolder('Card', {team: false}, 'team').onFinishChange((v) => this.setTeam(v));
|
|
this.addToFolder('Card', {team: false}, 'team').onFinishChange((v) => this.setTeam(v));
|
|
@@ -55,7 +53,7 @@ class Card extends GuiableContainer{
|
|
this.sprite.width = w;
|
|
this.sprite.width = w;
|
|
this.sprite.height= h;
|
|
this.sprite.height= h;
|
|
|
|
|
|
- this.frame = new PIXI.Sprite(BlueImage);
|
|
|
|
|
|
+ this.frame = new PIXI.Sprite(RedImage);
|
|
this.frame.anchor.set(0.5,0.5);
|
|
this.frame.anchor.set(0.5,0.5);
|
|
this.frame.width = w;
|
|
this.frame.width = w;
|
|
this.frame.height= h;
|
|
this.frame.height= h;
|
|
@@ -68,11 +66,12 @@ class Card extends GuiableContainer{
|
|
this.label.height= lh;
|
|
this.label.height= lh;
|
|
this.label.position.set(0,210);
|
|
this.label.position.set(0,210);
|
|
|
|
|
|
-
|
|
|
|
this.interactive = true;
|
|
this.interactive = true;
|
|
this.hitArea = new PIXI.Rectangle(-w/2,-h/2,w,h);
|
|
this.hitArea = new PIXI.Rectangle(-w/2,-h/2,w,h);
|
|
this.cursor = 'pointer';
|
|
this.cursor = 'pointer';
|
|
|
|
|
|
|
|
+ this.scale.set(0.5);
|
|
|
|
+
|
|
this.addChild(this.sprite);
|
|
this.addChild(this.sprite);
|
|
this.addChild(this.label);
|
|
this.addChild(this.label);
|
|
this.addChild(this.frame);
|
|
this.addChild(this.frame);
|
|
@@ -84,22 +83,23 @@ class Card extends GuiableContainer{
|
|
setTeam(team) {
|
|
setTeam(team) {
|
|
switch(team) {
|
|
switch(team) {
|
|
case 0: case 'R': case 'r': case false:
|
|
case 0: case 'R': case 'r': case false:
|
|
- this.frame.setTexture(RedImage);
|
|
|
|
|
|
+ this.frame.texture = RedImage;
|
|
break;
|
|
break;
|
|
case 1: case 'B': case 'b': case true:
|
|
case 1: case 'B': case 'b': case true:
|
|
- this.frame.setTexture(BlueImage);
|
|
|
|
|
|
+ this.frame.texture = BlueImage;
|
|
break;
|
|
break;
|
|
default:break;
|
|
default:break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
loadCard(number) {
|
|
loadCard(number) {
|
|
|
|
+ number = parseInt(number+0.5, 10);
|
|
this.imageURL = Deck.Filenames[number];
|
|
this.imageURL = Deck.Filenames[number];
|
|
- this.setTexture(Deck.Textures[number]);
|
|
|
|
|
|
+ this.sprite.texture = Deck.Textures[number];
|
|
}
|
|
}
|
|
|
|
|
|
setTexture(texture) {
|
|
setTexture(texture) {
|
|
- this.sprite.setTexture(texture);
|
|
|
|
|
|
+ this.sprite.texture = texture;
|
|
}
|
|
}
|
|
|
|
|
|
onClick(fn) {
|
|
onClick(fn) {
|
|
@@ -139,7 +139,6 @@ class Card extends GuiableContainer{
|
|
getAsJSON() {
|
|
getAsJSON() {
|
|
return {
|
|
return {
|
|
component: 'base/Card',
|
|
component: 'base/Card',
|
|
- image: this.imageURL,
|
|
|
|
x: this.position.x,
|
|
x: this.position.x,
|
|
y: this.position.y
|
|
y: this.position.y
|
|
};
|
|
};
|