// Learn TypeScript: // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html import EventMgr from "../game/EventMgr"; import { GameEvent } from "../game/GameEvent"; import { GameInput } from "../game/Hero"; import Main from "../game/Main"; const {ccclass, property} = cc._decorator; @ccclass export default class sdkDebugView extends cc.Component { @property(cc.Button) private btnLeft: cc.Button = null; @property(cc.Button) private btnLeftDown: cc.Button = null; @property(cc.Button) private btnRight: cc.Button = null; @property(cc.Button) private btnRightDown: cc.Button = null; @property(cc.Button) private btnUp: cc.Button = null; @property(cc.Button) private btnDown: cc.Button = null; @property(cc.Button) private btnDebugToggle: cc.Button = null; @property(cc.Node) private debugView: cc.Node = null; // LIFE-CYCLE CALLBACKS: // onLoad () {} start () { this.btnLeft.node.active = false; this.btnRight.node.active = false; this.btnLeft.node.on("click",this.on_btnLeft,this); this.btnLeftDown.node.on("click",this.on_btnLeftDown,this); this.btnRight.node.on("click",this.on_btnRight,this); this.btnRightDown.node.on("click",this.on_btnRightDown,this); this.btnUp.node.on("click",this.on_btnUp,this); this.btnDown.node.on("click",this.on_btnDown,this); this.btnDebugToggle.node.on("click",this.on_btnDebugToggle,this); this.on_btnDebugToggle(); } on_btnDown(arg0: string, on_btnDown: any, arg2: this) { EventMgr.Instance.dispatch_event(GameEvent.DebugSDKInput,GameInput.down); } on_btnUp(arg0: string, on_btnUp: any, arg2: this) { // console.error(Main.Ins.EnemyCount); EventMgr.Instance.dispatch_event(GameEvent.DebugSDKInput,GameInput.up); } on_btnRightDown(arg0: string, on_btnRightDown: any, arg2: this) { // EventMgr.Instance.dispatch_event(GameEvent.DebugSDKInput,GameInput.rightDown); EventMgr.Instance.dispatch_event(GameEvent.DebugSDKInput,GameInput.rightClick); } on_btnRight(arg0: string, on_btnRight: any, arg2: this) { EventMgr.Instance.dispatch_event(GameEvent.DebugSDKInput,GameInput.rightClick); } on_btnLeftDown(arg0: string, on_btnLeftDown: any, arg2: this) { // EventMgr.Instance.dispatch_event(GameEvent.DebugSDKInput,GameInput.leftDown); EventMgr.Instance.dispatch_event(GameEvent.DebugSDKInput,GameInput.leftClick); } on_btnLeft(arg0: string, on_btnLeft: any, arg2: this) { EventMgr.Instance.dispatch_event(GameEvent.DebugSDKInput,GameInput.leftDown); } private on_btnDebugToggle(){ this.debugView.active = !this.debugView.active; } }