bb3f52df37
* animated grid tiles * change woka's category with arrow buttons * added some dynamic effects to woka's list * add some drag distance treshold * do not show arrows if only one collection * WSAD and arrow keys movement through WOKA models * Adapting end to end tests Co-authored-by: Piotr 'pwh' Hanusiak <p.hanusiak@workadventu.re> Co-authored-by: David Négrier <d.negrier@thecodingmachine.com>
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { GridItem } from "@home-based-studio/phaser3-utils";
|
|
|
|
export class WokaSlot extends GridItem {
|
|
private sprite: Phaser.GameObjects.Sprite;
|
|
private selection: Phaser.GameObjects.Rectangle;
|
|
|
|
private readonly SIZE: number = 50;
|
|
|
|
constructor(scene: Phaser.Scene, spriteKey: string, id?: string) {
|
|
super(scene, id);
|
|
|
|
this.sprite = this.scene.add.sprite(0, 0, spriteKey);
|
|
this.selection = this.scene.add
|
|
.rectangle(0, 0, this.SIZE, this.SIZE)
|
|
.setStrokeStyle(1, 0xffffff)
|
|
.setVisible(false);
|
|
|
|
this.add([this.selection, this.sprite]);
|
|
this.setSize(this.SIZE, this.SIZE);
|
|
this.setInteractive({ cursor: "pointer" });
|
|
this.scene.input.setDraggable(this);
|
|
|
|
this.bindEventHandlers();
|
|
|
|
this.scene.add.existing(this);
|
|
}
|
|
|
|
public getSprite(): Phaser.GameObjects.Sprite {
|
|
return this.sprite;
|
|
}
|
|
|
|
public select(select: boolean = true): void {
|
|
this.selection.setVisible(select);
|
|
}
|
|
}
|