Commit 1c35a0b2 authored by 范雪寒's avatar 范雪寒

feat:

parent f9bdbc38
......@@ -105,10 +105,18 @@ export abstract class middleLayerBase extends cc.Component {
this.loadBundle(sceneName, version, bondleUrl);
}
loadBundle(sceneName, version, bondleUrl) {
async loadBundle(sceneName, version, bondleUrl) {
this.currentBundleInfo = { sceneName, version, bondleUrl };
this.showMask();
this.showWaitingLetters();
const oldSceneName = this.currentBundleInfo?.sceneName;
const engineInfo = await this.getEngineInfo();
const { isChanged } = JSON.parse(engineInfo);
if (isChanged) {
await this.checkRotateScreen(oldSceneName, sceneName);
}
cc.assetManager.loadBundle(bondleUrl, { version: version }, async (err, bundle) => {
bundle.loadScene(sceneName, null, null, (err, scene) => {
const btnRestart = cc.find('middleLayer/BtnRestart');
......@@ -129,6 +137,41 @@ export abstract class middleLayerBase extends cc.Component {
});
}
checkRotateScreen(oldSceneName: string, newSceneName: string) {
const sceneNameList = ['op_16'];
if (sceneNameList.includes(oldSceneName) || sceneNameList.includes(newSceneName)) {
return new Promise((resolve, reject) => {
if (sceneNameList.includes(newSceneName)) {
// 如果已经是竖屏了
if (cc.view.getCanvasSize().width < cc.view.getCanvasSize().height) {
resolve(null);
return;
}
// 旋转到竖屏
(<any>window).courseware.onConfigurationPortrait({}, async () => {
while (cc.view.getCanvasSize().width > cc.view.getCanvasSize().height) {
await asyncDelay(0.1);
}
resolve(null);
});
} else {
// 如果已经是横屏了
if (cc.view.getCanvasSize().width > cc.view.getCanvasSize().height) {
resolve(null);
return;
}
// 旋转到横屏
(<any>window).courseware.onConfigurationLandscape({}, async () => {
while (cc.view.getCanvasSize().width < cc.view.getCanvasSize().height) {
await asyncDelay(0.1);
}
resolve(null);
});
}
});
}
}
courses = null;
courseIndex = 0;
courseItem = null;
......@@ -223,4 +266,8 @@ export abstract class middleLayerBase extends cc.Component {
cc.log(str);
}
}
\ No newline at end of file
}
function asyncDelay(arg0: number) {
throw new Error("Function not implemented.");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment