This commit is contained in:
2025-09-20 12:22:00 +08:00
parent 8a60992052
commit 4d6f8b5bdd
8 changed files with 1321 additions and 1476 deletions
@@ -1,4 +1,5 @@
import { _decorator, Button, Component, Node, NodeEventType, Sprite } from "cc";
import { GButton } from "../../../Main/Common/GButton";
const { ccclass, property } = _decorator;
@ccclass("SimpleToggle")
@@ -14,21 +15,10 @@ export class SimpleToggle extends Component {
btn: Button;
protected onLoad(): void {
this.node.on(NodeEventType.TOUCH_START, this.onClickThis, this);
GButton.BandClick(this.node,this.onClickThis,this);
this.btn = this.getComponent(Button);
}
init(isSelected: boolean, callBack: () => {}) {
this.selectedSprite.node.active = isSelected;
this.unSelectedSprite.node.active = !isSelected;
if (this.callback) {
this.onDestroy();
}
this.callback = callBack;
this.node.on(NodeEventType.TOUCH_START, this.onClickThis, this);
}
refresh(isSelected: boolean) {
this.selectedSprite.node.active = isSelected;
this.unSelectedSprite.node.active = !isSelected;
@@ -45,7 +35,7 @@ export class SimpleToggle extends Component {
}
protected onDestroy(): void {
this.node.off(NodeEventType.TOUCH_START, this.onClickThis, this);
//this.node.off(NodeEventType.TOUCH_START, this.onClickThis, this);
this.callback = null;
}