Commit 19692b24 authored by Friends233's avatar Friends233

修改游戏定时器

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