item list

This commit is contained in:
ntr
2018-12-21 19:21:09 +11:00
parent 114a6d505c
commit b9e74f1d0d
3 changed files with 46 additions and 2 deletions
+45
View File
@@ -0,0 +1,45 @@
const Phaser = require('phaser');
const {
TEXT,
// COLOURS,
POSITIONS: { GAME_LIST },
} = require('./constants');
class ItemList extends Phaser.GameObjects.Group {
constructor(args) {
super(args.list);
const { list, ws, itemList } = args;
const X = GAME_LIST.x() + GAME_LIST.x();
const WIDTH = Math.floor(GAME_LIST.width());
const HEIGHT = GAME_LIST.height();
const itemRow = (item, i) => {
const ITEM_X = X;
const ITEM_Y = GAME_LIST.rowY(i);
const itemBox = list.add
.rectangle(ITEM_X, ITEM_Y, WIDTH * 2, HEIGHT, 0x111111)
.setInteractive()
.setOrigin(0);
this.add(list.add.text(ITEM_X, ITEM_Y, item.action, TEXT.HEADER));
itemBox.on('pointerdown', () => {
ws.sendItemUse(item.id);
});
};
itemList.forEach(itemRow);
return true;
}
cleanup() {
return true;
}
}
module.exports = ItemList;