Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
middleLayer_for_debug
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_debug
Commits
72c39c42
Commit
72c39c42
authored
May 16, 2022
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:
parent
d75d942f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
339 additions
and
300 deletions
+339
-300
middleLayer_for_debug.fire
...ts/middleLayer_for_debug/scene/middleLayer_for_debug.fire
+111
-135
middleLayer.ts
assets/middleLayer_for_debug/script/middleLayer.ts
+46
-129
middleLayerBase.ts
assets/middleLayer_for_debug/script/middleLayerBase.ts
+182
-36
No files found.
assets/middleLayer_for_debug/scene/middleLayer_for_debug.fire
View file @
72c39c42
...
@@ -308,15 +308,18 @@
...
@@ -308,15 +308,18 @@
},
},
{
{
"__id__": 199
"__id__": 199
},
{
"__id__": 207
}
}
],
],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 2
10
"__id__": 2
09
},
},
{
{
"__id__": 21
1
"__id__": 21
0
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -9787,9 +9790,6 @@
...
@@ -9787,9 +9790,6 @@
"_children": [
"_children": [
{
{
"__id__": 200
"__id__": 200
},
{
"__id__": 203
}
}
],
],
"_active": false,
"_active": false,
...
@@ -9842,122 +9842,6 @@
...
@@ -9842,122 +9842,6 @@
"groupIndex": 0,
"groupIndex": 0,
"_id": "74vmJ2zBBM+bb8ymP3WkKK"
"_id": "74vmJ2zBBM+bb8ymP3WkKK"
},
},
{
"__type__": "cc.Node",
"_name": "loading",
"_objFlags": 0,
"_parent": {
"__id__": 199
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 201
},
{
"__id__": 202
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 356,
"height": 356
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
77.611,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "0fJYDcOy9OJZm+wKj3Ekt6"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 200
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "d483699c-1f3a-44ed-880f-c0289a7e142b"
},
"_type": 0,
"_sizeMode": 2,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": false,
"_atlas": null,
"_id": "93t/fTMjdMu4k0cMv5Juki"
},
{
"__type__": "cc.Animation",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 200
},
"_enabled": true,
"_defaultClip": {
"__uuid__": "c01fcefa-a80e-43a2-8b03-cce500eba63d"
},
"_clips": [
{
"__uuid__": "c01fcefa-a80e-43a2-8b03-cce500eba63d"
}
],
"playOnLoad": false,
"_id": "ebVOOmcvVKzJ4jWjA0JjV9"
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "progress",
"_name": "progress",
...
@@ -9967,20 +9851,20 @@
...
@@ -9967,20 +9851,20 @@
},
},
"_children": [
"_children": [
{
{
"__id__": 20
4
"__id__": 20
1
}
}
],
],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 20
7
"__id__": 20
4
},
},
{
{
"__id__": 20
8
"__id__": 20
5
}
}
],
],
"_prefab": {
"_prefab": {
"__id__": 20
9
"__id__": 20
6
},
},
"_opacity": 255,
"_opacity": 255,
"_color": {
"_color": {
...
@@ -10034,17 +9918,17 @@
...
@@ -10034,17 +9918,17 @@
"_name": "bar",
"_name": "bar",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 20
3
"__id__": 20
0
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 20
5
"__id__": 20
2
}
}
],
],
"_prefab": {
"_prefab": {
"__id__": 20
6
"__id__": 20
3
},
},
"_opacity": 255,
"_opacity": 255,
"_color": {
"_color": {
...
@@ -10098,7 +9982,7 @@
...
@@ -10098,7 +9982,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 20
4
"__id__": 20
1
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -10128,7 +10012,7 @@
...
@@ -10128,7 +10012,7 @@
{
{
"__type__": "cc.PrefabInfo",
"__type__": "cc.PrefabInfo",
"root": {
"root": {
"__id__": 20
3
"__id__": 20
0
},
},
"asset": {
"asset": {
"__uuid__": "3d356c4d-cb23-4239-aa5f-8a913f420fa4"
"__uuid__": "3d356c4d-cb23-4239-aa5f-8a913f420fa4"
...
@@ -10141,7 +10025,7 @@
...
@@ -10141,7 +10025,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 20
3
"__id__": 20
0
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -10173,7 +10057,7 @@
...
@@ -10173,7 +10057,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 20
3
"__id__": 20
0
},
},
"_enabled": true,
"_enabled": true,
"_id": "3eMT/DXoJNGZT/8Z3nuTUH"
"_id": "3eMT/DXoJNGZT/8Z3nuTUH"
...
@@ -10181,7 +10065,7 @@
...
@@ -10181,7 +10065,7 @@
{
{
"__type__": "cc.PrefabInfo",
"__type__": "cc.PrefabInfo",
"root": {
"root": {
"__id__": 20
3
"__id__": 20
0
},
},
"asset": {
"asset": {
"__uuid__": "3d356c4d-cb23-4239-aa5f-8a913f420fa4"
"__uuid__": "3d356c4d-cb23-4239-aa5f-8a913f420fa4"
...
@@ -10189,6 +10073,100 @@
...
@@ -10189,6 +10073,100 @@
"fileId": "",
"fileId": "",
"sync": false
"sync": false
},
},
{
"__type__": "cc.Node",
"_name": "bg",
"_objFlags": 0,
"_parent": {
"__id__": 7
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 208
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"height": 100
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "45WEE2echIUY1/z1Z88Exf"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 207
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "51nBXWjLpNUIamFPlMloSh"
},
{
{
"__type__": "cc.Widget",
"__type__": "cc.Widget",
"_name": "",
"_name": "",
...
@@ -10224,8 +10202,6 @@
...
@@ -10224,8 +10202,6 @@
"__id__": 7
"__id__": 7
},
},
"_enabled": true,
"_enabled": true,
"label": null,
"text": "hello",
"_id": "dc27P7CmJKL7vJ/gzFAByK"
"_id": "dc27P7CmJKL7vJ/gzFAByK"
}
}
]
]
\ No newline at end of file
assets/middleLayer_for_debug/script/middleLayer.ts
View file @
72c39c42
...
@@ -46,6 +46,7 @@ export default class NewClass extends middleLayerBase {
...
@@ -46,6 +46,7 @@ export default class NewClass extends middleLayerBase {
)
)
uiNode
.
scale
=
scale
;
uiNode
.
scale
=
scale
;
initAir
(
this
);
initAir
(
this
);
this
.
reWriteAir
();
// this.preloadAll();
// this.preloadAll();
this
.
role
=
'
student
'
;
this
.
role
=
'
student
'
;
...
@@ -210,7 +211,6 @@ export default class NewClass extends middleLayerBase {
...
@@ -210,7 +211,6 @@ export default class NewClass extends middleLayerBase {
loadingProgress
.
getComponent
(
cc
.
ProgressBar
).
progress
=
this
.
loadedCount
/
this
.
preloadCount
;
loadingProgress
.
getComponent
(
cc
.
ProgressBar
).
progress
=
this
.
loadedCount
/
this
.
preloadCount
;
}
}
currentBundleInfo
=
null
;
onHomeworkFinish
(
callBack
,
data
=
null
)
{
onHomeworkFinish
(
callBack
,
data
=
null
)
{
console
.
log
(
'
this.courseIndex =
'
+
JSON
.
stringify
(
this
.
currentBundleInfo
));
console
.
log
(
'
this.courseIndex =
'
+
JSON
.
stringify
(
this
.
currentBundleInfo
));
if
(
this
.
currentBundleInfo
.
sceneName
==
'
ls_fly
'
)
{
if
(
this
.
currentBundleInfo
.
sceneName
==
'
ls_fly
'
)
{
...
@@ -471,10 +471,30 @@ export default class NewClass extends middleLayerBase {
...
@@ -471,10 +471,30 @@ export default class NewClass extends middleLayerBase {
cc
.
find
(
'
middleLayer/BtnRight
'
).
on
(
'
click
'
,
()
=>
{
cc
.
find
(
'
middleLayer/BtnRight
'
).
on
(
'
click
'
,
()
=>
{
this
.
goNextPage
();
this
.
goNextPage
();
if
(
this
.
courseIndex
==
0
)
{
cc
.
find
(
'
middleLayer/BtnLeft
'
).
active
=
false
;
}
else
{
cc
.
find
(
'
middleLayer/BtnLeft
'
).
active
=
false
;
}
if
(
this
.
courseIndex
==
this
.
courses
.
length
-
1
)
{
cc
.
find
(
'
middleLayer/BtnRight
'
).
active
=
false
;
}
else
{
cc
.
find
(
'
middleLayer/BtnRight
'
).
active
=
true
;
}
});
});
cc
.
find
(
'
middleLayer/BtnLeft
'
).
on
(
'
click
'
,
()
=>
{
cc
.
find
(
'
middleLayer/BtnLeft
'
).
on
(
'
click
'
,
()
=>
{
this
.
goPrePage
();
this
.
goPrePage
();
if
(
this
.
courseIndex
==
0
)
{
cc
.
find
(
'
middleLayer/BtnLeft
'
).
active
=
false
;
}
else
{
cc
.
find
(
'
middleLayer/BtnLeft
'
).
active
=
false
;
}
if
(
this
.
courseIndex
==
this
.
courses
.
length
-
1
)
{
cc
.
find
(
'
middleLayer/BtnRight
'
).
active
=
false
;
}
else
{
cc
.
find
(
'
middleLayer/BtnRight
'
).
active
=
true
;
}
});
});
cc
.
find
(
'
middleLayer/ui/BtnOpenOsmo
'
).
on
(
'
click
'
,
()
=>
{
cc
.
find
(
'
middleLayer/ui/BtnOpenOsmo
'
).
on
(
'
click
'
,
()
=>
{
...
@@ -544,6 +564,8 @@ export default class NewClass extends middleLayerBase {
...
@@ -544,6 +564,8 @@ export default class NewClass extends middleLayerBase {
const
nameText
=
cc
.
find
(
'
middleLayer/ui/bundleName
'
);
const
nameText
=
cc
.
find
(
'
middleLayer/ui/bundleName
'
);
const
bundleName
=
nameText
.
getComponent
(
cc
.
EditBox
).
string
;
const
bundleName
=
nameText
.
getComponent
(
cc
.
EditBox
).
string
;
cc
.
sys
.
localStorage
.
setItem
(
'
bundleName
'
,
bundleName
);
cc
.
sys
.
localStorage
.
setItem
(
'
bundleName
'
,
bundleName
);
this
.
hideUI
();
this
.
showWaitingLetters
();
this
.
loadOnlineBundle
(
bundleName
);
this
.
loadOnlineBundle
(
bundleName
);
this
.
showDebugUI
();
this
.
showDebugUI
();
});
});
...
@@ -553,6 +575,7 @@ export default class NewClass extends middleLayerBase {
...
@@ -553,6 +575,7 @@ export default class NewClass extends middleLayerBase {
const
courseIdNode
=
cc
.
find
(
'
middleLayer/ui/courseId
'
);
const
courseIdNode
=
cc
.
find
(
'
middleLayer/ui/courseId
'
);
const
courseId
=
courseIdNode
.
getComponent
(
cc
.
EditBox
).
string
;
const
courseId
=
courseIdNode
.
getComponent
(
cc
.
EditBox
).
string
;
cc
.
sys
.
localStorage
.
setItem
(
'
courseId
'
,
courseId
);
cc
.
sys
.
localStorage
.
setItem
(
'
courseId
'
,
courseId
);
this
.
hideUI
();
this
.
loadOnlineCourseWare
(
courseId
);
this
.
loadOnlineCourseWare
(
courseId
);
this
.
showDebugUI
();
this
.
showDebugUI
();
});
});
...
@@ -595,33 +618,6 @@ export default class NewClass extends middleLayerBase {
...
@@ -595,33 +618,6 @@ export default class NewClass extends middleLayerBase {
});
});
}
}
goPrePage
()
{
this
.
goTarIndexPage
(
this
.
courseIndex
-
1
);
}
goNextPage
()
{
this
.
goTarIndexPage
(
this
.
courseIndex
+
1
);
}
goTarIndexPage
(
index
)
{
if
(
!
this
.
courses
||
index
==
this
.
courseIndex
||
index
<
0
||
index
>
this
.
courses
.
length
-
1
)
{
return
;
}
(
<
any
>
window
).
courseware
.
freeAllOcMethod
();
this
.
courseIndex
=
index
;
this
.
courseItem
=
this
.
courses
[
this
.
courseIndex
];
if
(
this
.
courseIndex
==
0
)
{
cc
.
find
(
'
middleLayer/BtnLeft
'
).
active
=
false
;
}
else
{
cc
.
find
(
'
middleLayer/BtnLeft
'
).
active
=
false
;
}
if
(
this
.
courseIndex
==
this
.
courses
.
length
-
1
)
{
cc
.
find
(
'
middleLayer/BtnRight
'
).
active
=
false
;
}
else
{
cc
.
find
(
'
middleLayer/BtnRight
'
).
active
=
true
;
}
this
.
loadPageBundle
();
}
log
(
str
)
{
log
(
str
)
{
const
logStr
=
`
${
new
Date
().
toLocaleString
()}
:
${
str
}
`
;
const
logStr
=
`
${
new
Date
().
toLocaleString
()}
:
${
str
}
`
;
console
.
log
(
logStr
);
console
.
log
(
logStr
);
...
@@ -636,53 +632,6 @@ export default class NewClass extends middleLayerBase {
...
@@ -636,53 +632,6 @@ export default class NewClass extends middleLayerBase {
hideUI
()
{
hideUI
()
{
cc
.
find
(
'
middleLayer/ui
'
).
active
=
false
;
cc
.
find
(
'
middleLayer/ui
'
).
active
=
false
;
}
}
loadOnlineBundle
(
bundleName
)
{
this
.
hideUI
();
this
.
showWaitingLetters
();
this
.
callNetworkApiGet
(
`/api/template/v1/
${
bundleName
}
`
,
{},
(
datastr
)
=>
{
const
data
=
JSON
.
parse
(
datastr
);
let
configData
=
null
;
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
configData
=
data
.
data
.
conf
.
ios
;
}
else
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
)
{
configData
=
data
.
data
.
conf
.
android
;
}
else
{
configData
=
data
.
data
.
conf
.
web_desktop
;
}
const
sceneName
=
configData
.
sceneName
;
const
version
=
configData
.
version
;
const
bondleUrl
=
configData
.
bondleUrl
;
this
.
loadBundle
(
sceneName
,
version
,
bondleUrl
);
});
}
courses
=
null
;
courseIndex
=
0
;
courseItem
=
null
;
loadOnlineCourseWare
(
courseId
,
linkFlag
=
false
)
{
this
.
hideUI
();
this
.
showWaitingLetters
();
let
api
=
`/api/courseware/v1/
${
courseId
}
/list`
;
if
(
linkFlag
===
true
)
{
api
=
`/api/courseware/v1/
${
courseId
}
/eq/level/list`
;
}
this
.
callNetworkApiGet
(
api
,
{},
(
datastr
)
=>
{
const
data
=
JSON
.
parse
(
datastr
);
if
(
data
.
rows
&&
data
.
rows
.
length
>
0
)
{
this
.
courses
=
data
.
rows
;
this
.
courseIndex
=
data
.
index
||
0
;
this
.
courseItem
=
data
.
rows
[
this
.
courseIndex
];
}
if
(
this
.
courses
&&
this
.
courses
.
length
>
1
&&
this
.
courseIndex
<=
this
.
courses
.
length
-
1
)
{
cc
.
find
(
'
middleLayer/BtnRight
'
).
active
=
true
;
}
if
(
this
.
courseIndex
>
0
)
{
cc
.
find
(
'
middleLayer/BtnLeft
'
).
active
=
false
;
}
this
.
reWriteAir
();
this
.
loadPageBundle
();
});
}
loadLocalBundle
(
address
,
port
)
{
loadLocalBundle
(
address
,
port
)
{
this
.
callNetworkApiGetLocal
(
`http://
${
address
}
:
${
port
}
`
,
'
/dist/config.json
'
,
{},
(
datastr
)
=>
{
this
.
callNetworkApiGetLocal
(
`http://
${
address
}
:
${
port
}
`
,
'
/dist/config.json
'
,
{},
(
datastr
)
=>
{
const
data
=
JSON
.
parse
(
datastr
);
const
data
=
JSON
.
parse
(
datastr
);
...
@@ -705,60 +654,6 @@ export default class NewClass extends middleLayerBase {
...
@@ -705,60 +654,6 @@ export default class NewClass extends middleLayerBase {
this
.
loadBundle
(
sceneName
,
version
,
bondleUrl
);
this
.
loadBundle
(
sceneName
,
version
,
bondleUrl
);
});
});
}
}
loadPageBundle
()
{
let
sceneName
,
version
,
bondleUrl
=
""
;
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
sceneName
=
this
.
courseItem
.
conf
.
ios
.
sceneName
;
version
=
this
.
courseItem
.
conf
.
ios
.
version
;
bondleUrl
=
this
.
courseItem
.
conf
.
ios
.
bondleUrl
;
}
else
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
)
{
sceneName
=
this
.
courseItem
.
conf
.
android
.
sceneName
;
version
=
this
.
courseItem
.
conf
.
android
.
version
;
bondleUrl
=
this
.
courseItem
.
conf
.
android
.
bondleUrl
;
}
else
{
sceneName
=
this
.
courseItem
.
conf
.
web_desktop
.
sceneName
;
version
=
this
.
courseItem
.
conf
.
web_desktop
.
version
;
bondleUrl
=
this
.
courseItem
.
conf
.
web_desktop
.
bondleUrl
;
}
this
.
loadBundle
(
sceneName
,
version
,
bondleUrl
);
}
loadBundle
(
sceneName
,
version
,
bondleUrl
)
{
this
.
currentBundleInfo
=
{
sceneName
,
version
,
bondleUrl
};
this
.
showMask
();
this
.
showWaitingLetters
();
cc
.
assetManager
.
loadBundle
(
bondleUrl
,
{
version
:
version
},
async
(
err
,
bundle
)
=>
{
if
(
err
)
{
return
this
.
asyncDelayLog
(
err
);
}
bundle
.
loadScene
(
sceneName
,
null
,
null
,
(
err
,
scene
)
=>
{
const
btnRestart
=
cc
.
find
(
'
middleLayer/BtnRestart
'
);
btnRestart
.
active
=
false
;
if
(
err
)
{
this
.
asyncDelayLog
(
'
err:
'
+
err
);
}
cc
.
audioEngine
.
stopAll
();
cc
.
director
.
runScene
(
scene
,
null
,
()
=>
{
console
.
log
(
'
sceneName =
'
+
sceneName
);
const
canvas
=
cc
.
find
(
'
Canvas
'
);
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
);
cc
.
find
(
'
middleLayer/ExitBtn
'
).
active
=
true
;
this
.
hideWaitingLetters
();
this
.
hideMask
();
canvas
.
getComponent
(
cc
.
Widget
).
updateAlignment
();
middleLayer
.
scale
=
canvas
.
width
/
middleLayer
.
width
;
// this.showLog('middleLayer.scale = ' + middleLayer.scale);
});
});
});
}
reloadBundle
()
{
const
{
sceneName
,
version
,
bondleUrl
}
=
this
.
currentBundleInfo
;
this
.
loadBundle
(
sceneName
,
version
,
bondleUrl
);
}
showMask
()
{
showMask
()
{
const
mask
=
cc
.
find
(
'
middleLayer/mask
'
);
const
mask
=
cc
.
find
(
'
middleLayer/mask
'
);
mask
.
active
=
true
;
mask
.
active
=
true
;
...
@@ -791,9 +686,29 @@ export default class NewClass extends middleLayerBase {
...
@@ -791,9 +686,29 @@ export default class NewClass extends middleLayerBase {
}
}
(
<
any
>
window
).
courseware
.
nextPage
=
()
=>
{
(
<
any
>
window
).
courseware
.
nextPage
=
()
=>
{
this
.
goNextPage
();
this
.
goNextPage
();
if
(
this
.
courseIndex
==
0
)
{
cc
.
find
(
'
middleLayer/BtnLeft
'
).
active
=
false
;
}
else
{
cc
.
find
(
'
middleLayer/BtnLeft
'
).
active
=
false
;
}
if
(
this
.
courseIndex
==
this
.
courses
.
length
-
1
)
{
cc
.
find
(
'
middleLayer/BtnRight
'
).
active
=
false
;
}
else
{
cc
.
find
(
'
middleLayer/BtnRight
'
).
active
=
true
;
}
}
}
(
<
any
>
window
).
courseware
.
beforePage
=
()
=>
{
(
<
any
>
window
).
courseware
.
beforePage
=
()
=>
{
this
.
goPrePage
();
this
.
goPrePage
();
if
(
this
.
courseIndex
==
0
)
{
cc
.
find
(
'
middleLayer/BtnLeft
'
).
active
=
false
;
}
else
{
cc
.
find
(
'
middleLayer/BtnLeft
'
).
active
=
false
;
}
if
(
this
.
courseIndex
==
this
.
courses
.
length
-
1
)
{
cc
.
find
(
'
middleLayer/BtnRight
'
).
active
=
false
;
}
else
{
cc
.
find
(
'
middleLayer/BtnRight
'
).
active
=
true
;
}
}
}
(
<
any
>
window
).
courseware
.
sendAnswer
=
(
answerObj
)
=>
{
(
<
any
>
window
).
courseware
.
sendAnswer
=
(
answerObj
)
=>
{
this
.
log
(
"
===成功调用sendAnswer===
"
+
JSON
.
stringify
(
answerObj
));
this
.
log
(
"
===成功调用sendAnswer===
"
+
JSON
.
stringify
(
answerObj
));
...
@@ -943,6 +858,8 @@ export default class NewClass extends middleLayerBase {
...
@@ -943,6 +858,8 @@ export default class NewClass extends middleLayerBase {
});
});
}
}
getRainbowColorList
()
{
getRainbowColorList
()
{
return
[
return
[
cc
.
color
(
255
,
255
,
0
),
cc
.
color
(
255
,
255
,
0
),
...
...
assets/middleLayer_for_debug/script/middleLayerBase.ts
View file @
72c39c42
export
class
middleLayerBase
extends
cc
.
Component
{
export
abstract
class
middleLayerBase
extends
cc
.
Component
{
abstract
reWriteAir
():
void
;
abstract
showMask
():
void
;
abstract
hideMask
():
void
;
abstract
hideWaitingLetters
():
void
;
abstract
showWaitingLetters
():
void
;
callNetworkApiPost
(
uri
,
data
,
callBack
)
{
callNetworkApiPost
(
uri
,
data
,
callBack
)
{
this
.
getBaseUrl
((
baseUrl
)
=>
{
this
.
getBaseUrl
((
baseUrl
)
=>
{
const
xhr
=
new
XMLHttpRequest
();
const
xhr
=
new
XMLHttpRequest
();
...
@@ -72,4 +79,143 @@ export class middleLayerBase extends cc.Component {
...
@@ -72,4 +79,143 @@ export class middleLayerBase extends cc.Component {
});
});
});
});
}
}
loadOnlineBundle
(
bundleName
)
{
this
.
callNetworkApiGet
(
`/api/template/v1/
${
bundleName
}
`
,
{},
(
datastr
)
=>
{
const
data
=
JSON
.
parse
(
datastr
);
let
configData
=
null
;
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
configData
=
data
.
data
.
conf
.
ios
;
}
else
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
)
{
configData
=
data
.
data
.
conf
.
android
;
}
else
{
configData
=
data
.
data
.
conf
.
web_desktop
;
}
const
sceneName
=
configData
.
sceneName
;
const
version
=
configData
.
version
;
const
bondleUrl
=
configData
.
bondleUrl
;
this
.
loadBundle
(
sceneName
,
version
,
bondleUrl
);
});
}
currentBundleInfo
=
null
;
reloadBundle
()
{
const
{
sceneName
,
version
,
bondleUrl
}
=
this
.
currentBundleInfo
;
this
.
loadBundle
(
sceneName
,
version
,
bondleUrl
);
}
loadBundle
(
sceneName
,
version
,
bondleUrl
)
{
this
.
currentBundleInfo
=
{
sceneName
,
version
,
bondleUrl
};
this
.
showMask
();
this
.
showWaitingLetters
();
cc
.
assetManager
.
loadBundle
(
bondleUrl
,
{
version
:
version
},
async
(
err
,
bundle
)
=>
{
bundle
.
loadScene
(
sceneName
,
null
,
null
,
(
err
,
scene
)
=>
{
const
btnRestart
=
cc
.
find
(
'
middleLayer/BtnRestart
'
);
btnRestart
.
active
=
false
;
cc
.
audioEngine
.
stopAll
();
cc
.
director
.
runScene
(
scene
,
null
,
()
=>
{
console
.
log
(
'
sceneName =
'
+
sceneName
);
const
canvas
=
cc
.
find
(
'
Canvas
'
);
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
);
cc
.
find
(
'
middleLayer/ExitBtn
'
).
active
=
true
;
this
.
hideWaitingLetters
();
this
.
hideMask
();
canvas
.
getComponent
(
cc
.
Widget
).
updateAlignment
();
middleLayer
.
scale
=
canvas
.
width
/
middleLayer
.
width
;
// this.showLog('middleLayer.scale = ' + middleLayer.scale);
});
});
});
}
courses
=
null
;
courseIndex
=
0
;
courseItem
=
null
;
loadOnlineCourseWare
(
courseId
,
linkFlag
=
false
)
{
this
.
showWaitingLetters
();
let
api
=
`/api/courseware/v1/
${
courseId
}
/list`
;
if
(
linkFlag
===
true
)
{
api
=
`/api/courseware/v1/
${
courseId
}
/eq/level/list`
;
}
this
.
callNetworkApiGet
(
api
,
{},
(
datastr
)
=>
{
const
data
=
JSON
.
parse
(
datastr
);
if
(
data
.
rows
&&
data
.
rows
.
length
>
0
)
{
this
.
courses
=
data
.
rows
;
this
.
courseIndex
=
data
.
index
||
0
;
this
.
courseItem
=
data
.
rows
[
this
.
courseIndex
];
}
if
(
this
.
courses
&&
this
.
courses
.
length
>
1
&&
this
.
courseIndex
<=
this
.
courses
.
length
-
1
)
{
cc
.
find
(
'
middleLayer/BtnRight
'
).
active
=
true
;
}
if
(
this
.
courseIndex
>
0
)
{
cc
.
find
(
'
middleLayer/BtnLeft
'
).
active
=
false
;
}
this
.
reWriteAir
();
this
.
loadPageBundle
();
});
}
loadPageBundle
()
{
let
sceneName
,
version
,
bondleUrl
=
""
;
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
sceneName
=
this
.
courseItem
.
conf
.
ios
.
sceneName
;
version
=
this
.
courseItem
.
conf
.
ios
.
version
;
bondleUrl
=
this
.
courseItem
.
conf
.
ios
.
bondleUrl
;
}
else
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
)
{
sceneName
=
this
.
courseItem
.
conf
.
android
.
sceneName
;
version
=
this
.
courseItem
.
conf
.
android
.
version
;
bondleUrl
=
this
.
courseItem
.
conf
.
android
.
bondleUrl
;
}
else
{
sceneName
=
this
.
courseItem
.
conf
.
web_desktop
.
sceneName
;
version
=
this
.
courseItem
.
conf
.
web_desktop
.
version
;
bondleUrl
=
this
.
courseItem
.
conf
.
web_desktop
.
bondleUrl
;
}
this
.
loadBundle
(
sceneName
,
version
,
bondleUrl
);
}
goPrePage
()
{
this
.
goTarIndexPage
(
this
.
courseIndex
-
1
);
}
goNextPage
()
{
this
.
goTarIndexPage
(
this
.
courseIndex
+
1
);
}
goTarIndexPage
(
index
)
{
if
(
!
this
.
courses
||
index
==
this
.
courseIndex
||
index
<
0
||
index
>
this
.
courses
.
length
-
1
)
{
return
;
}
(
<
any
>
window
).
courseware
.
freeAllOcMethod
();
this
.
courseIndex
=
index
;
this
.
courseItem
=
this
.
courses
[
this
.
courseIndex
];
this
.
loadPageBundle
();
}
showTips
(
str
)
{
const
tipsNode
=
new
cc
.
Node
();
tipsNode
.
parent
=
cc
.
find
(
'
Canvas
'
);
tipsNode
.
zIndex
=
100
;
const
bg
=
cc
.
instantiate
(
cc
.
find
(
'
middleLayer/bg
'
));
bg
.
parent
=
tipsNode
;
bg
.
active
=
true
;
bg
.
color
=
cc
.
color
(
100
,
100
,
100
);
const
labelNode
=
new
cc
.
Node
();
labelNode
.
parent
=
tipsNode
;
const
label
=
labelNode
.
addComponent
(
cc
.
Label
);
label
.
string
=
str
;
bg
.
width
=
200
;
bg
.
height
=
labelNode
.
height
+
20
;
cc
.
tween
(
tipsNode
)
.
set
({
opacity
:
255
})
.
delay
(
1
)
.
to
(
1
,
{
opacity
:
0
})
.
removeSelf
()
.
start
();
}
}
}
\ No newline at end of file
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