Commit 19692b24 authored by Friends233's avatar Friends233

修改游戏定时器

parent 561ced30
......@@ -149,7 +149,7 @@ export default class GameScene extends cc.Component {
/** 目标数量 */
num: 1,
/** 倒计时 */
cds: 50,
cds: 3,
},
{
level: 1,
......@@ -186,7 +186,10 @@ export default class GameScene extends cc.Component {
this.isStartGame = true
cc.find('clipMask/clipWrp', this.node).getComponent(cc.Animation).play()
// this.schedule(this.startCd, 1)
this.timer = setInterval(() => this.startCd(), 1000)
clearTimeout(this.timer)
this.timer = setTimeout(() => {
this.startCd()
}, 1000)
})
}
......@@ -303,8 +306,8 @@ export default class GameScene extends cc.Component {
gameOver() {
this.isGameOver = true
this.setClipState(CLIP_STATE.GAME_OVER)
this.unschedule(this.startCd)
window.clearInterval(this.timer)
// this.unschedule(this.startCd)
window.clearTimeout(this.timer)
exportEvent.fire(CUSTOM_EVENT.GAME_OVER, {
...this.gameConfig.LevelInfo[this.actLevel],
score: this.starNum,
......@@ -326,17 +329,21 @@ export default class GameScene extends cc.Component {
if (!cd || cd <= 0) {
this.setLable('cdIcon/cd', `0s`)
this.gameOver()
this.unschedule(this.startCd)
window.clearInterval(this.timer)
// this.unschedule(this.startCd)
window.clearTimeout(this.timer)
return
}
this.countDown = cd
this.setLable('cdIcon/cd', `${this.countDown}s`)
clearTimeout(this.timer)
this.timer = setTimeout(() => {
this.startCd()
}, 1000);
}
protected onDestroy(): void {
this.unschedule(this.startCd)
window.clearInterval(this.timer)
// this.unschedule(this.startCd)
window.clearTimeout(this.timer)
}
/** 刷新关卡信息 */
......@@ -357,8 +364,8 @@ export default class GameScene extends cc.Component {
this.updateGameProc()
this.unschedule(this.startCd)
window.clearInterval(this.timer)
// this.unschedule(this.startCd)
window.clearTimeout(this.timer)
this.setLable('cdIcon/cd', `${this.countDown}s`)
}
......@@ -378,8 +385,8 @@ export default class GameScene extends cc.Component {
// 达到目标
if (this.starNum >= this.levelObjectives) {
this.isStartGame = false
this.unschedule(this.startCd)
window.clearInterval(this.timer)
// this.unschedule(this.startCd)
window.clearTimeout(this.timer)
exportEvent.fire(CUSTOM_EVENT.PASS_LEVEL, {
...this.gameConfig.LevelInfo[this.actLevel],
score: this.starNum,
......@@ -393,8 +400,8 @@ export default class GameScene extends cc.Component {
nextLevel() {
const nextLevel = this.actLevel + 1
this.isStartGame = true
this.unschedule(this.startCd)
window.clearInterval(this.timer)
// this.unschedule(this.startCd)
window.clearTimeout(this.timer)
if (nextLevel >= this.gameConfig.LevelInfo.length) { // 已通关
this.gameOver()
return
......@@ -402,7 +409,10 @@ export default class GameScene extends cc.Component {
this.refreshLevelInfo(nextLevel)
this.refreshStageProps()
// this.schedule(this.startCd, 1)
this.timer = setInterval(() => this.startCd(), 1000)
clearTimeout(this.timer)
this.timer = setTimeout(() => {
this.startCd()
}, 1000)
}
/** 更新游戏进度条信息 */
......
This diff is collapsed.
......@@ -40,7 +40,7 @@
<!-- <script src="//yun.duiba.com.cn/db_games/libs0924/svgaParser.minWeb.js" crossorigin="anonymous"></script>-->
<link rel="stylesheet" type="text/css" href="https://yun.duiba.com.cn/db_games/ccc_game/template/1681898392442/style-mobile.css"/>
<link rel="stylesheet" type="text/css" href="https://yun.duiba.com.cn/db_games/ccc_game/template/1682301770504/style-mobile.css"/>
<style>
......@@ -90,9 +90,9 @@
</div>
</div>
<script src="https://yun.duiba.com.cn/db_games/ccc_game/template/1681898392442/src/settings.js" charset="utf-8"></script>
<script src="https://yun.duiba.com.cn/db_games/ccc_game/template/1682301770504/src/settings.js" charset="utf-8"></script>
<script src="https://yun.duiba.com.cn/db_games/ccc_game/template/1681898392442/main.js" charset="utf-8"></script>
<script src="https://yun.duiba.com.cn/db_games/ccc_game/template/1682301770504/main.js" charset="utf-8"></script>
<script type="text/javascript">
(function () {
......
window.__remoteUrl__ = "https://yun.duiba.com.cn/db_games/ccc_game/template/1681898392442/";
window.__remoteUrl__ = "https://yun.duiba.com.cn/db_games/ccc_game/template/1682301770504/";
window.__remoteAssets__ = window.__remoteUrl__ + "assets/";
window.__version__ = 1681898392442;
window.__version__ = 1682301770504;
window.__ENV__ = "prod";
window.boot = function () {
......
......@@ -49,7 +49,7 @@
"width": 960,
"height": 640
},
"last-module-event-record-time": 1681469884076,
"last-module-event-record-time": 1682239993727,
"assets-sort-type": "name",
"facebook": {
"enable": false,
......
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