Colour items
This commit is contained in:
parent
21c657a1a2
commit
168cdd4104
@ -5,6 +5,16 @@ const {
|
||||
COLOURS,
|
||||
} = require('../constants');
|
||||
|
||||
function FindColour(item) {
|
||||
// Future add skills and use a constants lookup file ??
|
||||
switch (item) {
|
||||
case 'Green': return 0x61B329;
|
||||
case 'Red': return 0xCC3333;
|
||||
case 'Blue': return 0x6633FF;
|
||||
default: return 0x222222;
|
||||
}
|
||||
}
|
||||
|
||||
class Item extends Phaser.GameObjects.Container {
|
||||
constructor(scene, item, index, x, y, width, height) {
|
||||
super(scene, x, y);
|
||||
@ -18,8 +28,9 @@ class Item extends Phaser.GameObjects.Container {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
this.colour = FindColour(item);
|
||||
this.box = scene.add
|
||||
.rectangle(0, 0, width, height, 0x222222);
|
||||
.rectangle(0, 0, width, height, this.colour);
|
||||
|
||||
this.text = scene.add
|
||||
// .text(0, 0, `${action} x${count}`, TEXT.NORMAL)
|
||||
@ -49,7 +60,7 @@ class Item extends Phaser.GameObjects.Container {
|
||||
this.scene.children.list.forEach((item) => {
|
||||
if (item.state === 'select') item.deselect();
|
||||
});
|
||||
this.box.setFillStyle(COLOURS.SELECT);
|
||||
// this.box.setFillStyle(COLOURS.SELECT);
|
||||
this.state = 'select';
|
||||
}
|
||||
|
||||
@ -57,12 +68,12 @@ class Item extends Phaser.GameObjects.Container {
|
||||
this.scene.children.list.forEach((item) => {
|
||||
if (item.state === 'select') item.deselect();
|
||||
});
|
||||
this.box.setFillStyle(0xff0000);
|
||||
this.box.setFillStyle(0x222222);
|
||||
this.state = 'activate';
|
||||
}
|
||||
|
||||
deselect() {
|
||||
this.box.setFillStyle(0x222222);
|
||||
this.box.setFillStyle(this.colour);
|
||||
this.state = 'deselect';
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user