添加query跳转

This commit is contained in:
ifengzp 2020-04-02 23:13:21 +08:00
parent e74442f8bb
commit 581ad72792
3 changed files with 25 additions and 3 deletions

View File

@ -4,7 +4,7 @@ const { ccclass, property } = cc._decorator;
export default class BackHomeBtn extends cc.Component { export default class BackHomeBtn extends cc.Component {
static instance: BackHomeBtn = null; static instance: BackHomeBtn = null;
start() { onLoad() {
cc.game.addPersistRootNode(this.node); cc.game.addPersistRootNode(this.node);
BackHomeBtn.instance = this; BackHomeBtn.instance = this;
this.toggleActive(false); this.toggleActive(false);

View File

@ -180,7 +180,7 @@
"array": [ "array": [
0, 0,
0, 0,
443.4050067376326, 452.9632127266895,
0, 0,
0, 0,
0, 0,

View File

@ -18,13 +18,34 @@ export default class Home extends cc.Component {
this.initScrollItem(); 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() { initScrollItem() {
for (let key in sceneList) { for (let key in sceneList) {
let scrollItem = cc.instantiate(this.scrollItemPrefab); let scrollItem = cc.instantiate(this.scrollItemPrefab);
scrollItem.getChildByName("label").getComponent(cc.Label).string = sceneList[key]; scrollItem.getChildByName("label").getComponent(cc.Label).string = sceneList[key];
scrollItem.on(cc.Node.EventType.TOUCH_END, () => { scrollItem.on(cc.Node.EventType.TOUCH_END, () => {
BackHomeBtn.instance.toggleActive(true);
cc.tween(scrollItem) cc.tween(scrollItem)
.to(0.1, { scale: 1.05 }) .to(0.1, { scale: 1.05 })
.to(0.1, { scale: 1 }) .to(0.1, { scale: 1 })
@ -38,5 +59,6 @@ export default class Home extends cc.Component {
loadScene(key) { loadScene(key) {
cc.director.loadScene(key); cc.director.loadScene(key);
BackHomeBtn.instance.toggleActive(true);
} }
} }