diff --git a/assets/Scene/Home/BackHomeBtn.ts b/assets/Scene/Home/BackHomeBtn.ts index e83a281..7ec30c7 100644 --- a/assets/Scene/Home/BackHomeBtn.ts +++ b/assets/Scene/Home/BackHomeBtn.ts @@ -4,7 +4,7 @@ const { ccclass, property } = cc._decorator; export default class BackHomeBtn extends cc.Component { static instance: BackHomeBtn = null; - start() { + onLoad() { cc.game.addPersistRootNode(this.node); BackHomeBtn.instance = this; this.toggleActive(false); diff --git a/assets/Scene/Home/Home.fire b/assets/Scene/Home/Home.fire index 63be1da..8a3767c 100755 --- a/assets/Scene/Home/Home.fire +++ b/assets/Scene/Home/Home.fire @@ -180,7 +180,7 @@ "array": [ 0, 0, - 443.4050067376326, + 452.9632127266895, 0, 0, 0, diff --git a/assets/Scene/Home/Home.ts b/assets/Scene/Home/Home.ts index c41328a..58cc871 100644 --- a/assets/Scene/Home/Home.ts +++ b/assets/Scene/Home/Home.ts @@ -18,13 +18,34 @@ export default class Home extends cc.Component { this.initScrollItem(); } + start() { + this.judgeJump(); + } + + judgeJump() { + const sceneName = this.getQueryStringByName("sceneName"); + const isSameVisit = window["isSameVisit"]; + + if (!sceneName) return; + if (isSameVisit) return; + + if (sceneList[sceneName]) { + window["isSameVisit"] = true; + this.loadScene(sceneName); + } + } + + getQueryStringByName(name) { + let result = window.location.search.match(new RegExp("[\?\&]" + name+ "=([^\&]+)","i")); + return result == null || result.length < 1 ? "" : result[1]; + } + initScrollItem() { for (let key in sceneList) { let scrollItem = cc.instantiate(this.scrollItemPrefab); scrollItem.getChildByName("label").getComponent(cc.Label).string = sceneList[key]; scrollItem.on(cc.Node.EventType.TOUCH_END, () => { - BackHomeBtn.instance.toggleActive(true); cc.tween(scrollItem) .to(0.1, { scale: 1.05 }) .to(0.1, { scale: 1 }) @@ -38,5 +59,6 @@ export default class Home extends cc.Component { loadScene(key) { cc.director.loadScene(key); + BackHomeBtn.instance.toggleActive(true); } }