Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cartoon_main
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
cartoon_main
Commits
252528f3
Commit
252528f3
authored
Aug 24, 2022
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat
parent
21d40a4b
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1231 additions
and
115 deletions
+1231
-115
cartoon_main.fire
assets/cartoon_main/scene/cartoon_main.fire
+901
-3
cartoon_main.ts
assets/cartoon_main/scene/cartoon_main.ts
+74
-8
MyCocosSceneComponent.ts
assets/cartoon_main/script/MyCocosSceneComponent.ts
+2
-2
util.ts
assets/cartoon_main/script/util.ts
+218
-102
back.png
assets/cartoon_main/textures/back.png
+0
-0
back.png.meta
assets/cartoon_main/textures/back.png.meta
+36
-0
No files found.
assets/cartoon_main/scene/cartoon_main.fire
View file @
252528f3
This diff is collapsed.
Click to expand it.
assets/cartoon_main/scene/cartoon_main.ts
View file @
252528f3
import
{
asyncDelay
,
onHomeworkFinish
}
from
"
../script/util
"
;
import
{
asyncDelay
,
asyncCallNetworkApiGet
,
getSpriteFrimeByUrl
,
buttonOnClick
,
showLoading
,
hideLoading
}
from
"
../script/util
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
@@ -18,21 +19,75 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -18,21 +19,75 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
onLoadEnd
()
{
rows
=
null
;
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
orgId
=
9
;
this
.
initData
();
routers
=
[];
async
onLoadEnd
()
{
await
this
.
initData
();
this
.
initView
();
this
.
initView
();
this
.
initListener
();
this
.
initListener
();
}
}
_cantouch
=
null
;
async
loadData
(
pid
=
null
)
{
initData
()
{
const
query
=
{
orgid
:
this
.
orgId
};
// 所有全局变量 默认都是null
if
(
pid
)
{
this
.
_cantouch
=
true
;
query
[
"
pid
"
]
=
pid
;
}
const
res
:
any
=
await
asyncCallNetworkApiGet
(
"
/api/syllabus/v1/list
"
,
query
);
const
rows
=
JSON
.
parse
(
res
).
rows
;
return
rows
;
}
async
initData
()
{
this
.
rows
=
this
.
loadData
();
}
drawPage
()
{
const
contentNode
=
cc
.
find
(
"
Canvas/pages/view/content
"
);
const
item
=
cc
.
find
(
"
item
"
,
contentNode
);
// 清理原来的数据
item
.
parent
=
this
.
node
;
contentNode
.
removeAllChildren
();
item
.
parent
=
contentNode
;
// 绘制
for
(
let
i
=
0
;
i
<
this
.
rows
.
length
;
i
++
)
{
const
row
=
this
.
rows
[
i
];
const
itemClone
=
cc
.
instantiate
(
item
);
itemClone
.
parent
=
contentNode
;
itemClone
.
active
=
true
;
itemClone
.
attr
({
item_id
:
row
.
id
});
cc
.
find
(
`text`
,
itemClone
).
getComponent
(
cc
.
Label
).
string
=
row
.
name
;
if
(
row
.
cover
)
{
getSpriteFrimeByUrl
(
row
.
cover
,
(
spriteFrame
)
=>
{
const
coverNode
=
cc
.
find
(
`cover`
,
itemClone
);
coverNode
.
getComponent
(
cc
.
Sprite
).
spriteFrame
=
spriteFrame
;
const
sx
=
70
/
coverNode
.
width
;
const
sy
=
80
/
coverNode
.
height
;
coverNode
.
scale
=
Math
.
min
(
sx
,
sy
);
});
}
buttonOnClick
(
itemClone
,
async
()
=>
{
this
.
routers
.
push
(
itemClone
);
showLoading
();
await
this
.
loadData
(
row
.
id
);
this
.
drawPage
();
hideLoading
();
if
(
this
.
routers
.
length
>
0
)
{
cc
.
find
(
`Canvas/back`
).
active
=
false
;
}
});
}
}
}
initView
()
{
initView
()
{
this
.
initBg
();
this
.
initBg
();
this
.
drawPage
();
}
}
initBg
()
{
initBg
()
{
...
@@ -41,7 +96,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -41,7 +96,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
initListener
()
{
initListener
()
{
const
back
=
cc
.
find
(
`Canvas/back`
);
buttonOnClick
(
back
,
async
()
=>
{
showLoading
();
const
item
=
this
.
routers
.
pop
();
await
this
.
loadData
(
item
.
id
);
this
.
drawPage
();
hideLoading
();
if
(
this
.
routers
.
length
===
0
)
{
back
.
active
=
false
;
}
});
}
}
playLocalAudio
(
audioName
)
{
playLocalAudio
(
audioName
)
{
...
...
assets/cartoon_main/script/MyCocosSceneComponent.ts
View file @
252528f3
...
@@ -87,7 +87,7 @@ export class MyCocosSceneComponent extends cc.Component {
...
@@ -87,7 +87,7 @@ export class MyCocosSceneComponent extends cc.Component {
preload
()
{
preload
()
{
const
preloadArr
=
this
.
_imageResList
.
concat
(
this
.
_audioResList
).
concat
(
this
.
_animaResList
);
const
preloadArr
=
this
.
_imageResList
.
concat
(
this
.
_audioResList
).
concat
(
this
.
_animaResList
);
cc
.
assetManager
.
loadAny
(
preloadArr
,
null
,
null
,
(
err
,
data
)
=>
{
cc
.
assetManager
.
loadAny
(
preloadArr
,
null
,
null
,
async
(
err
,
data
)
=>
{
if
(
window
&&
window
[
"
air
"
])
{
if
(
window
&&
window
[
"
air
"
])
{
// window["air"].onCourseInScreen = (next) => {
// window["air"].onCourseInScreen = (next) => {
...
@@ -95,7 +95,7 @@ export class MyCocosSceneComponent extends cc.Component {
...
@@ -95,7 +95,7 @@ export class MyCocosSceneComponent extends cc.Component {
// this.onLoadEnd();
// this.onLoadEnd();
// next();
// next();
// };
// };
this
.
onLoadEnd
();
await
this
.
onLoadEnd
();
window
[
"
air
"
].
hideAirClassLoading
();
window
[
"
air
"
].
hideAirClassLoading
();
}
else
{
}
else
{
this
.
onLoadEnd
();
this
.
onLoadEnd
();
...
...
assets/cartoon_main/script/util.ts
View file @
252528f3
This diff is collapsed.
Click to expand it.
assets/cartoon_main/textures/back.png
0 → 100644
View file @
252528f3
9.44 KB
assets/cartoon_main/textures/back.png.meta
0 → 100644
View file @
252528f3
{
"ver": "2.3.5",
"uuid": "e999b601-f784-47f8-bbdf-10fcaeb5f833",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 108,
"height": 113,
"platformSettings": {},
"subMetas": {
"back": {
"ver": "1.0.4",
"uuid": "de271a39-457b-4acc-89c7-d9b75dc64b8e",
"rawTextureUuid": "e999b601-f784-47f8-bbdf-10fcaeb5f833",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 108,
"height": 113,
"rawWidth": 108,
"rawHeight": 113,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ 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