ballonGuide.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import { GameInput } from "../game/Hero";
  2. const {ccclass, property} = cc._decorator;
  3. @ccclass
  4. export default class ballonGuide extends cc.Component {
  5. @property(cc.Animation)
  6. private left:cc.Animation = null;
  7. @property(cc.Animation)
  8. private right:cc.Animation = null;
  9. @property(cc.Animation)
  10. private top:cc.Animation = null;
  11. @property(cc.Animation)
  12. private bottom:cc.Animation = null;
  13. // onLoad () {}
  14. public init(){
  15. this.setShow(true);
  16. this.showTop(false);
  17. this.showBottom(false);
  18. this.showLeft(false);
  19. this.showRight(false);
  20. }
  21. showTop(isShow: boolean, str: string = undefined) {
  22. if (isShow && str) {
  23. this.top.node.getChildByName("lb").getComponent(cc.Label).string = str;
  24. }
  25. if (this.top.node.active == isShow) {
  26. return;
  27. }
  28. this.top.node.active = isShow;
  29. }
  30. showBottom(isShow: boolean, str: string = undefined) {
  31. if (isShow && str) {
  32. this.bottom.node.getChildByName("lb").getComponent(cc.Label).string = str;
  33. }
  34. if (this.bottom.node.active == isShow) {
  35. return;
  36. }
  37. this.bottom.node.active = isShow;
  38. }
  39. showLeft(isShow: boolean, str: string = undefined) {
  40. if (isShow && str) {
  41. this.left.node.getChildByName("lb").getComponent(cc.Label).string = str;
  42. }
  43. if (this.left.node.active == isShow) {
  44. return;
  45. }
  46. this.left.node.active = isShow;
  47. }
  48. showRight(isShow: boolean, str: string = undefined) {
  49. if (isShow && str) {
  50. this.right.node.getChildByName("lb").getComponent(cc.Label).string = str;
  51. }
  52. if (this.right.node.active == isShow) {
  53. return;
  54. }
  55. this.right.node.active = isShow;
  56. }
  57. public setShow(isShow) {
  58. this.node.active = isShow;
  59. }
  60. // public getImpPermit(ipt: GameInput) {
  61. // switch (ipt) {
  62. // case GameInput.down:
  63. // return this.bottom.node.active || !this.hasIptShow();
  64. // case GameInput.leftClick:
  65. // return this.left.node.active || !this.hasIptShow();
  66. // case GameInput.rightClick:
  67. // return this.right.node.active || !this.hasIptShow();
  68. // case GameInput.up:
  69. // return this.top.node.active || !this.hasIptShow();
  70. // default:
  71. // return true;
  72. // break;
  73. // }
  74. // }
  75. // private hasIptShow() {
  76. // return this.bottom.node.active ||
  77. // this.left.node.active ||
  78. // this.right.node.active ||
  79. // this.top.node.active;
  80. // }
  81. // update (dt) {}
  82. }