标签:脚本 手动 progress lse 从服务器 fps null only ever
//preload.js 挂载资源的脚本 cc.Class({ extends: cc.Component, properties: { // foo: { // default: null, // The default value will be used only when the component attaching // to a node for the first time // url: cc.Texture2D, // optional, default is typeof default // serializable: true, // optional, default is true // visible: true, // optional, default is true // displayName: ‘Foo‘, // optional // readonly: false, // optional, default is false // }, // ... img_array: { type: cc.SpriteFrame, default: [], }, atlas_array: { default: [], type: cc.SpriteAtlas, }, sound_array: { default: [], url: cc.AudioClip, }, prefab_array: { default: [], type: cc.Prefab, }, }, // use this for initialization onLoad: function () { }, // called every frame, uncomment this function to activate update callback // update: function (dt) { // }, });
//home_scene.js 预加载下个场景资源的处理脚本 cc.Class({ extends: cc.Component, properties: { // foo: { // default: null, // The default value will be used only when the component attaching // to a node for the first time // url: cc.Texture2D, // optional, default is typeof default // serializable: true, // optional, default is true // visible: true, // optional, default is true // displayName: ‘Foo‘, // optional // readonly: false, // optional, default is false // }, // ... wait: { type: cc.Node, default: null, }, progress_label: { type: cc.Label, default: null, }, }, // use this for initialization onLoad: function () { this.wait.active = false; this.progress_label.string = "0%"; }, goto_roadmap: function() { // 你在做场景切换的时候,如果你直接切换过去, // 由于下一个场景一定要先加载完它所需要的资源,那么一定会卡住一段时间; // 会在这里加上我们的等待界面,加入,场景加载的等待场景; this.wait.active = true; cc.loader.onProgress = function(completedCount, totalCount, item){ console.log("completedCount:" + completedCount + ",totalCount:" + totalCount); var per = Math.floor(completedCount * 100 / totalCount); this.progress_label.string = per + "%"; }.bind(this); // 预加载 cc.director.preloadScene("roadmap_scene", function() { cc.loader.onProgress = null; cc.director.loadScene("roadmap_scene"); }); // end }, // called every frame, uncomment this function to activate update callback // update: function (dt) { // }, });
cocos creator基础-(二十四)cc.Director与资源加载策略
标签:脚本 手动 progress lse 从服务器 fps null only ever
原文地址:https://www.cnblogs.com/orxx/p/10546926.html