Commit 71e821d8 authored by 李维's avatar 李维

添加中间层返回按钮

parent 5bcec6f2
......@@ -267,13 +267,13 @@ export default class NewClass extends cc.Component {
this.show(defaultText);
})
// 设置点击背景遮罩层的回调
this.maskBg.on("click", ()=>{
if(this.sysKeyboard) {
const editBox = cc.find("textEditBox", this.editBoxContainer);
editBox.getComponent(cc.EditBox).focus()
}
})
// 设置点击背景遮罩层的回调 - 用户偶儿误触 暂时禁用这段逻辑
// this.maskBg.on("click", ()=>{
// if(this.sysKeyboard) {
// const editBox = cc.find("textEditBox", this.editBoxContainer);
// editBox.getComponent(cc.EditBox).focus()
// }
// })
}
// 注册软键盘事件
......
This diff is collapsed.
......@@ -57,11 +57,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
async onLoadEnd() {
// TODO 加载完成后的逻辑写在这里
console.log(this.data);
this.initSize();
this.initEventListener();
this.initHeaderAndFooter();
await this.initHotZoneBg();
this.initHotZoneItem();
this.initSize(); // 页面尺寸
this.initMiddleLayer(); // 中间层相关
this.initEventListener(); // 事件监听
this.initHeaderAndFooter(); // 顶部和底部图片
await this.initHotZoneBg(); // 初始化背景
this.initHotZoneItem(); // 初始化热区数据
this.initScorePanel();
this.initActionButton();
this.initScoreShow();
......@@ -141,6 +142,30 @@ export default class SceneComponent extends MyCocosSceneComponent {
})
}
_middleLayer;
initMiddleLayer() {
this._middleLayer = cc.find('middleLayer')?.getComponent('middleLayer');
if (!this._middleLayer) {
this._middleLayer = console;
}
else {
this._middleLayer.log("获取到middleLayer");
}
let back = cc.find("Canvas/backBtn");
back.on('click', () => {
this._middleLayer.log("exit game")
const middleLayer = cc.find('middleLayer')?.getComponent('middleLayer');
if (middleLayer) {
middleLayer.log('exit game');
// 有些模板需要在返回时上报数据,直接把数据作为参数传入就可以了
middleLayer.exitGame(this.resultData == null ? this.resultData = null : {});
} else {
console.log("==触发返回事件==");
}
})
}
// 初始化头部和底部图片
initHeaderAndFooter() {
const headerNode = cc.find("Canvas/Header");
......@@ -1908,6 +1933,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 提交试卷
submitted = false;
// 游戏成绩数据
resultData = null;
submit() {
const resultData = {
details: [],
......@@ -1920,7 +1947,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
resultData.scoreCconfigArr.push(item);
});
this.scoreValidater.forEach(validater => {
if(validater) {
// 返回一个校验集合
......@@ -1990,7 +2016,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
})
resultData.totalScore = totalScore;
this.resultData = resultData;
console.log("答案校验完毕", resultData)
this.showEndScore(resultData.totalScore)
......@@ -2027,7 +2053,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.allConnectionEndPoints = [];
this.totalScorePanel = null;
this.allCrosswordData = {};
// 停止当前正在播放的音乐
if(this.currentAudioPlay) {
cc.audioEngine.stop(this.currentAudioPlay);
......
{
"ver": "2.3.5",
"uuid": "a897884a-119f-4ca8-82bf-25bd4202ba91",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 131,
"height": 131,
"platformSettings": {},
"subMetas": {
"btn_return": {
"ver": "1.0.4",
"uuid": "57778522-3a96-439a-88f3-7cd4b2f6e675",
"rawTextureUuid": "a897884a-119f-4ca8-82bf-25bd4202ba91",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 131,
"height": 131,
"rawWidth": 131,
"rawHeight": 131,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
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