From d4bcaa244cdc39e57360aa5d7e74af0330d27b52 Mon Sep 17 00:00:00 2001 From: ntr Date: Mon, 19 Nov 2018 23:09:31 +1100 Subject: [PATCH] clean up text --- client/src/scenes/cryp.list.js | 9 ++++++++- client/src/scenes/cryp.page.js | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/client/src/scenes/cryp.list.js b/client/src/scenes/cryp.list.js index 2a34a558..97869dda 100644 --- a/client/src/scenes/cryp.list.js +++ b/client/src/scenes/cryp.list.js @@ -23,8 +23,14 @@ class CrypList extends Phaser.Scene { return true; } + destroyText() { + this.children.list.filter(c => c.type === 'Text').forEach(t => t.destroy()); + } + renderCryps(cryps) { if (!cryps) return true; + this.destroyText(); + this.graphics.clear(); const crypRows = cryps.forEach((cryp, i) => { crypRow(this, cryp, i); @@ -33,12 +39,13 @@ class CrypList extends Phaser.Scene { this.input.on('gameobjectup', this.clickHandler, this); // seal the boxes in and stop rerendering them - this.graphics.generateTexture(); + // this.graphics.generateTexture(); return true; } clickHandler(pointer, crypBox) { + console.log(crypBox); this.registry.set('activeCryp', crypBox.cryp); } } diff --git a/client/src/scenes/cryp.page.js b/client/src/scenes/cryp.page.js index 4e7ec3f0..28743733 100644 --- a/client/src/scenes/cryp.page.js +++ b/client/src/scenes/cryp.page.js @@ -34,13 +34,18 @@ class CrypPage extends Phaser.Scene { updateData(parent, key, data) { if (key === 'activeCryp') { - return this.scene.restart(); + this.renderCryp(data); } return true; } + destroyText() { + this.children.list.filter(c => c.type === 'Text').forEach(t => t.destroy()); + } + renderCryp(cryp) { if (!cryp) return true; + this.destroyText(); this.add.text(500, 500, cryp.name, { fontFamily: 'Arial', fontSize: 24, color: '#ffffff', fontStyle: 'bold' });