|
@@ -9,7 +9,7 @@ import EventManager from '../../services/EventManager';
|
|
|
|
|
|
import config from '../../config.js';
|
|
|
|
|
|
-class CardHolder extends GuiableContainer{
|
|
|
+class CardHolder extends GuiableContainer {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
let {
|
|
@@ -45,12 +45,11 @@ class CardHolder extends GuiableContainer{
|
|
|
this.sprite.interactive = true;
|
|
|
this.sprite.hitArea = new PIXI.Rectangle(0, 0, this.w, this.h);
|
|
|
this.sprite.cursor = 'pointer';
|
|
|
- let fn = () => {
|
|
|
+ this._placeFn = () => {
|
|
|
// This is called before it is removed from the DragEnd Callback
|
|
|
- EventManager.trigger('CardPlaced', [this, this._onDrop]);
|
|
|
+ EventManager.trigger('CardPlaced', [this, this._onDrop]);
|
|
|
};
|
|
|
- this.sprite.on('mouseup', fn);
|
|
|
- this.sprite.on('touchend', fn);
|
|
|
+ this.setEvents();
|
|
|
|
|
|
this.position.set(this.x,this.y);
|
|
|
|
|
@@ -60,11 +59,40 @@ class CardHolder extends GuiableContainer{
|
|
|
EventManager.on('CardDraggingFinished', () => this.removeChild(this.sprite));
|
|
|
}
|
|
|
|
|
|
+ getCard() {
|
|
|
+ return this._card;
|
|
|
+ }
|
|
|
+
|
|
|
+ setEvents() {
|
|
|
+ this.sprite.on('mouseup', this._placeFn);
|
|
|
+ this.sprite.on('touchend',this._placeFn);
|
|
|
+ }
|
|
|
+
|
|
|
+ unsetEvents() {
|
|
|
+ this.sprite.off('mouseup', this._placeFn);
|
|
|
+ this.sprite.off('touchend',this._placeFn);
|
|
|
+ }
|
|
|
+
|
|
|
+ lock(card = null) {
|
|
|
+ this.unsetEvents();
|
|
|
+ this._locked = true;
|
|
|
+ this._card = card;
|
|
|
+ if(card) {
|
|
|
+ card.attach(this);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ unlock() {
|
|
|
+ this.setEvents();
|
|
|
+ this._locked = false;
|
|
|
+ }
|
|
|
+
|
|
|
scaleTo(s) {
|
|
|
this.scale.set(s);
|
|
|
this.s = s;
|
|
|
return this;
|
|
|
}
|
|
|
+
|
|
|
change(props) {
|
|
|
let newdata = {
|
|
|
x: this.x,
|