item list
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user