1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import Button from '../game/Button';
- import EventMgr from '../game/EventMgr';
- import { GameEvent } from '../game/GameEvent';
- import { SDK as sdk, CMD} from '../game/sdk';
- import { SDKIpt } from '../game/SDKIpt';
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class gameRank extends cc.Component {
- @property(cc.Node)
- private mainView:cc.Node = null
- @property(cc.Button)
- btnQuitCancel: cc.Button = null;
- @property(cc.Button)
- btnQuitConfirn: cc.Button = null;
- private get isActive(): boolean { return this.node.active; }
- private index:number = 1
-
- start () {
- this.btnQuitCancel.node.on("click",this.quit,this);
- this.btnQuitConfirn.node.on("click",this.confirn,this);
- EventMgr.Instance.add_event_listenner(GameEvent.SDK_UI_IPT,this,this.ON_SDK_UI_IPT);
- }
- protected onDestroy(): void {
- EventMgr.Instance.remove_event_listenner(GameEvent.SDK_UI_IPT,this,this.ON_SDK_UI_IPT);
- }
- ON_SDK_UI_IPT(SDK_UI_IPT: GameEvent, ipt: SDKIpt, ON_SDK_UI_IPT: any) {
-
- console.error("mainview 收到 sdk 动作:"+ipt );
- if (!this.isActive) { return; }
- switch (ipt) {
- case SDKIpt.left:
- this.index = this.index===1?0:1
- this._ButtonActive()
- break;
- case SDKIpt.right:
- this.index = this.index===0?1:0
- this._ButtonActive()
- break;
- case SDKIpt.rightFoot://主界面确认进入游戏//y
- if(this.index === 0)
- this.quit();
- else
- this.confirn();
- break;
- case SDKIpt.leftFoot:
-
- break;
- default:
- break;
- }
-
- }
- openDialog(){
- this.node.active = true;
- this.index = 1
- this._ButtonActive()
- }
- quit(){
- this.node.active = false
- this.mainView.active = true
- }
- confirn(){
- EventMgr.Instance.dispatch_event(GameEvent.SDK_QUIT);
- }
- _ButtonActive(){
- if(this.index == 0){
- this.btnQuitCancel.node.getComponent(Button).selected();
- this.btnQuitConfirn.node.getComponent(Button).unselected()
- }else{
- this.btnQuitCancel.node.getComponent(Button).unselected();
- this.btnQuitConfirn.node.getComponent(Button).selected()
- }
- }
- }
|