` start() {
const canvas: Node = find(“Canvas”);
const loading = canvas.getChildByName(“loading”)
const container = canvas.getChildByName(“Container”);
const progressBar = loading.getComponentInChildren(ProgressBar);
const lbProgress = loading.getChildByName("lbProgress").getComponent(Label)
const row = 100;
const col = 100;
const total = row * col;
let count = 0;
for (let y = 0; y < col; y++) {
for (let x = 0; x < row; x++) {
resources.load("pfbTile", Prefab, (err, prefab) => {
const tileNode = instantiate(prefab);
container.addChild(tileNode);
// 进度
count++;
const progresValue = Math.floor(count / total * 100);
lbProgress.string = progresValue.toString() + "%";
progressBar.progress = progresValue/100;
if (count == total) {
loading.active = false;
console.log("loaded all ....... ");
}
});
}
}
}`
在浏览器上加载进度的表现很流畅,在模拟器和安卓机上卡在0%很长时间,然后直接完成加载。Creator3.4.2,win11系统,安卓是小米s10.包也一起上传了NewProject.zip (1.4 MB)