Commit 18ebc83d authored by wildfirecode's avatar wildfirecode

1

parent d384b84c
...@@ -2,8 +2,8 @@ export default class PieceControl { ...@@ -2,8 +2,8 @@ export default class PieceControl {
public scene; public scene;
private isDog: boolean; private isDog: boolean;
private front; private front;
private back; public back;
private index: number; public index: number;
static FLIP_DURTION = 1000; static FLIP_DURTION = 1000;
public container; public container;
......
...@@ -9,7 +9,7 @@ export default class SceneControl { ...@@ -9,7 +9,7 @@ export default class SceneControl {
SHOW_TIME = 1000; SHOW_TIME = 1000;
DELAY = 500; DELAY = 500;
BORNS = 2; BORNS = 1;
R = 3; R = 3;
TIMES = 3; TIMES = 3;
N = 4; N = 4;
...@@ -22,40 +22,42 @@ export default class SceneControl { ...@@ -22,40 +22,42 @@ export default class SceneControl {
} }
initUI() { initUI() {
const n = this.R * this.R; const n = this.R * this.R;
const targetList = utils.fillN(n); const targetList = utils.fillN(n);
const randomTargetList = utils.shuffle(targetList); const randomTargetList = utils.shuffle(targetList);
this._targets = randomTargetList.slice(0, this.BORNS); this._targets = randomTargetList.slice(0, this.BORNS);
this._list = []; this._list = [];
for (let index = 1; index <= n; index++) { for (let index = 1; index <= n; index++) {
const inTargets = this._targets.indexOf(index) != -1; const inTargets = this._targets.indexOf(index) != -1;
const p = new PieceControl(this.scene, !inTargets, index); const p = new PieceControl(this.scene, !inTargets, index);
p.back.setInteractive();
p['index'] = index; p['index'] = index;
this._list.push(p); this._list.push(p);
p.container.x = ((index - 1) % this.R) * this.SIZE + 106 + 50; p.container.x = ((index - 1) % this.R) * this.SIZE + 106 + 50;
p.container.y = Math.floor((index - 1) / this.R) * this.SIZE + 106 + 50; p.container.y = Math.floor((index - 1) / this.R) * this.SIZE + 106 + 50;
p.flipImmediately(); p.flipImmediately();
// p.addEventListener('click', (e: createjs.MouseEvent) => { p.back.on('clicked', () => {
// const p = (e.currentTarget as Piece); // console.log(p.index);
// this.disable(); this.disable();
// let enable = false; let enable = false;
// const index = this._targets.indexOf(p.index); const index = this._targets.indexOf(p.index);
// if (index != -1) { if (index != -1) {
// this._targets.splice(index, 1); this._targets.splice(index, 1);
// if (this._targets.length == 0) { if (this._targets.length == 0) {
// console.log('good.') console.log('good.')
// } else { } else {
// enable = true; enable = true;
// } }
// } }
// else { else {
// console.log('sorry.') console.log('sorry.')
// } }
// p.flip(() => { p.flip(() => {
// if (enable) this.enable(); if (enable) this.enable();
// }); });
}, this);
// });
} }
this.disable(); this.disable();
...@@ -84,14 +86,14 @@ export default class SceneControl { ...@@ -84,14 +86,14 @@ export default class SceneControl {
} }
disable() { disable() {
// for (const e of this._list) { this.scene.input.off('gameobjectup', this.ongameobjectup, this);
// e.mouseEnabled = false;
// }
} }
enable() { enable() {
// for (const e of this._list) { this.scene.input.on('gameobjectup', this.ongameobjectup, this);
// e.mouseEnabled = true; }
// }
ongameobjectup(pointer, gameObject){
gameObject.emit('clicked', gameObject);
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment