mirror of
https://github.com/cheney2013/UIState.git
synced 2024-12-26 03:39:10 +00:00
33 lines
830 B
TypeScript
33 lines
830 B
TypeScript
|
import { Button, Component, Node, NodeEventType, _decorator } from 'cc';
|
||
|
import UIState from './component/UIState';
|
||
|
const { ccclass, property } = _decorator;
|
||
|
|
||
|
@ccclass('Main')
|
||
|
export class Main extends Component {
|
||
|
@property(Button)
|
||
|
btnChangeOutter:Button;
|
||
|
|
||
|
@property(Button)
|
||
|
btnChangeInner:Button;
|
||
|
|
||
|
@property(Node)
|
||
|
innerBox:Node;
|
||
|
|
||
|
start() {
|
||
|
this.btnChangeOutter.node.on(NodeEventType.TOUCH_END, () => {
|
||
|
const uiState = this.node.getComponent(UIState);
|
||
|
uiState.state = uiState.state === 0 ? 1 : 0;
|
||
|
});
|
||
|
this.btnChangeInner.node.on(NodeEventType.TOUCH_END, () => {
|
||
|
const uiState = this.innerBox.getComponent(UIState);
|
||
|
uiState.state = uiState.state === 0 ? 1 : 0;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
update(deltaTime: number) {
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|