客户端版本低,则会跳转下载最新版本!
/*
*跳转场景方法
*/
loadScene_Function: function () {
let path = this.playerInfo.loginIp + "/checkVersion";
let instance = this;
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState === 4 && xhr.status === 200) {
if (!!xhr.response) {
try {
const response = JSON.parse(xhr.response);
if (response.version == instance.playerInfo.versionCode) {
// progressUI
cc.director.preloadScene('LobbyMain', (cc, tc, item) => {
this.progressUI.progress = cc / tc;
}, () => {
cc.director.loadScene("LobbyMain");
})
} else {
let board = cc.find('Canvas/com_NewVersion');
board.active = true;
window.versionUrl = response.url;
}
} catch (e) {
console.error('json解析错误');
}
}
}
}
xhr.open("post", path);
xhr.send();
此代码来自完整的电玩游戏项目,需要了解更详细代码,请加 QQ : 2307844569
扫码体验游戏:
点击链接体验游戏:
http://game.cdn.bogolo.cn/dwc_jieji_h5/server164/