sdkDebugView.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. import EventMgr from "../game/EventMgr";
  8. import { GameEvent } from "../game/GameEvent";
  9. import { GameInput } from "../game/Hero";
  10. import Main from "../game/Main";
  11. const {ccclass, property} = cc._decorator;
  12. @ccclass
  13. export default class sdkDebugView extends cc.Component {
  14. @property(cc.Button)
  15. private btnLeft: cc.Button = null;
  16. @property(cc.Button)
  17. private btnLeftDown: cc.Button = null;
  18. @property(cc.Button)
  19. private btnRight: cc.Button = null;
  20. @property(cc.Button)
  21. private btnRightDown: cc.Button = null;
  22. @property(cc.Button)
  23. private btnUp: cc.Button = null;
  24. @property(cc.Button)
  25. private btnDown: cc.Button = null;
  26. @property(cc.Button)
  27. private btnDebugToggle: cc.Button = null;
  28. @property(cc.Node)
  29. private debugView: cc.Node = null;
  30. // LIFE-CYCLE CALLBACKS:
  31. // onLoad () {}
  32. start () {
  33. this.btnLeft.node.active = false;
  34. this.btnRight.node.active = false;
  35. this.btnLeft.node.on("click",this.on_btnLeft,this);
  36. this.btnLeftDown.node.on("click",this.on_btnLeftDown,this);
  37. this.btnRight.node.on("click",this.on_btnRight,this);
  38. this.btnRightDown.node.on("click",this.on_btnRightDown,this);
  39. this.btnUp.node.on("click",this.on_btnUp,this);
  40. this.btnDown.node.on("click",this.on_btnDown,this);
  41. this.btnDebugToggle.node.on("click",this.on_btnDebugToggle,this);
  42. this.on_btnDebugToggle();
  43. }
  44. on_btnDown(arg0: string, on_btnDown: any, arg2: this) {
  45. EventMgr.Instance.dispatch_event(GameEvent.DebugSDKInput,GameInput.down);
  46. }
  47. on_btnUp(arg0: string, on_btnUp: any, arg2: this) {
  48. // console.error(Main.Ins.EnemyCount);
  49. EventMgr.Instance.dispatch_event(GameEvent.DebugSDKInput,GameInput.up);
  50. }
  51. on_btnRightDown(arg0: string, on_btnRightDown: any, arg2: this) {
  52. // EventMgr.Instance.dispatch_event(GameEvent.DebugSDKInput,GameInput.rightDown);
  53. EventMgr.Instance.dispatch_event(GameEvent.DebugSDKInput,GameInput.rightClick);
  54. }
  55. on_btnRight(arg0: string, on_btnRight: any, arg2: this) {
  56. EventMgr.Instance.dispatch_event(GameEvent.DebugSDKInput,GameInput.rightClick);
  57. }
  58. on_btnLeftDown(arg0: string, on_btnLeftDown: any, arg2: this) {
  59. // EventMgr.Instance.dispatch_event(GameEvent.DebugSDKInput,GameInput.leftDown);
  60. EventMgr.Instance.dispatch_event(GameEvent.DebugSDKInput,GameInput.leftClick);
  61. }
  62. on_btnLeft(arg0: string, on_btnLeft: any, arg2: this) {
  63. EventMgr.Instance.dispatch_event(GameEvent.DebugSDKInput,GameInput.leftDown);
  64. }
  65. private on_btnDebugToggle(){
  66. this.debugView.active = !this.debugView.active;
  67. }
  68. }