Commit 1da8f366 authored by 李维's avatar 李维

优化性能

parent 4f54b5f4
No preview for this file type
{
"ver": "1.1.2",
"uuid": "e0ae4184-41ff-46b0-9091-3eb0ce6568d1",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"__type__": "cc.AnimationClip",
"_name": "loading",
"_objFlags": 0,
"_native": "",
"_duration": 2.533333333333333,
"sample": 60,
"speed": 0.5,
"wrapMode": 2,
"curveData": {
"comps": {
"cc.Sprite": {
"spriteFrame": [
{
"frame": 0,
"value": {
"__uuid__": "29713062-e52e-4112-aff5-c99188ce5c52"
}
},
{
"frame": 0.5,
"value": {
"__uuid__": "7ba58a09-dd77-42cd-8bcc-81d5f2118eea"
}
},
{
"frame": 1,
"value": {
"__uuid__": "002175d8-9eb1-429b-aea6-04b30d0df15a"
}
},
{
"frame": 1.5166666666666666,
"value": {
"__uuid__": "81fd7e93-5f7f-4b8e-a5cf-8a37983df449"
}
},
{
"frame": 2,
"value": {
"__uuid__": "d472b32c-4a08-4dab-a77b-e6ea36e98084"
}
},
{
"frame": 2.5166666666666666,
"value": {
"__uuid__": "29713062-e52e-4112-aff5-c99188ce5c52"
}
}
]
}
}
},
"events": []
}
\ No newline at end of file
{
"ver": "2.1.0",
"uuid": "c01fcefa-a80e-43a2-8b03-cce500eba63d",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "ac7e840c-596c-4d10-80e2-8c44f3cce9b7",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "f939b385-39f4-4fee-8944-164ae765e08e",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 124,
"height": 129,
"platformSettings": {},
"subMetas": {
"icon_tiger1": {
"ver": "1.0.4",
"uuid": "29713062-e52e-4112-aff5-c99188ce5c52",
"rawTextureUuid": "f939b385-39f4-4fee-8944-164ae765e08e",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 3,
"offsetY": 2.5,
"trimX": 20,
"trimY": 0,
"width": 90,
"height": 124,
"rawWidth": 124,
"rawHeight": 129,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "57a512a2-507b-4fda-b0b7-d9bdcff3884a",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 124,
"height": 129,
"platformSettings": {},
"subMetas": {
"icon_tiger2": {
"ver": "1.0.4",
"uuid": "7ba58a09-dd77-42cd-8bcc-81d5f2118eea",
"rawTextureUuid": "57a512a2-507b-4fda-b0b7-d9bdcff3884a",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 5,
"offsetY": 3,
"trimX": 24,
"trimY": 1,
"width": 86,
"height": 121,
"rawWidth": 124,
"rawHeight": 129,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "80af74de-7a17-49a9-9f06-dc24d0177e3d",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 124,
"height": 129,
"platformSettings": {},
"subMetas": {
"icon_tiger3": {
"ver": "1.0.4",
"uuid": "002175d8-9eb1-429b-aea6-04b30d0df15a",
"rawTextureUuid": "80af74de-7a17-49a9-9f06-dc24d0177e3d",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 5,
"offsetY": 1.5,
"trimX": 25,
"trimY": 1,
"width": 84,
"height": 124,
"rawWidth": 124,
"rawHeight": 129,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "4bb78fd6-0368-4928-93eb-f3ef20978589",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 124,
"height": 129,
"platformSettings": {},
"subMetas": {
"icon_tiger4": {
"ver": "1.0.4",
"uuid": "81fd7e93-5f7f-4b8e-a5cf-8a37983df449",
"rawTextureUuid": "4bb78fd6-0368-4928-93eb-f3ef20978589",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 2,
"offsetY": 0,
"trimX": 22,
"trimY": 1,
"width": 84,
"height": 127,
"rawWidth": 124,
"rawHeight": 129,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "e14b77e2-93f0-444e-bd38-5f9bb7d56717",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 124,
"height": 129,
"platformSettings": {},
"subMetas": {
"icon_tiger5": {
"ver": "1.0.4",
"uuid": "d472b32c-4a08-4dab-a77b-e6ea36e98084",
"rawTextureUuid": "e14b77e2-93f0-444e-bd38-5f9bb7d56717",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 124,
"height": 129,
"rawWidth": 124,
"rawHeight": 129,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
......@@ -73,6 +73,8 @@ export default class UnitPageClass extends cc.Component {
const sv = cc.find("middleLayer/Views/UnitPage/unit_list_node/scrollView")
sv.off("scrolling")
this.isDestory = true;
this.lastUpdate = 0;
this.allListItemNodes = [];
}
async initView() {
......@@ -90,11 +92,13 @@ export default class UnitPageClass extends cc.Component {
sv.off("scrolling")
sv.on("scrolling", (e)=>{
this.allListItemNodes.forEach((node)=>{
const worldPos = node.parent.convertToWorldSpaceAR(cc.v2(node.x, node.y));
if(worldPos.x >= -node.width && worldPos.x <= canvas.width) {
node.opacity = 255;
} else {
node.opacity = 0;
if(node.parent) {
const worldPos = node.parent.convertToWorldSpaceAR(cc.v2(node.x, node.y));
if(worldPos.x >= -node.width && worldPos.x <= canvas.width) {
node.opacity = 255;
} else {
node.opacity = 0;
}
}
})
})
......@@ -241,8 +245,9 @@ export default class UnitPageClass extends cc.Component {
}
listItem;
g_content = null;
async getUnitItemDataArr(dataArr, sv) {
const content = sv.content;
const content = this.g_content = sv.content;
content.removeAllChildren();
sv.scrollToTop();
......@@ -251,10 +256,8 @@ export default class UnitPageClass extends cc.Component {
content.removeAllChildren();
let listItem = this.listItem;
let subItem = cc.find("sub_item", listItem);
let listLabel = cc.find("label", listItem);
const itemArr = [];
let subItem = cc.find("/sub_item", listItem);
for (let i = 0; i < dataArr.length; i++) {
// 此方法为异步方法,防止页面切换走以后仍然执行,在这里判断一下是否页面已经切换走
if(this.isDestory) {
......@@ -262,23 +265,18 @@ export default class UnitPageClass extends cc.Component {
}
const data = dataArr[i];
const itemNode = cc.instantiate(listItem);
const cardsContainer = cc.find("/cards", itemNode)
let listLabel = cc.find("/label", itemNode);
itemNode['data'] = data;
itemNode.removeAllChildren();
const subArr = data.children;
const baseX = subItem.x;
const baseY = subItem.y;
const disX = 530;
let lastX = 0;
for (let j = 0; j < subArr.length; j++) {
const subNode = cc.instantiate(subItem)
subNode.x = baseX + j * disX;
subNode.y = baseY;
itemNode.addChild(subNode);
lastX = subNode.x;
subNode.active = true
cardsContainer.addChild(subNode);
const subData = subArr[j];
// 课程封皮
getSprNodeByUrl(subData.cover, (spr) => {
const sprNode = spr.node;
const picLayer = cc.find("mask/pic_frame", subNode);
......@@ -286,11 +284,11 @@ export default class UnitPageClass extends cc.Component {
setSprNodeMaxLen(sprNode, picLayer.width, picLayer.height, true);
})
// 课程完成状态指示
const pointBase = cc.find("point", subNode);
const pointLayer = cc.find("pint_layer", subNode);
const pointDisX = 57;
pointBase.opacity = 0;
for (let k = 0; k < 8; k++) {
const clsData = subData.children[k];
const pointNode = cc.instantiate(pointBase);
......@@ -309,20 +307,16 @@ export default class UnitPageClass extends cc.Component {
pointNode.x = pointBase.x + k * pointDisX;
}
// 为方便测试,先全部解锁
// 解锁
const lockCover = cc.find("bg_cover_mask", subNode);
lockCover.active = false;
// 下面是正常解锁逻辑
// const unLock = this.syllabusLockStatusStore[subData.id]==='unlock';
// lockCover.active = !unLock;
// if (i==0&&j==0) {
// // 说明是第一个
// lockCover.active = false;
// }
// 课程标题
const labelNode = cc.find("label", subNode);
const label = labelNode.getComponent(cc.Label);
label.string = subData.name;
// 点击事件
subNode.addComponent(cc.Button);
subNode.on("click", () => {
const vc = this.Viewer.getComponent("PageViewer");
......@@ -335,27 +329,18 @@ export default class UnitPageClass extends cc.Component {
})
}
const labelNode = cc.instantiate(listLabel);
const label = labelNode.getComponent(cc.Label);
label.string = data.name//"Unit " + (i + 1);
itemNode.addChild(labelNode);
// if (subArr.length > 2) {
itemNode.width = lastX + 360;
setTimeout(() => {
itemNode.width = lastX + 360;
}, 1);
// }
itemArr.push(itemNode);
// 单元标题
const label = listLabel.getComponent(cc.Label);
label.string = data.name;
// 保存节点到数组 在update中逐个渲染
this.allListItemNodes.push(itemNode);
itemNode.parent = content;
// 默认显示前3个节点
// 默认显示前3个节点 - 优化性能
if (i < 3) {
itemArr[i].opacity = 255;
itemNode.opacity = 255;
}
await asyncDelay(0.05)
}
return itemArr;
}
onClickPreview() {
......@@ -378,6 +363,12 @@ export default class UnitPageClass extends cc.Component {
animation: "rightIn"
})
}
// update (dt) {}
lastUpdate = 0;
update (dt) {
if(this.lastUpdate < this.allListItemNodes.length) {
this.allListItemNodes[this.lastUpdate++].parent = this.g_content
}
}
}
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