Commit 716c4811 authored by wildfirecode's avatar wildfirecode

1

parent 34d1bd4a
This diff is collapsed.
......@@ -46,15 +46,21 @@ function launchWithCustomModule(customModule) {
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('recycling-start', {});
engine.globalEvent.dispatchEvent('recycling-start', { time: 2 });
const d = engine.gameStage.sceneContainer.getChildAt(0);
}, 200);
setTimeout(() => {
engine.globalEvent.dispatchEvent('recycling-start', { time: 2 });
const d = engine.gameStage.sceneContainer.getChildAt(0);
}, 1000 * 10);
});
engine.globalEvent.addEventListener('recycling-time-update', (e) => {
// console.log(e.type, e.data);
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('recycling-game-fail', (e) => {
engine.globalEvent.addEventListener('recycling-game-end', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('recycling-game-success', (e) => {
......
......@@ -45,6 +45,6 @@
<script src="load-assets.js"></script>
<script src="main.js"></script>
<script>
localStorage.clear()
// localStorage.clear()
</script>
</body>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
......@@ -74,10 +74,13 @@
"recycling-start": {
"alias": "开始",
"data": {
"picUrl": "图片路径",
"blockUrl": "blockUrl"
"time": "游戏时间"
}
},
"recycling-end": {
"alias": "游戏结束",
"data": {}
},
"recycling-stop": {
"alias": "停止"
}
......@@ -89,12 +92,16 @@
"time": "剩余时间"
}
},
"recycling-game-fail": {
"alias": "游戏结束",
"recycling-score-update": {
"alias": "分数更新",
"data": {
"reason": "结束原因(1:时间到了)"
"score": "分数"
}
},
"recycling-game-end": {
"alias": "游戏结束",
"data": {}
},
"recycling-game-success": {
"alias": "游戏成功",
"data": {
......
......@@ -4,15 +4,16 @@
import { getTextureByName } from "../../../recycling/src/game/utils";
import { props } from "../props";
import uiConfig from "./uiConfig";
import Conveyor from "./Conveyor";
import CountDownGroup from "./views/CountDownGroup";
import uiConfig from "./uiConfig";
import getGuideInfo, { setGuide } from "./utils/getGuideInfo";
import CountDownGroup from "./views/CountDownGroup";
import GuideView from "./views/guideView";
export default class GameView extends engine.Container {
private _timer;
private _timeCounter = 0;
score = 0;
uiMap: any;
wetWaste: engine.Rectangle;
harmfulWaste: engine.Rectangle;
......@@ -69,7 +70,7 @@ export default class GameView extends engine.Container {
this.recoverableWaste = this.createRect(389, 551, 287, 292, 0x0000ff);
}
createRect(x, y, w, h,c) {
createRect(x, y, w, h, c) {
const rect = new engine.Rectangle(x, y, w, h);
const sp = new engine.Sprite();
......@@ -78,7 +79,7 @@ export default class GameView extends engine.Container {
sp.y = y;
const g = new engine.Graphics;
g.alpha=0.0;
g.alpha = 0.0;
g.beginFill(c);
g.drawRect(0, 0, w, h);
g.endFill();
......@@ -111,8 +112,10 @@ export default class GameView extends engine.Container {
}
async start() {
console.log('on start')
this._timeCounter = 0;
if(!getGuideInfo()) {
if (!getGuideInfo()) {
await this.guide.startGuide();
setGuide();
}
......@@ -121,7 +124,6 @@ export default class GameView extends engine.Container {
this.playAni();
console.log('on start')
engine.globalEvent.dispatchEvent('recycling-time-update', {
second: this.getSecond(),
......@@ -132,25 +134,25 @@ export default class GameView extends engine.Container {
}, 1000)
}
getSecond() { return 0 }
getSecond() {
return props.time - this._timeCounter
}
onTimer() {
this._timeCounter++;
engine.globalEvent.dispatchEvent('recycling-time-update', {
second: this.getSecond(),
});
if (this.getSecond() == 0) {
// GAME_TIME = props.GAME_TIME
this.stop();
engine.globalEvent.dispatchEvent('recycling-game-fail', {
reason: 1
});
engine.globalEvent.dispatchEvent('recycling-game-end', { });
}
}
stop() {
clearInterval(this._timer);
}
setup() {
......
......@@ -36,11 +36,11 @@ export default class CountDownGroup extends engine.Sprite {
this.addChild(this.num3)
this.addChild(this.go)
this.visible = false;
this.reset();
}
private reset() {
this.visible = false;
this.go.alpha = this.num1.alpha = this.num2.alpha = this.num3.alpha = 0;
this.go.scaleX = this.num1.scaleX = this.num2.scaleX = this.num3.scaleX = 3;
this.go.scaleY = this.num1.scaleY = this.num2.scaleY = this.num3.scaleY = 3;
......@@ -48,7 +48,7 @@ export default class CountDownGroup extends engine.Sprite {
async startCountDown() {
return new Promise((r) => {
this.reset();
this.visible = true;
this.num3.alpha = 1;
......
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