Commit bf4a5f1e authored by liujiangnan's avatar liujiangnan

feat: 两个模板切换

parent 0c348dfe
......@@ -2350,13 +2350,13 @@
"_id": "29zXboiXFBKoIV4PQ2liTe"
},
{
"__type__": "408a6f4ZfpM8Yzyg+IOGg/V",
"__type__": "ffc5e624+xCM7xwIqMER6Q1",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_id": "eaTVUpqahPfZeO9+sUI7RP"
"_id": "9f4msEcbtAJ7R3B1Cn2/Jy"
}
]
\ No newline at end of file
......@@ -4,7 +4,7 @@ import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SceneComponent extends MyCocosSceneComponent {
export default class Learning extends MyCocosSceneComponent {
addPreloadImage() {
}
......
......@@ -4,7 +4,7 @@ import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SceneComponent extends MyCocosSceneComponent {
export default class Playing extends MyCocosSceneComponent {
@property(cc.AudioClip)
bgMusic1: cc.AudioClip = null;
......
......@@ -4,7 +4,7 @@ import { callNetworkApiGet } from "../script/util";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SceneComponent extends MyCocosSceneComponent {
export default class Syllabus extends MyCocosSceneComponent {
addPreloadImage() {
}
......
......@@ -75,28 +75,6 @@ cc.Class({
}
},
onMiddleLayerLoadingFinish() {
if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
jsb.reflection.callStaticMethod(
"RootViewController",
"getMiddleLayerInfoFinish:",
""
);
}
if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
jsb.reflection.callStaticMethod(
"com/iplayabc/cocos/AppActivity",
"getMiddleLayerInfoFinish",
"(Ljava/lang/String;)Ljava/lang/String;",
""
);
}
},
// 需要预加载的数量
preloadCount: null,
// 统计已加载的数量
loadedCount: null,
isDev: null,
engineCode: null, // 机器唯一编码
......@@ -105,10 +83,6 @@ cc.Class({
// 统一释放异步资源的方法
async onLoad() {
this.preloadCount = 0;
this.loadedCount = 0;
initAir(this);
this.reWriteAir();
await this.getBaseUrl();
......@@ -123,7 +97,6 @@ cc.Class({
this.initListener();
this.showWaitingLetters();
// this.onMiddleLayerLoadingFinish();
const words = cc.sys.localStorage.getItem("wordIds");
if (words) {
......@@ -216,38 +189,10 @@ cc.Class({
this.currentSceneName = bundleName;
this.showWaitingLetters();
const data = await this.callNetworkApiGet(`/api/template/v1/${bundleName}`, {}, `http://openapi.iteachabc.com`);
let configData = null;
if (cc.sys.os == cc.sys.OS_IOS) {
configData = data.data.conf.ios;
} else if (cc.sys.os == cc.sys.OS_ANDROID) {
configData = data.data.conf.android;
} else {
configData = data.data.conf.web_desktop;
}
const sceneName = configData.sceneName;
const version = configData.version;
const bondleUrl = configData.bondleUrl;
this.loadBundle(sceneName, version, bondleUrl);
this.loadBundle(bundleName);
},
loadBundle(sceneName, version, bondleUrl) {
cc.assetManager.loadBundle(bondleUrl, { version: version }, async (err, bundle) => {
if (err) {
console.error(err);
return;
}
bundle.loadScene(sceneName, null, null, (err, scene) => {
if (err) {
console.error(err);
}
cc.director.runScene(scene, null, () => {
const Canvas = cc.find('Canvas');
const middleLayer = cc.find('middleLayer');
Canvas.getComponent(cc.Widget).updateAlignment();
middleLayer.scale = Canvas.width / middleLayer.width;
});
});
});
loadBundle(bundleName) {
cc.director.loadScene(bundleName);
},
showWaitingLetters() {
......
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