Commit 87951f14 authored by wildfirecode's avatar wildfirecode

1

parent 716c4811
This diff is collapsed.
...@@ -51,15 +51,18 @@ function launchWithCustomModule(customModule) { ...@@ -51,15 +51,18 @@ function launchWithCustomModule(customModule) {
const d = engine.gameStage.sceneContainer.getChildAt(0); const d = engine.gameStage.sceneContainer.getChildAt(0);
}, 200); }, 200);
setTimeout(() => { // setTimeout(() => {
engine.globalEvent.dispatchEvent('recycling-start', { time: 2 }); // engine.globalEvent.dispatchEvent('recycling-start', { time: 2 });
const d = engine.gameStage.sceneContainer.getChildAt(0); // const d = engine.gameStage.sceneContainer.getChildAt(0);
}, 1000 * 10); // }, 1000 * 10);
}); });
engine.globalEvent.addEventListener('recycling-time-update', (e) => { engine.globalEvent.addEventListener('recycling-time-update', (e) => {
console.log(e.type, e.data); console.log(e.type, e.data);
}); });
engine.globalEvent.addEventListener('recycling-score-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('recycling-game-end', (e) => { engine.globalEvent.addEventListener('recycling-game-end', (e) => {
console.log(e.type, e.data); console.log(e.type, e.data);
}); });
......
This diff is collapsed.
This diff is collapsed.
...@@ -103,17 +103,22 @@ export default class GameView extends engine.Container { ...@@ -103,17 +103,22 @@ export default class GameView extends engine.Container {
let idlerWheels = ['idler0', 'idler1', 'idler2', 'idler3', 'idler4', 'idler5', 'idler6']; let idlerWheels = ['idler0', 'idler1', 'idler2', 'idler3', 'idler4', 'idler5', 'idler6'];
idlerWheels = idlerWheels.map(i => this.uiMap[i]); idlerWheels = idlerWheels.map(i => this.uiMap[i]);
idlerWheels.forEach(i => { idlerWheels.forEach(i => {
engine.Tween.get(i, { loop: true }).to({ rotation: 360 }, 3000); engine.Tween.get(i, { loop: true }).to({ rotation: -360 }, 1000);
}) })
} }
stopAni() { stopAni() {
let idlerWheels = ['idler0', 'idler1', 'idler2', 'idler3', 'idler4', 'idler5', 'idler6'];
idlerWheels = idlerWheels.map(i => this.uiMap[i]);
idlerWheels.forEach(i => {
engine.Tween.removeTweens(i);
})
} }
async start() { async start() {
console.log('on start') console.log('on start')
this._timeCounter = 0; this._timeCounter = 0;
this.score = 0;
if (!getGuideInfo()) { if (!getGuideInfo()) {
await this.guide.startGuide(); await this.guide.startGuide();
...@@ -122,8 +127,7 @@ export default class GameView extends engine.Container { ...@@ -122,8 +127,7 @@ export default class GameView extends engine.Container {
await this.countdown.startCountDown(); await this.countdown.startCountDown();
this.playAni(); this.startGame();
engine.globalEvent.dispatchEvent('recycling-time-update', { engine.globalEvent.dispatchEvent('recycling-time-update', {
second: this.getSecond(), second: this.getSecond(),
...@@ -134,25 +138,43 @@ export default class GameView extends engine.Container { ...@@ -134,25 +138,43 @@ export default class GameView extends engine.Container {
}, 1000) }, 1000)
} }
getSecond() { private startGame() {
this.playAni();
this.stage.addEventListener(engine.MouseEvent.CLICK, this.xxx, this);
}
private xxx() {
this.score++;
engine.globalEvent.dispatchEvent('recycling-score-update', {
score: this.score
});
}
private stopGame() {
this.stage.removeEventListener(engine.MouseEvent.CLICK, this.xxx, this);
this.stopAni();
}
getSecond() {
return props.time - this._timeCounter return props.time - this._timeCounter
} }
onTimer() { onTimer() {
this._timeCounter++; this._timeCounter++;
engine.globalEvent.dispatchEvent('recycling-time-update', { engine.globalEvent.dispatchEvent('recycling-time-update', {
second: this.getSecond(), second: this.getSecond(),
}); });
if (this.getSecond() == 0) { if (this.getSecond() == 0) {
this.stop(); this.stop();
engine.globalEvent.dispatchEvent('recycling-game-end', { }); engine.globalEvent.dispatchEvent('recycling-game-end', {});
} }
} }
stop() { stop() {
clearInterval(this._timer); clearInterval(this._timer);
this.stopGame();
} }
setup() { setup() {
......
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