今天尝试原来加载界面的时候受挫。决定换种方法
没有做加载修改的原来的加载顺序:
/**
* by Again 2016-3-13 0.51.23
* 加载这个节点后第一次刷新后转跳到指定节点
*/
var NextScene = qc.defineBehaviour(‘qc.demo.NextScene‘, qc.Behaviour, function() {
// 初始化代码
this.loaded = false;
}, {
// 需要序列化的场景资源名称
scene: qc.Serializer.STRING
});
NextScene.prototype.awake = function() {
this.loaded = false;
};
// 加载下一场景唤醒
NextScene.prototype.update = function() {
var self = this;
if (self.loaded === false) {
self.loaded = true;
// 切换到指定场景
if (self.scene) {
self.game.scene.load(self.scene, false, function() {
// 方式1:预加载中,我们可以做一些资源的加载操作
}, function() {
self.game.log.trace(‘loading new sence ok ({0})‘, self.scene);
});
}
}
}
/**
* 场景加载的进度提示获取
*/
var LoadingUI = qc.defineBehaviour(‘qc.demo.LoadingUI‘, qc.Behaviour,
function() {
var self = this;
this.clue = null;
//默认显示
this.onShow = function() {
self.gameObject.visible = true;
self.gameObject.alpha = 1;
};
//默认消失
this.onHide = function() {
self.gameObject.visible = false;
self.gameObject.alpha = 0;
};
//默认加载中
this.onLoading = function(loaded, total) {
self.game.log.trace("loading :{0}/{1}",loaded,total);
};
}, {
}
);
// 初始化处理
LoadingUI.prototype.awake = function() {
// 关注场景开始切换和切换结束的事件
var self = this;
//设置响应事件
this.addListener(self.game.scene.onStartLoad, function() {
// 场景加载开始,显示本界面
if (typeof(self.onShow) === "function") {
self.onShow();
};
});
this.addListener(self.game.scene.onEndLoad, function() {
// 场景加载完毕,隐藏本界面
if (typeof(self.onHide) === "function") {
self.onHide();
};
});
}
// 帧调度,保证本界面永远在其他界面之上
LoadingUI.prototype.update = function() {
var self = this,
loaded = self.game.assets.loaded,
total = self.game.assets.total;
// 场景加中
if (typeof(self.onLoading) === "function") {
self.onLoading(loaded, total);
};
};
/////////////////////////////////////////////////////////////////////
// 对外接口
LoadingUI.prototype.setOnShow = function(callback) {
this.onShow = callback;
};
LoadingUI.prototype.setOnHide = function(callback) {
this.onHide = callback;
};
LoadingUI.prototype.setOnLoading = function(callback) {
this.onLoading = callback;
};
利用青瓷布局自定义加载的场景,而不是自己改写qici-loading
原文:http://www.cnblogs.com/Again/p/5271087.html