cocos-awesome/assets/Scene/Home/BackHomeBtn.ts

22 lines
429 B
TypeScript
Raw Normal View History

2020-04-01 17:45:37 +00:00
const { ccclass, property } = cc._decorator;
@ccclass
export default class BackHomeBtn extends cc.Component {
static instance: BackHomeBtn = null;
2020-04-02 15:13:21 +00:00
onLoad() {
2020-04-01 17:45:37 +00:00
cc.game.addPersistRootNode(this.node);
BackHomeBtn.instance = this;
this.toggleActive(false);
}
toggleActive(flag: boolean) {
this.node.active = flag;
}
backToHome() {
this.toggleActive(false);
cc.director.loadScene('Home');
}
}