21 lines
591 B
TypeScript
21 lines
591 B
TypeScript
import { _decorator, Component, Node, SpringJoint2D, Sprite } from "cc";
|
|||
|
|
const { ccclass, property } = _decorator;
|
||
|
|
|
||
|
|
@ccclass("NavigationBtn")
|
||
|
|
export class NavigationBtn extends Component {
|
||
|
|
focus: Node;
|
||
|
|
unfocus: Node;
|
||
|
|
|
||
|
|
start() {
|
||
|
|
this.focus = this.node.getChildByName("focus");
|
||
|
|
this.unfocus = this.node.getChildByName("unfocus");
|
||
|
|
}
|
||
|
|
|
||
|
|
setFocus(focus: boolean) {
|
||
|
|
if (!this.focus) this.focus = this.node.getChildByName("focus");
|
||
|
|
if (!this.unfocus) this.unfocus = this.node.getChildByName("unfocus");
|
||
|
|
this.focus.active = focus;
|
||
|
|
this.unfocus.active = !focus;
|
||
|
|
}
|
||
|
|
}
|