Commit d2093c22 authored by Master Q's avatar Master Q

注意闭包导致的 变量引用出错

parent 4980dee1
......@@ -716,5 +716,5 @@ export const ResJson = {
}
],
// eslint-disable-next-line
"path": "https://yun.duiba.com.cn/db_games/activity/template/1670224643/resource/"
"path": "https://yun.duiba.com.cn/db_games/activity/template/1670242040/resource/"
}
\ No newline at end of file
import { destroyLayers, layers } from "./modules/layers";
import { SceneController } from "./modules/layers/ctrls";
import { ModalCtroller } from "./modules/ModalControl";
import { RES } from "./modules/RES";
import { ResJson } from "./ResJson";
import { GameScene } from "./scenes/GameScene/GameScene";
......@@ -20,6 +21,7 @@ import getEnv = FYGE.getEnv;
export const GDispatcher = new EventDispatcher();
export const loadAllGroups = async function() {
RES.loadConfig(ResJson)
await RES.loadAllGroup()
}
......@@ -188,7 +190,10 @@ export class Main {
this.stage.destroy();
// 全局事件置空
// GDispatcher.removeAllEventListener();
GDispatcher.removeAllEventListener();
// 晴空下
ModalCtroller.clearModalMap()
// 淘宝环境网络数据记录清
// destroyTbNetData();
......
......@@ -190,9 +190,18 @@ export const ModalCtroller = (function() {
(_.ModalContainer as FYGE.Container).destroy();
ModalMap.delete(ModalNode)
}
console.log('closeModal config:', _.props._config, ModalMap)
return
}
},
closeAllModal() {
ModalMap.forEach(item => {
item.closeModal && item.closeModal()
})
},
clearModalMap() {
ModalMap.clear()
}
}
})()
\ No newline at end of file
......@@ -74,14 +74,13 @@ export const SceneController = (function() {
let preScene: SceneCompent // 之前一个场景的
return {
init(cont: FYGE.Container) {
if (!controller) {
controller = cont
}
controller = cont
},
destroyScene(scene: SceneCompent) {
scene.destroy()
},
changeScene(SceneNode: any, props?: Record<string, any>) {
console.log('controller===', controller)
if (!controller) {
throw new Error('没有场景controller')
}
......
......@@ -50,6 +50,8 @@ export class GameResumeModal extends Dream.RenderContainer<{
* 确认走复活逻辑
*/
onConfirm = async () => {
clearInterval(this.intervalId)
const {
success
} = await sendTbNet(TbNetName.reduceTools)
......
......@@ -47,7 +47,7 @@ export const GameConfig = {
boxConfig: {
[BoxType.Box1]: {
resName: 'box1.png',
addScore: 5,
addScore: 4,
oc: {
x: 142, y: 230 // 判断中心点
},
......@@ -67,7 +67,7 @@ export const GameConfig = {
},
[BoxType.Box3]: {
resName: 'box3.png',
addScore: 5,
addScore: 6,
oc: {
x: 142, y: 230
},
......@@ -77,7 +77,7 @@ export const GameConfig = {
},
[BoxType.Box4]: {
resName: 'box4.png',
addScore: 5,
addScore: 8,
oc: {
x: 142, y: 250
},
......@@ -87,7 +87,7 @@ export const GameConfig = {
},
[BoxType.Box5]: {
resName: 'box5.png',
addScore: 5,
addScore: 10,
oc: {
x: 142, y: 260
},
......@@ -97,7 +97,7 @@ export const GameConfig = {
},
[BoxType.Box6]: {
resName: 'box6.png',
addScore: 5,
addScore: 1,
oc: {
x: 142, y: 230
},
......@@ -107,7 +107,7 @@ export const GameConfig = {
},
[BoxType.Box7]: {
resName: 'box7.png',
addScore: 5,
addScore: 15,
oc: {
x: 142, y: 360
},
......@@ -117,7 +117,7 @@ export const GameConfig = {
},
[BoxType.Box8]: {
resName: 'box8.png',
addScore: 5,
addScore: 15,
oc: {
x: 142, y: 360
},
......
......@@ -258,7 +258,7 @@ export class GameScene extends Dream.RenderContainer {
offsetY: py,
maxH: mh
})
console.log('jumpEnd')
console.log('jumpEnd:', _i)
if (_i == 3) {
this.onJumpSuc()
} else if (_i == 2 || _i == -1) {
......@@ -267,6 +267,7 @@ export class GameScene extends Dream.RenderContainer {
}
onJumpSuc() {
console.log('onJumpSuc')
if (this.isWithGift) {
this.DecisionConfig.geleIns.onGetGift()
this.isDrawed = true
......@@ -281,6 +282,7 @@ export class GameScene extends Dream.RenderContainer {
onGameOver() {
this.isOver = true
let f = Tools.PageData.liveCard
console.log('GameOver')
if (f && !this.isUsed) {
ModalCtroller.showModal(GameResumeModal, {
resumeNum: Tools.PageData.liveCard,
......@@ -335,6 +337,9 @@ export class GameScene extends Dream.RenderContainer {
}
onShowGameOverModal = async () => {
if (this.isDrawed) {
await this.onDraw()
}
const submitScore = this.ScoreBoardIns.score
const {
success
......@@ -342,9 +347,6 @@ export class GameScene extends Dream.RenderContainer {
score: submitScore
})
if (success) {
if (this.isDrawed) {
await this.onDraw()
}
ModalCtroller.showModal(GameOverModal, {
......@@ -591,6 +593,7 @@ export class GameScene extends Dream.RenderContainer {
render() {
const bottomAtomRes = RES.getRes('bottomAtom.png')
console.log('render GameScene')
return (
<FYGE.Container>
......
......@@ -47,7 +47,7 @@ export class NewGuyScene extends Dream.RenderContainer {
}
const mapName = Object.keys(posMap)
this.GuideContainer.addChild(
<DreamContainer>
<DreamContainer onClick={nextStep}>
<DreamShape alpha={0.7} />
<DreamContainer inlineProps={{
......@@ -78,7 +78,7 @@ export class NewGuyScene extends Dream.RenderContainer {
y: 1100
}} text="踩到特殊格子 可获得额外得分" color="#ffffff" textWidth={750} size={32} />
<DreamSprite onClick={nextStep} inlineProps={{
<DreamSprite inlineProps={{
x: 375 - n.width / 2,
y: 1200
}} src={n} />
......@@ -88,7 +88,7 @@ export class NewGuyScene extends Dream.RenderContainer {
case 3:
const btn = RES.getRes('startGameBtn.png')
this.GuideContainer.addChild(
<DreamContainer>
<DreamContainer onClick={nextStep}>
<DreamShape alpha={0.7} />
<DreamTextField text="踩到特殊道具" color="#ffffff" size={fontSize} textWidth={750} inlineProps={{
......@@ -98,7 +98,7 @@ export class NewGuyScene extends Dream.RenderContainer {
y: 770
}} />
<DreamSprite src={btn} onClick={nextStep} inlineProps={{
<DreamSprite src={btn} inlineProps={{
x: 375 - btn.width / 2,
y: 850
}} />
......
// @ts-ignore
const app = typeof getApp == 'function' && getApp()
const audioIns = app?.audioContext
if (audioIns) {
audioIns.onPlay(() => {
console.log('播放')
})
audioIns.onError(() => {
console.log('audio error')
})
}
export function PlayAudio() {
console.log('app =====', app)
// @ts-ignore
const app = typeof getApp == 'function' && getApp()
const audioIns = app?.audioContext
if (audioIns) {
audioIns.onPlay(() => {
console.log('播放')
})
audioIns.onError(() => {
console.log('audio error')
})
}
audioIns && audioIns.play()
}
......
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