shits fucked

This commit is contained in:
ntr 2018-11-20 00:21:52 +11:00
parent 7c74018dbf
commit d9b25e0fc6
5 changed files with 20 additions and 24 deletions

View File

@ -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"

View File

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

View File

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

View File

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

View File

@ -35,6 +35,8 @@ function renderCryps(store) {
});
window.addEventListener('resize', () => game.resize(window.innerWidth, window.innerHeight), false);
return game;
}
module.exports = renderCryps;