Commit be973413 authored by 李维's avatar 李维

添加真实进度条

parent 39d457e9
......@@ -320,22 +320,22 @@
"__id__": 998
},
{
"__id__": 1015
"__id__": 1017
},
{
"__id__": 288
},
{
"__id__": 1022
"__id__": 1024
}
],
"_active": true,
"_components": [
{
"__id__": 1028
"__id__": 1030
},
{
"__id__": 1029
"__id__": 1031
}
],
"_prefab": null,
......@@ -44723,18 +44723,21 @@
},
{
"__id__": 1007
},
{
"__id__": 1012
}
],
"_active": false,
"_components": [
{
"__id__": 1012
"__id__": 1014
},
{
"__id__": 1013
"__id__": 1015
},
{
"__id__": 1014
"__id__": 1016
}
],
"_prefab": null,
......@@ -45345,6 +45348,101 @@
},
"_id": "8f9YpoyVdH74RARY/UyCO/"
},
{
"__type__": "cc.Node",
"_name": "progressText",
"_objFlags": 0,
"_parent": {
"__id__": 998
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 1013
}
],
"_prefab": null,
"_opacity": 125,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 80.06,
"height": 50.4
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
60,
-340,
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": "d9hNBAgSRGfr1ogufFGX8g"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1012
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "12%",
"_N$string": "12%",
"_fontSize": 40,
"_lineHeight": 40,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "dcyYmuY1pMzZ/7iCj3gRAO"
},
{
"__type__": "cc.Sprite",
"_name": "",
......@@ -45423,13 +45521,13 @@
},
"_children": [
{
"__id__": 1016
"__id__": 1018
}
],
"_active": false,
"_components": [
{
"__id__": 1021
"__id__": 1023
}
],
"_prefab": null,
......@@ -45485,20 +45583,20 @@
"_name": "tips",
"_objFlags": 0,
"_parent": {
"__id__": 1015
"__id__": 1017
},
"_children": [
{
"__id__": 1017
"__id__": 1019
}
],
"_active": true,
"_components": [
{
"__id__": 1019
"__id__": 1021
},
{
"__id__": 1020
"__id__": 1022
}
],
"_prefab": null,
......@@ -45554,13 +45652,13 @@
"_name": "label",
"_objFlags": 0,
"_parent": {
"__id__": 1016
"__id__": 1018
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 1018
"__id__": 1020
}
],
"_prefab": null,
......@@ -45616,7 +45714,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1017
"__id__": 1019
},
"_enabled": true,
"_materials": [
......@@ -45649,7 +45747,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1016
"__id__": 1018
},
"_enabled": true,
"_materials": [
......@@ -45681,7 +45779,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1016
"__id__": 1018
},
"_enabled": true,
"alignMode": 1,
......@@ -45708,7 +45806,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1015
"__id__": 1017
},
"_enabled": true,
"alignMode": 1,
......@@ -45739,16 +45837,16 @@
},
"_children": [
{
"__id__": 1023
"__id__": 1025
}
],
"_active": false,
"_components": [
{
"__id__": 1026
"__id__": 1028
},
{
"__id__": 1027
"__id__": 1029
}
],
"_prefab": null,
......@@ -45804,16 +45902,16 @@
"_name": "bg",
"_objFlags": 0,
"_parent": {
"__id__": 1022
"__id__": 1024
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 1024
"__id__": 1026
},
{
"__id__": 1025
"__id__": 1027
}
],
"_prefab": null,
......@@ -45869,7 +45967,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1023
"__id__": 1025
},
"_enabled": true,
"_materials": [
......@@ -45901,7 +45999,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1023
"__id__": 1025
},
"_enabled": true,
"alignMode": 1,
......@@ -45928,7 +46026,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1022
"__id__": 1024
},
"_enabled": true,
"alignMode": 1,
......@@ -45955,7 +46053,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1022
"__id__": 1024
},
"_enabled": true,
"_id": "99TmKuadlDrpqTImwqqu6G"
......
......@@ -205,7 +205,9 @@ export abstract class middleLayerBase extends cc.Component {
cc.assetManager.loadBundle(bondleUrl, { version: version }, async (err, bundle) => {
bundle.loadScene(sceneName, null, null, (err, scene) => {
bundle.loadScene(sceneName, null, (finish, total, item) => {
this.setLoadingProgressBar(Math.floor(finish / total * 100));
}, (err, scene) => {
this.courseOpenTimeStamp = Date.now();
cc.director.runScene(scene, null, () => {
......@@ -241,6 +243,19 @@ export abstract class middleLayerBase extends cc.Component {
});
}
progressTextCom = null;
progressBarScript = null;
setLoadingProgressBar(pInt) {
if(!this.progressTextCom) {
this.progressTextCom = cc.find("middleLayer/loadingLayer/progressText").getComponent(cc.Label)
}
if(!this.progressBarScript) {
this.progressBarScript = cc.find('middleLayer/loadingLayer/prograss').getComponent('progress');
}
this.progressTextCom.string = `${pInt}%`;
this.progressBarScript.setProgress(pInt / 100);
}
showExitBtn(sceneName) {
}
......
......@@ -23,8 +23,6 @@ export default class NewClass extends cc.Component {
barBaseW = null;
barSpr = null;
barSf = null;
timeLen = 5000; // 五秒
stmt = null;
init() {
this.barBaseW = this.bar.width;
this.barSpr = this.bar.getComponent(cc.Sprite);
......@@ -45,23 +43,6 @@ export default class NewClass extends cc.Component {
}
onEnable() {
if (Date.now()-this.disStmt>1000) {
// 防止连续两次 enable
this.setProgress(0);
this.stmt = Date.now();
}
}
disStmt = null;
onDisable() {
this.disStmt = Date.now();
}
update() {
if (this.stmt) {
const pencent = (Date.now() - this.stmt)/5000 * 0.9;
this.setProgress(pencent>0.9?0.9:pencent);
}
this.setProgress(0);
}
}
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