62 lines
2.0 KiB
TypeScript
62 lines
2.0 KiB
TypeScript
/**
|
|
* 游戏启动首屏
|
|
*/
|
|
import {TrackingManager, TrackingType} from "../Script/Tracking/TrackingManager";
|
|
|
|
const {ccclass, property} = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class FirstScene extends cc.Component {
|
|
|
|
subPackageNum = 1 //分包个数
|
|
isloadscene = !1 //是否加载场景
|
|
onLoad () {
|
|
TrackingManager.send(TrackingType.Open);
|
|
|
|
var self = this
|
|
if(cc.sys.platform == cc.sys.BYTEDANCE_GAME){
|
|
this.schedule(()=>{
|
|
this.subPackageNum --
|
|
}, 1,2)
|
|
}else if(cc.sys.platform == cc.sys.WECHAT_GAME){
|
|
//@ts-ignore
|
|
const loadTask0 = wx.loadSubpackage({
|
|
name: 'resources', // 填写 game.json 中 subPackages 填写的分包名称 name
|
|
success: function(res) {
|
|
console.log('resources分包加载成功后通过 success 回调')
|
|
self.subPackageNum --
|
|
},
|
|
fail: function(res) {
|
|
console.log('resources分包加载失败通过 fail 回调')
|
|
}
|
|
});
|
|
|
|
loadTask0.onProgressUpdate(res => {
|
|
//console.log('loadTask0下载进度', res.progress);
|
|
//console.log('loadTask0已经下载的数据长度', res.totalBytesWritten);
|
|
//console.log('loadTask0预期需要下载的数据总长度', res.totalBytesExpectedToWrite);
|
|
});
|
|
}
|
|
}
|
|
|
|
start () {
|
|
|
|
}
|
|
|
|
update (dt) {
|
|
if(this.isloadscene == !0) return
|
|
if(cc.sys.platform == cc.sys.BYTEDANCE_GAME || cc.sys.platform == cc.sys.WECHAT_GAME){
|
|
if(this.subPackageNum <= 0){
|
|
this.isloadscene = !0
|
|
cc.director.loadScene('LoadScene')
|
|
}
|
|
}else{
|
|
this.subPackageNum -= 0.1
|
|
if(this.subPackageNum <= 0){
|
|
this.isloadscene = !0
|
|
cc.director.loadScene('LoadScene')
|
|
}
|
|
}
|
|
}
|
|
}
|