update
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user