Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
middleLayer_for_kyxq
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
middleLayer_for_kyxq
Commits
4a07559d
Commit
4a07559d
authored
Nov 13, 2023
by
李维
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复关卡结束跳转错误
parent
bf385f91
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
167 additions
and
168 deletions
+167
-168
middleLayer_for_kyxq.fire
assets/middleLayer_for_kyxq/scene/middleLayer_for_kyxq.fire
+4
-4
LessonPreview.ts
assets/middleLayer_for_kyxq/script/LessonPreview.ts
+55
-42
MissionPage.ts
assets/middleLayer_for_kyxq/script/MissionPage.ts
+3
-3
UnitPage.ts
assets/middleLayer_for_kyxq/script/UnitPage.ts
+5
-2
middleLayer.ts
assets/middleLayer_for_kyxq/script/middleLayer.ts
+100
-117
No files found.
assets/middleLayer_for_kyxq/scene/middleLayer_for_kyxq.fire
View file @
4a07559d
...
...
@@ -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,
...
...
assets/middleLayer_for_kyxq/script/LessonPreview.ts
View file @
4a07559d
...
...
@@ -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
;
}
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
.
playAudioId
=
null
this
.
isAudioPlaying
=
false
;
});
})
}
}
}
}
assets/middleLayer_for_kyxq/script/MissionPage.ts
View file @
4a07559d
...
...
@@ -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
'
;
}
}
}
...
...
assets/middleLayer_for_kyxq/script/UnitPage.ts
View file @
4a07559d
...
...
@@ -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
);
if
(
picLayer
)
{
picLayer
.
addChild
(
sprNode
);
setSprNodeMaxLen
(
sprNode
,
picLayer
.
width
,
picLayer
.
height
,
true
);
}
})
// 课程完成状态指示
...
...
assets/middleLayer_for_kyxq/script/middleLayer.ts
View file @
4a07559d
...
...
@@ -31,11 +31,11 @@ export default class MiddleLayerClass extends middleLayerBase {
doHeart
()
{
const
token
=
cc
.
sys
.
localStorage
.
getItem
(
'
token
'
);
const
engine_uuid
=
this
.
ENGINE_INFO
?
this
.
ENGINE_INFO
.
uuid
:
""
;
this
.
callNetworkApiGet
(
`/api/kyxq/v1/heart`
,
{
token
,
engine_uuid
},
()
=>
{
const
engine_uuid
=
this
.
ENGINE_INFO
?
this
.
ENGINE_INFO
.
uuid
:
""
;
this
.
callNetworkApiGet
(
`/api/kyxq/v1/heart`
,
{
token
,
engine_uuid
},
()
=>
{
// 心跳结果,暂时不做任何处理
});
this
.
scheduleOnce
(()
=>
{
this
.
scheduleOnce
(()
=>
{
this
.
doHeart
();
},
5
);
}
...
...
@@ -47,7 +47,7 @@ export default class MiddleLayerClass extends middleLayerBase {
});
if
(
data
&&
data
==
true
)
{
(
<
any
>
window
).
courseware
.
logUpload
(
async
(
res
)
=>
{
const
{
fileUrl
,
error
}
=
JSON
.
parse
(
res
);
const
{
fileUrl
,
error
}
=
JSON
.
parse
(
res
);
if
(
fileUrl
)
{
await
this
.
asyncCallNetworkApiPost
(
"
/api/application/v1/engine/report
"
,
{
engineid
:
this
.
ENGINE_INFO
.
uuid
,
...
...
@@ -57,7 +57,7 @@ export default class MiddleLayerClass extends middleLayerBase {
}
});
}
this
.
scheduleOnce
(()
=>
{
this
.
scheduleOnce
(()
=>
{
this
.
navLogCaller
();
},
5
);
}
...
...
@@ -68,7 +68,7 @@ export default class MiddleLayerClass extends middleLayerBase {
this
.
initListener
();
this
.
doHeart
();
this
.
scheduleOnce
(()
=>
{
this
.
scheduleOnce
(()
=>
{
// 启动日志召回监听服务
this
.
navLogCaller
();
},
5
);
...
...
@@ -76,7 +76,7 @@ export default class MiddleLayerClass extends middleLayerBase {
try
{
// 有些壳上没有提供这个方法,所以处理一下异常
this
.
onMiddleLayerLoadingFinish
();
// 这个是用来隐藏原生端启动页的方法,酌情在适当的地方调用
}
catch
(
error
)
{}
}
catch
(
error
)
{
}
// setTimeout(() => {
// this.showFinish();
// }, 2000);
...
...
@@ -102,8 +102,8 @@ export default class MiddleLayerClass extends middleLayerBase {
});
}
saveEnd
(
callback
){
if
(
this
.
courseIndex
<
this
.
courses
.
length
-
1
)
{
saveEnd
(
callback
)
{
if
(
this
.
courseIndex
<
this
.
courses
.
length
-
1
)
{
callback
&&
callback
();
return
;
}
...
...
@@ -132,7 +132,7 @@ export default class MiddleLayerClass extends middleLayerBase {
onHomeworkFinish
(
d1
=
null
,
d2
=
null
)
{
let
data
=
null
;
let
callback
=
null
;
if
(
typeof
(
d1
)
==
'
function
'
)
{
if
(
typeof
(
d1
)
==
'
function
'
)
{
data
=
d2
;
callback
=
d1
;
}
else
{
...
...
@@ -220,11 +220,11 @@ export default class MiddleLayerClass extends middleLayerBase {
}
getPageInfo
()
{
return
{
length
:
this
.
courses
.
length
,
index
:
this
.
courseIndex
};
return
{
length
:
this
.
courses
.
length
,
index
:
this
.
courseIndex
};
}
golds
=
null
;
saveGolds
(
gold
:
Number
=
0
)
{
saveGolds
(
gold
:
Number
=
0
)
{
if
(
!
this
.
golds
)
{
this
.
golds
=
{
total
:
0
...
...
@@ -239,31 +239,22 @@ export default class MiddleLayerClass extends middleLayerBase {
}
goNextPage
()
{
console
.
log
(
this
.
courseIndex
)
console
.
log
(
this
.
courses
.
length
)
console
.
log
(
"
this.crossArray
"
,
JSON
.
stringify
(
this
.
crossArray
))
if
(
this
.
courseIndex
<
this
.
courses
.
length
-
1
)
{
if
(
this
.
courseIndex
<
this
.
courses
.
length
-
1
)
{
// 单页完成的庆祝画面
this
.
showGold
(()
=>
{
this
.
goTarIndexPage
(
this
.
courseIndex
+
1
);
});
}
else
if
(
this
.
courseIndex
>=
this
.
courses
.
length
){
const
lastCurse
=
this
.
crossArray
[
this
.
crossArray
.
length
-
1
];
console
.
log
(
"
KK
"
,
this
.
courseItem
.
course_id
,
lastCurse
.
id
)
}
else
{
const
lastCurse
=
this
.
crossArray
[
this
.
crossArray
.
length
-
1
];
if
(
this
.
courseItem
.
course_id
!=
lastCurse
.
id
)
{
console
.
log
(
"
showFinish
"
)
// 课件完成的庆祝画面
this
.
showFinish
();
// 上报解锁下一关
const
currentIndex
=
this
.
crossArray
.
findIndex
(
item
=>
item
.
id
==
this
.
courseItem
.
course_id
);
const
nextCourse
=
this
.
crossArray
[
currentIndex
+
1
];
console
.
log
(
"
currentIndex
"
,
currentIndex
)
console
.
log
(
"
nextCourse
"
,
nextCourse
)
console
.
log
(
"
nextCourse.id
"
,
nextCourse
.
id
)
this
.
unlockNext
(
nextCourse
.
id
);
}
else
{
// 所有课件都完成的庆祝动画
console
.
log
(
"
showAllFinish
"
)
this
.
showAllFinish
();
// 上报一个本节课完成
this
.
callNetworkApiPost
(
`/api/kyxq/v1/user/saveend`
,
{
...
...
@@ -282,8 +273,8 @@ export default class MiddleLayerClass extends middleLayerBase {
goNextCross
()
{
const
currentid
=
this
.
courseItem
.
course_id
;
const
currentIndex
=
this
.
crossArray
.
findIndex
(
item
=>
item
.
id
==
this
.
courseItem
.
course_id
);
if
(
currentIndex
!=-
1
&&
this
.
crossArray
[
currentIndex
+
1
])
{
this
.
loadOnlineCourseWare
(
this
.
crossArray
[
currentIndex
+
1
].
id
,
null
,
null
);
if
(
currentIndex
!=
-
1
&&
this
.
crossArray
[
currentIndex
+
1
])
{
this
.
loadOnlineCourseWare
(
this
.
crossArray
[
currentIndex
+
1
].
id
,
null
,
null
);
}
else
{
this
.
showTips
(
`已经是最后一关了`
);
}
...
...
@@ -292,7 +283,6 @@ export default class MiddleLayerClass extends middleLayerBase {
}
async
showGold
(
cb
)
{
console
.
log
(
'
in showGold
'
)
const
goldAnim
=
cc
.
instantiate
(
cc
.
find
(
'
middleLayer/res/anim/finish1_ske
'
));
const
finishLayer
=
cc
.
find
(
"
middleLayer/finishLayer
"
);
goldAnim
.
active
=
true
;
...
...
@@ -300,18 +290,15 @@ export default class MiddleLayerClass extends middleLayerBase {
finishLayer
.
active
=
true
;
appearAnim
(
finishLayer
,
0.3
);
console
.
log
(
'
goldAnim:
'
,
goldAnim
);
await
asyncPlayDragonBoneAnimation
(
goldAnim
,
'
newAnimation
'
,
1
,
null
);
goldAnim
.
active
=
false
;
finishLayer
.
active
=
false
;
finishLayer
.
removeAllChildren
()
cb
&&
cb
();
cb
&&
cb
();
}
async
showFinish
()
{
console
.
log
(
'
in showFinish
'
)
const
finishAnim
=
cc
.
instantiate
(
cc
.
find
(
'
middleLayer/res/anim/finish2_ske
'
));
finishAnim
.
active
=
true
;
...
...
@@ -322,34 +309,31 @@ export default class MiddleLayerClass extends middleLayerBase {
await
asyncPlayDragonBoneAnimation
(
finishAnim
,
'
newAnimation
'
,
1
,
null
);
const
replayBtn
=
cc
.
find
(
'
middleLayer/res/img/btn_replay
'
);
replayBtn
.
parent
=
finishLayer
replayBtn
.
parent
=
finishLayer
const
nextBtn
=
cc
.
find
(
'
middleLayer/res/img/btn_next
'
);
nextBtn
.
parent
=
finishLayer
nextBtn
.
parent
=
finishLayer
const
hideFinish
=
()
=>
{
nextBtn
.
parent
=
cc
.
find
(
"
middleLayer/res/img
"
)
replayBtn
.
parent
=
cc
.
find
(
"
middleLayer/res/img
"
)
const
hideFinish
=
()
=>
{
nextBtn
.
parent
=
cc
.
find
(
"
middleLayer/res/img
"
)
replayBtn
.
parent
=
cc
.
find
(
"
middleLayer/res/img
"
)
finishLayer
.
removeChild
(
finishAnim
);
finishLayer
.
active
=
false
;
}
replayBtn
.
on
(
'
touchstart
'
,
()
=>
{
console
.
log
(
"
replayBtn
"
)
replayBtn
.
on
(
'
touchstart
'
,
()
=>
{
hideFinish
();
this
.
loadOnlineCourseWare
(
this
.
courseItem
.
course_id
,
null
,
null
);
})
nextBtn
.
on
(
"
touchstart
"
,
()
=>
{
console
.
log
(
"
nextBtn
"
)
hideFinish
();
this
.
goNextCross
();
})
}
async
showAllFinish
()
{
console
.
log
(
'
in showAllFinish
'
)
const
finishAnim
=
cc
.
instantiate
(
cc
.
find
(
'
middleLayer/res/anim/allfinish_ske
'
));
finishAnim
.
active
=
true
;
...
...
@@ -360,16 +344,15 @@ export default class MiddleLayerClass extends middleLayerBase {
await
asyncPlayDragonBoneAnimation
(
finishAnim
,
'
newAnimation
'
,
1
,
null
);
const
exitBtn
=
cc
.
find
(
'
middleLayer/res/img/btn_x
'
);
exitBtn
.
parent
=
finishLayer
exitBtn
.
parent
=
finishLayer
const
hideFinish
=
()
=>
{
exitBtn
.
parent
=
cc
.
find
(
"
middleLayer/res/img
"
)
const
hideFinish
=
()
=>
{
exitBtn
.
parent
=
cc
.
find
(
"
middleLayer/res/img
"
)
finishLayer
.
removeChild
(
finishAnim
);
finishLayer
.
active
=
false
;
}
exitBtn
.
on
(
"
touchstart
"
,
()
=>
{
console
.
log
(
"
exitBtn
"
)
hideFinish
();
this
.
exitGame
()
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment