From d9b25e0fc604989aea06afc290654d5888cbd95b Mon Sep 17 00:00:00 2001 From: ntr Date: Tue, 20 Nov 2018 00:21:52 +1100 Subject: [PATCH] shits fucked --- client/package.json | 1 + client/src/scenes/cryp.list.js | 24 ++++++++++++------------ client/src/scenes/cryp.page.js | 14 +++----------- client/src/scenes/cryp.row.js | 3 ++- client/src/scenes/cryps.js | 2 ++ 5 files changed, 20 insertions(+), 24 deletions(-) diff --git a/client/package.json b/client/package.json index 2c6590f8..b88e22e9 100755 --- a/client/package.json +++ b/client/package.json @@ -5,6 +5,7 @@ "main": "index.js", "scripts": { "start": "parcel index.html --port 40080 --no-hmr", + "start-lite": "parcel index.html --port 40080 --no-hmr --no-source-maps", "build": "rm -rf dist && parcel build index.html", "lint": "eslint --fix --ext .jsx src/", "test": "echo \"Error: no test specified\" && exit 1" diff --git a/client/src/scenes/cryp.list.js b/client/src/scenes/cryp.list.js index e48124e8..d9fb325d 100644 --- a/client/src/scenes/cryp.list.js +++ b/client/src/scenes/cryp.list.js @@ -9,8 +9,8 @@ class CrypList extends Phaser.Scene { create() { this.registry.events.on('changedata', this.updateData, this); - this.graphics = this.add.graphics(); - + this.input.on('gameobjectup', this.clickHandler, this); + console.log('creating'); return true; } @@ -21,30 +21,30 @@ class CrypList extends Phaser.Scene { return true; } - destroyText() { - this.children.list.filter(c => c.type === 'Text').forEach(t => t.destroy()); + redraw() { + this.children.list.forEach(t => { + t.disableInteractive(); + t.destroy(); + }); } renderCryps(cryps) { if (!cryps) return true; - this.destroyText(); - this.graphics.clear(); + console.log(JSON.stringify(this.children.list)); + console.log(this.children.length); + this.redraw(); cryps.forEach((cryp, i) => { crypRow(this, cryp, i); }); - this.input.on('gameobjectup', this.clickHandler, this); - - // seal the boxes in and stop rerendering them - this.graphics.generateTexture(); - + window.redraw = this.redraw.bind(this); return true; } clickHandler(pointer, crypBox) { console.log(crypBox); - this.registry.set('activeCryp', crypBox.cryp); + this.registry.set('activeCryp', Object.create(crypBox.cryp)); } } diff --git a/client/src/scenes/cryp.page.js b/client/src/scenes/cryp.page.js index 28743733..f0eed295 100644 --- a/client/src/scenes/cryp.page.js +++ b/client/src/scenes/cryp.page.js @@ -24,11 +24,6 @@ class CrypPage extends Phaser.Scene { create() { this.registry.events.on('changedata', this.updateData, this); - - const cryp = this.registry.get('activeCryp'); - this.graphics = this.add.graphics(); - - this.renderCryp(cryp); return true; } @@ -39,20 +34,17 @@ class CrypPage extends Phaser.Scene { return true; } - destroyText() { - this.children.list.filter(c => c.type === 'Text').forEach(t => t.destroy()); + redraw() { + this.children.list.forEach(t => t.destroy()); } renderCryp(cryp) { if (!cryp) return true; - this.destroyText(); + this.redraw(); this.add.text(500, 500, cryp.name, { fontFamily: 'Arial', fontSize: 24, color: '#ffffff', fontStyle: 'bold' }); - cryp.skills.forEach((skill, i) => crypSkill(this, skill, i)); - // seal the boxes in and stop rerendering them - this.graphics.generateTexture(); return true; } } diff --git a/client/src/scenes/cryp.row.js b/client/src/scenes/cryp.row.js index 360d9887..b4508a24 100644 --- a/client/src/scenes/cryp.row.js +++ b/client/src/scenes/cryp.row.js @@ -8,10 +8,11 @@ const TOP_MARGIN = 50; const ROW_MARGIN = 50; const TEXT_MARGIN = 24; -const xPos = i => 0; +const xPos = i => Math.random() * 1400; const yPos = i => (i * ROW_HEIGHT + ROW_MARGIN) + TOP_MARGIN; function crypRow(list, cryp, i) { + console.log(i); const X_ORIGIN = xPos(i); const Y_ORIGIN = yPos(i); diff --git a/client/src/scenes/cryps.js b/client/src/scenes/cryps.js index 5981e930..224b50dd 100644 --- a/client/src/scenes/cryps.js +++ b/client/src/scenes/cryps.js @@ -35,6 +35,8 @@ function renderCryps(store) { }); window.addEventListener('resize', () => game.resize(window.innerWidth, window.innerHeight), false); + + return game; } module.exports = renderCryps;