Commit bf4a5f1e authored by liujiangnan's avatar liujiangnan

feat: 两个模板切换

parent 0c348dfe
...@@ -2350,13 +2350,13 @@ ...@@ -2350,13 +2350,13 @@
"_id": "29zXboiXFBKoIV4PQ2liTe" "_id": "29zXboiXFBKoIV4PQ2liTe"
}, },
{ {
"__type__": "408a6f4ZfpM8Yzyg+IOGg/V", "__type__": "ffc5e624+xCM7xwIqMER6Q1",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 2 "__id__": 2
}, },
"_enabled": true, "_enabled": true,
"_id": "eaTVUpqahPfZeO9+sUI7RP" "_id": "9f4msEcbtAJ7R3B1Cn2/Jy"
} }
] ]
\ No newline at end of file
...@@ -4,7 +4,7 @@ import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent"; ...@@ -4,7 +4,7 @@ import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class SceneComponent extends MyCocosSceneComponent { export default class Learning extends MyCocosSceneComponent {
addPreloadImage() { addPreloadImage() {
} }
......
...@@ -4,7 +4,7 @@ import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent"; ...@@ -4,7 +4,7 @@ import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class SceneComponent extends MyCocosSceneComponent { export default class Playing extends MyCocosSceneComponent {
@property(cc.AudioClip) @property(cc.AudioClip)
bgMusic1: cc.AudioClip = null; bgMusic1: cc.AudioClip = null;
......
...@@ -4,7 +4,7 @@ import { callNetworkApiGet } from "../script/util"; ...@@ -4,7 +4,7 @@ import { callNetworkApiGet } from "../script/util";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class SceneComponent extends MyCocosSceneComponent { export default class Syllabus extends MyCocosSceneComponent {
addPreloadImage() { addPreloadImage() {
} }
......
...@@ -75,28 +75,6 @@ cc.Class({ ...@@ -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, isDev: null,
engineCode: null, // 机器唯一编码 engineCode: null, // 机器唯一编码
...@@ -105,10 +83,6 @@ cc.Class({ ...@@ -105,10 +83,6 @@ cc.Class({
// 统一释放异步资源的方法 // 统一释放异步资源的方法
async onLoad() { async onLoad() {
this.preloadCount = 0;
this.loadedCount = 0;
initAir(this); initAir(this);
this.reWriteAir(); this.reWriteAir();
await this.getBaseUrl(); await this.getBaseUrl();
...@@ -123,7 +97,6 @@ cc.Class({ ...@@ -123,7 +97,6 @@ cc.Class({
this.initListener(); this.initListener();
this.showWaitingLetters(); this.showWaitingLetters();
// this.onMiddleLayerLoadingFinish();
const words = cc.sys.localStorage.getItem("wordIds"); const words = cc.sys.localStorage.getItem("wordIds");
if (words) { if (words) {
...@@ -216,38 +189,10 @@ cc.Class({ ...@@ -216,38 +189,10 @@ cc.Class({
this.currentSceneName = bundleName; this.currentSceneName = bundleName;
this.showWaitingLetters(); this.showWaitingLetters();
const data = await this.callNetworkApiGet(`/api/template/v1/${bundleName}`, {}, `http://openapi.iteachabc.com`); this.loadBundle(bundleName);
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);
}, },
loadBundle(sceneName, version, bondleUrl) { loadBundle(bundleName) {
cc.assetManager.loadBundle(bondleUrl, { version: version }, async (err, bundle) => { cc.director.loadScene(bundleName);
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;
});
});
});
}, },
showWaitingLetters() { 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