代码如下:
onLoad () {
var _this = this;
_this.beginGame = cc.find("Canvas/bg/begin");
_this.progressBar = cc.find("Canvas/bg/progressBar");
_this.loadLabel = cc.find("Canvas/bg/loadLabel");
cc.director.preloadScene("game",_this.onProgress.bind(this), function () {
cc.log("game scene preloaded");
//进度条隐藏
_this.progressBar.active = false;
// 场景加载完成才能展示开始按钮
_this.beginGame.active = true;
});
},
onProgress :function(completedCount, totalCount, item){
this.progressBar.getComponent(cc.ProgressBar).progress = completedCount/totalCount;
this.loadLabel.getComponent(cc.Label).string = Math.floor(completedCount/totalCount * 100) + "%";
},
场景结构: