add select button to cryp list for mobile"

This commit is contained in:
ntr
2018-12-14 11:12:30 +11:00
parent b43fc44303
commit bfb721b5ee
3 changed files with 18 additions and 4 deletions
+14 -3
View File
@@ -37,10 +37,12 @@ class CrypRows extends Phaser.GameObjects.Group {
list.displaySkills(cryp);
});
const selectFn = () => {
list.game.events.emit('CRYP_ACTIVE', cryp);
};
if (KEY_MAP[i]) {
this.keyboard.on(KEY_MAP[i], () => {
list.game.events.emit('CRYP_ACTIVE', cryp);
}, this);
this.keyboard.on(KEY_MAP[i], selectFn, this);
}
row.cryp = cryp;
@@ -57,6 +59,15 @@ class CrypRows extends Phaser.GameObjects.Group {
const CRYP_STATS = [cryp.stamina, cryp.phys_dmg, cryp.spell_dmg];
CRYP_STATS.forEach(crypStat);
const selectBtn = list.add
.rectangle(ROW_WIDTH - 50, ROW_Y, 50, ROW_HEIGHT, FILL, 0.5)
.setInteractive()
.setOrigin(0);
selectBtn.on('pointerdown', selectFn);
this.add(selectBtn);
this.add(list.add.text(ROW_WIDTH - 20, ROW_Y, i + 1, TEXT.HEADER));
this.add(list.add.text(ROW_X, ROW_Y + (TEXT_MARGIN * 0), cryp.name, TEXT.HEADER));
});