clean up text

This commit is contained in:
ntr 2018-11-19 23:09:31 +11:00
parent 6907cf17e0
commit d4bcaa244c
2 changed files with 14 additions and 2 deletions

View File

@ -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);
}
}

View File

@ -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' });