unit109.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import { _decorator, Node, tween, UIOpacity } from 'cc';
  2. import { BaseZhaocha } from '../../hall/script/BaseZhaocha';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('unit109')
  5. export class unit109 extends BaseZhaocha {
  6. override answerName: Array<string> = [
  7. "弹壳",
  8. "地雷",
  9. "兵牌",
  10. "硬币",
  11. "装甲车",
  12. "独角兽",
  13. "骑士头盔",
  14. "加农炮",
  15. "钻戒",
  16. "火箭",
  17. "巨型骑枪",
  18. "尚方宝剑"
  19. ]
  20. // override num_showTip: number = 0;
  21. override str_tishi = "滑动右边绿色的布条,露出log";
  22. @property(Node)
  23. node_zhanai: Node = null;
  24. @property(Node)
  25. node_zhanai2: Node = null;
  26. startPos = null
  27. override start(): void {
  28. super.start()
  29. this.node_zhanai.on(Node.EventType.TOUCH_START, this.touchStart, this)
  30. this.node_zhanai.on(Node.EventType.TOUCH_MOVE, this.touchMove, this)
  31. this.node_zhanai.on(Node.EventType.TOUCH_END, this.touchEnd, this)
  32. this.node_zhanai.on(Node.EventType.TOUCH_CANCEL, this.touchEnd, this)
  33. this.node_zhanai2.on(Node.EventType.TOUCH_START, this.touchStart, this)
  34. this.node_zhanai2.on(Node.EventType.TOUCH_MOVE, this.touchMove, this)
  35. this.node_zhanai2.on(Node.EventType.TOUCH_END, this.touchEnd2, this)
  36. this.node_zhanai2.on(Node.EventType.TOUCH_CANCEL, this.touchEnd2, this)
  37. }
  38. touchStart(e) {
  39. this.startPos = e.getUILocation()
  40. }
  41. touchMove() {
  42. }
  43. touchEnd(e) {
  44. let endpos = e.getUILocation()
  45. if (this.startPos.subtract(endpos).length() > 100) {
  46. tween(this.node_zhanai.getComponent(UIOpacity))
  47. .to(0.5, { opacity: 0 })
  48. .call(() => {
  49. this.node_zhanai.active = false
  50. this.arr_node_allitem[3].active = true
  51. })
  52. .start()
  53. }
  54. this.startPos = null
  55. }
  56. touchEnd2(e) {
  57. let endpos = e.getUILocation()
  58. if (this.startPos.subtract(endpos).length() > 100) {
  59. tween(this.node_zhanai2.getComponent(UIOpacity))
  60. .to(0.5, { opacity: 0 })
  61. .call(() => {
  62. this.node_zhanai2.active = false
  63. this.arr_node_allitem[1].active = true
  64. }).start()
  65. }
  66. }
  67. }