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

修复关卡结束跳转错误

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