ShenNong_Simple/assets/Script/Load.ts
2024-10-30 15:28:42 +08:00

73 lines
1.7 KiB
TypeScript

import { WeChat } from "./module/Share/share";
const {ccclass, property, requireComponent} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property(false)
localTest: boolean = false;
@property("")
clientTestVersion: string = "1.0.0";
@property(cc.Label)
testVersion: cc.Label = null;
start () {
cc.debug.setDisplayStats(false);
window.initMgr();
// @ts-ignore
if(window.wx !== null && window.wx !== undefined) WeChat.setShare(location.href);
cc.fx.GameConfig.init(this.localTest);
this.testVersion.string = this.clientTestVersion;
var urlNow = window.location.href;
if(this.containsTrain(urlNow)){
console.log("无排行版本");
this.node.getChildByName("Rank").active = false;
}
else{
console.log("有排行版本");
}
}
//判断来源
containsTrain(str) {
return /from=train/i.test(str);
}
setRank(){
let data = {
"totleTimes": 8759,
"accuracy": 80,
}
cc.fx.GameTool.setRank(data);
}
//开始游戏,跳转至引导页面
startGame(){
setTimeout(() => {
cc.director.loadScene("GuideScene");
}, 100);
// cc.director.loadScene("GuideScene");
}
//备用,用来测试跳转 指定关卡
clickBtn(event,data){
// cc.fx.GameConfig.GM_INFO.custom = parseInt(data);
cc.director.loadScene("GameScene");
}
//打开排行榜
openRank(){
setTimeout(() => {
cc.director.loadScene("RankScene");
}, 100);
}
protected update(dt: number): void {
}
}