Commit 4a07559d authored by 李维's avatar 李维

修复关卡结束跳转错误

parent bf385f91
...@@ -24065,8 +24065,8 @@ ...@@ -24065,8 +24065,8 @@
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_string": "内容", "_string": "内容",
"_N$string": "内容", "_N$string": "内容",
"_fontSize": 36, "_fontSize": 42,
"_lineHeight": 40, "_lineHeight": 58,
"_enableWrapText": true, "_enableWrapText": true,
"_N$file": { "_N$file": {
"__uuid__": "86a73b35-ea84-4acf-83dc-d18b68083b2e" "__uuid__": "86a73b35-ea84-4acf-83dc-d18b68083b2e"
...@@ -24329,8 +24329,8 @@ ...@@ -24329,8 +24329,8 @@
], ],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_string": "故事梗概", "_string": "",
"_N$string": "故事梗概", "_N$string": "",
"_fontSize": 38, "_fontSize": 38,
"_lineHeight": 38, "_lineHeight": 38,
"_enableWrapText": true, "_enableWrapText": true,
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks: // Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import {playAudioByUrl, getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, asyncDelay } from "./util"; import { playAudioByUrl, getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, asyncDelay } from "./util";
const {ccclass, property} = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class LessonPreviewClass extends cc.Component { export default class LessonPreviewClass extends cc.Component {
...@@ -31,76 +31,89 @@ export default class LessonPreviewClass extends cc.Component { ...@@ -31,76 +31,89 @@ export default class LessonPreviewClass extends cc.Component {
@property(cc.Label) @property(cc.Label)
lblAudio: cc.Label = null; lblAudio: cc.Label = null;
onClickClose(){ onClickClose() {
this.audio_url=null this.audio_url = null
if (this.playAudioId!=null) cc.audioEngine.stop(this.playAudioId) if (this.playAudioId != null) cc.audioEngine.stop(this.playAudioId)
this.isAudioPlaying=false this.isAudioPlaying = false
this.node.active=false this.node.active = false
} }
data data
curPageIndex=0 curPageIndex = 0
setData(data){ setData(data) {
this.data=data this.data = data
} }
refreshUI(){ refreshUI() {
if(!this.data) return if (!this.data) return
let _data = this.data[this.curPageIndex] let _data = this.data[this.curPageIndex]
if(!_data) return if (!_data) return
if (_data.sub_title) this.lessonTitle.string=_data.sub_title if (_data.sub_title) this.lessonTitle.string = _data.sub_title
this.btn_last.active=this.curPageIndex>0 this.btn_last.active = this.curPageIndex > 0
this.btn_next.active=this.curPageIndex<(this.data.length-1) this.btn_next.active = this.curPageIndex < (this.data.length - 1)
getSprNodeByUrl(_data.image, (spr) => { getSprNodeByUrl(_data.image, (spr) => {
this.mask.addChild(spr.node); this.mask.addChild(spr.node);
spr.srcBlendFactor = cc.macro.BlendFactor.ONE spr.srcBlendFactor = cc.macro.BlendFactor.ONE
setSprNodeMaxLen(spr.node, this.mask.width, this.mask.height, true); setSprNodeMaxLen(spr.node, this.mask.width, this.mask.height, true);
}); });
this.pageLbl.string=`${this.curPageIndex+1}/${this.data.length}` this.pageLbl.string = `${this.curPageIndex + 1}/${this.data.length}`
this.strItem.string=_data.text this.strItem.string = _data.text
this.audio_url=_data.audio this.audio_url = _data.audio
this.lblAudio.string="——" this.lblAudio.string = ""
if (this.playAudioId!=null) cc.audioEngine.stop(this.playAudioId) if (this.playAudioId != null) cc.audioEngine.stop(this.playAudioId)
this.isAudioPlaying=false this.isAudioPlaying = false
if (_data.audio){ if (_data.audio) {
cc.assetManager.loadRemote(_data.audio, (err, audioClip:cc.AudioClip) => { cc.assetManager.loadRemote(_data.audio, (err, audioClip: cc.AudioClip) => {
if (audioClip){ if(audioClip.duration === undefined) {
this.lblAudio.string=String(Math.floor(audioClip.duration)) const audioId = cc.audioEngine.play(audioClip, false, 0);
setTimeout(() => {
audioClip.duration = cc.audioEngine.getDuration(audioId)
cc.audioEngine.pause(audioId)
this.lblAudio.string = String(Math.floor(audioClip.duration))
}, 50);
} else {
this.lblAudio.string = String(Math.floor(audioClip.duration))
} }
}); });
} }
} }
onClickLeft(){ onClickLeft() {
if (this.curPageIndex>0) this.curPageIndex-- if (this.curPageIndex > 0) this.curPageIndex--
this.refreshUI() this.refreshUI()
} }
onClickRight(){ onClickRight() {
if (!this.data) return if (!this.data) return
if (this.curPageIndex<this.data.length) this.curPageIndex++ if (this.curPageIndex < this.data.length) this.curPageIndex++
this.refreshUI() this.refreshUI()
} }
isAudioPlaying=false isAudioPlaying = false
audio_url audio_url
playAudioId playAudioId
onClickAudio(){ onClickAudio() {
if (this.isAudioPlaying && this.audio_url) { if (!this.audio_url) {
return; return;
} }
this.isAudioPlaying = true;
if (this.audio_url) { if(this.isAudioPlaying) {
cc.assetManager.loadRemote(this.audio_url, (err, audioClip) => { cc.audioEngine.stop(this.playAudioId);
this.playAudioId = cc.audioEngine.play(audioClip, false, 0.8); this.isAudioPlaying = false;
cc.audioEngine.setFinishCallback(this.playAudioId, () => { } else {
this.playAudioId=null this.isAudioPlaying = true;
this.isAudioPlaying = false; if (this.audio_url) {
}); cc.assetManager.loadRemote(this.audio_url, (err, audioClip) => {
}) this.playAudioId = cc.audioEngine.play(audioClip, false, 0.8);
cc.audioEngine.setFinishCallback(this.playAudioId, () => {
this.playAudioId = null
this.isAudioPlaying = false;
});
})
}
} }
} }
} }
...@@ -102,7 +102,7 @@ export default class MissionPageClass extends PageComponentBaseClass { ...@@ -102,7 +102,7 @@ export default class MissionPageClass extends PageComponentBaseClass {
} }
async onDisable() { async onDisable() {
global.middleLayer.crossArray = []; // global.middleLayer.crossArray = [];
} }
initBg() { initBg() {
...@@ -178,8 +178,8 @@ export default class MissionPageClass extends PageComponentBaseClass { ...@@ -178,8 +178,8 @@ export default class MissionPageClass extends PageComponentBaseClass {
const { rows } = await asyncCallNetworkApiGet(`/api/kyxq/v1/user/syllabus/status`, { syllabuses: syllabuses.join(",") }); const { rows } = await asyncCallNetworkApiGet(`/api/kyxq/v1/user/syllabus/status`, { syllabuses: syllabuses.join(",") });
for (let i = 0; i < rows.length; i++) { for (let i = 0; i < rows.length; i++) {
const row = rows[i]; const row = rows[i];
if (syllabuses.includes(row.id)) { if (syllabuses.includes(row.syllabus_id)) {
this.syllabusLockStatusStore[row.id] = row.unlock == 0 ? 'locked' : 'unlock'; this.syllabusLockStatusStore[row.syllabus_id] = row.unlock == 0 ? 'locked' : 'unlock';
} }
} }
} }
......
...@@ -271,8 +271,11 @@ export default class UnitPageClass extends PageComponentBaseClass { ...@@ -271,8 +271,11 @@ export default class UnitPageClass extends PageComponentBaseClass {
getSprNodeByUrl(subData.cover, (spr) => { getSprNodeByUrl(subData.cover, (spr) => {
const sprNode = spr.node; const sprNode = spr.node;
const picLayer = cc.find("mask/pic_frame", subNode); const picLayer = cc.find("mask/pic_frame", subNode);
picLayer.addChild(sprNode); if(picLayer) {
setSprNodeMaxLen(sprNode, picLayer.width, picLayer.height, true); picLayer.addChild(sprNode);
setSprNodeMaxLen(sprNode, picLayer.width, picLayer.height, true);
}
}) })
// 课程完成状态指示 // 课程完成状态指示
......
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