这个时候cc.AssetLibrary.init 还没有执行 调用cc.loader.loadRes加载图片会报does not exist
子域的相关部分可不可以延后加载呢
由于微信官方的限制,子域不能延后加载
`var scene = new cc.Scene();
var root = new cc.Node();
var canvas = root.addComponent(cc.Canvas);
canvas.designResolution = new cc.size(1334, 750);
canvas.fitHeight = true;
canvas.fitWidth = true;
root.parent = scene;
//背景图片
var node = new cc.Node();
var sprite = node.addComponent(cc.Sprite);
node.parent = root;
var widget = node.addComponent(cc.Widget);
widget.left = 0;
widget.right = 0;
widget.top = 0;
widget.bottom = 0;
var remoteUrl = “https://x x x x/bg_loading.jpg”;
cc.loader.load(remoteUrl, function (err, texture) {
if (err == null) {
var sf = new cc.SpriteFrame(texture);
sprite.spriteFrame = sf;
}
});
var node = new cc.Node();
var label = node.addComponent(cc.Label);
label.string = “请稍候…”;
label.fontSize = 26;
node.parent = root;
module.exports = scene;`
此处cc.loader.load 这段导致报错,而且真机必现
gameThirdScriptError
Cannot read property ‘setInsetTop’ of null;at setTimeout callback function
TypeError: Cannot read property ‘setInsetTop’ of null
at e._applySpriteFrameInsets (https://servicewechat.qq.com/game.js:3:341686)
at e._applySpriteFrame (https://servicewechat.qq.com/game.js:3:342385)
at e.set [as spriteFrame] (https://servicewechat.qq.com/game.js:3:339400)
at r. (https://servicewechat.qq.com/game.js:120:432)
at https://servicewechat.qq.com/game.js:3:479895
at Function. (https://servicewechat.qq.com/game.js:3:592619)
at Function. (27175)
支持。。。。
大佬,我想问下这里是在处理什么,可以加载资源吗,如果可以的话,是不是代表就不用再额外做个loading界面了,不可以的话,能说下这里是在处理什么吗,了解下。。
学习下
试了一下,优化启动速度倒是没有,就是加个进度条吧,不过这个场景隐藏以后,还有很长一段时间的黑屏,求助
我也想知道唉
mark
我猜是从微信后台下载首包,并解压。
mark
mark
这里怎么作进度条、进度条、进度条!!! 在main。js里面做onprogress收到的参数completeCount和totalCount都是1、1。
求回复,@jare @panda @yufang.wu
mark
请问 Creator 的版本是什么?具体的操作过程是什么?有报错信息吗?可以把代码贴上来吗或者提供一个小 demo?
2.0.2最新版,没有报错信息
cc.loader.onProgress = function(cur, num, itme) {
console.log(‘第’ + cur + ‘已加载完毕’);
};
//预加载
cc.director.preloadScene(‘main’, function() {
cc.loader.onProgress = null;
//跳转场景
cc.director.loadScene(‘main’);
});
main.js start函数最后加载主场景的方法,换成上面的预加载,显示进度。cur和num一直都是1,没法做进度条。
如果你可以实现,希望在这个帖子补充下显示进度的demo,或者教大家使用的代码片段也行。
@yufang.wu
我先记下来哦,这两天有一丢丢忙,我会跟进的!