Commit 87951f14 authored by wildfirecode's avatar wildfirecode

1

parent 716c4811
This diff is collapsed.
......@@ -51,15 +51,18 @@ function launchWithCustomModule(customModule) {
const d = engine.gameStage.sceneContainer.getChildAt(0);
}, 200);
setTimeout(() => {
engine.globalEvent.dispatchEvent('recycling-start', { time: 2 });
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('recycling-start', { time: 2 });
const d = engine.gameStage.sceneContainer.getChildAt(0);
}, 1000 * 10);
// const d = engine.gameStage.sceneContainer.getChildAt(0);
// }, 1000 * 10);
});
engine.globalEvent.addEventListener('recycling-time-update', (e) => {
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) => {
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 {
let idlerWheels = ['idler0', 'idler1', 'idler2', 'idler3', 'idler4', 'idler5', 'idler6'];
idlerWheels = idlerWheels.map(i => this.uiMap[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() {
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() {
console.log('on start')
this._timeCounter = 0;
this.score = 0;
if (!getGuideInfo()) {
await this.guide.startGuide();
......@@ -122,8 +127,7 @@ export default class GameView extends engine.Container {
await this.countdown.startCountDown();
this.playAni();
this.startGame();
engine.globalEvent.dispatchEvent('recycling-time-update', {
second: this.getSecond(),
......@@ -134,6 +138,23 @@ export default class GameView extends engine.Container {
}, 1000)
}
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
......@@ -147,12 +168,13 @@ export default class GameView extends engine.Container {
if (this.getSecond() == 0) {
this.stop();
engine.globalEvent.dispatchEvent('recycling-game-end', { });
engine.globalEvent.dispatchEvent('recycling-game-end', {});
}
}
stop() {
clearInterval(this._timer);
this.stopGame();
}
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