unit105.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { _decorator, Node, tween, UIOpacity } from 'cc';
  2. import { BaseZhaocha } from '../../hall/script/BaseZhaocha';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('unit105')
  5. export class unit105 extends BaseZhaocha {
  6. override answerName: Array<string> = [
  7. "灯泡",
  8. "眼镜",
  9. "输电塔",
  10. "酒精灯",
  11. "专科医院",
  12. "避雷针",
  13. "立式空调",
  14. "保安队长",
  15. "橡皮鸭子",
  16. "书包",
  17. "井盖",
  18. ]
  19. // override num_showTip: number = 0;
  20. override str_tishi = "滑动移开烧饼,露出下面的一袋防腐剂";
  21. @property(Node)
  22. node_zhanai: Node = null;
  23. @property(Node)
  24. node_zhanai2: Node = null;
  25. startPos = null
  26. override start(): void {
  27. super.start()
  28. this.node_zhanai.on(Node.EventType.TOUCH_START, this.touchStart, this)
  29. this.node_zhanai.on(Node.EventType.TOUCH_MOVE, this.touchMove, this)
  30. this.node_zhanai.on(Node.EventType.TOUCH_END, this.touchEnd, this)
  31. this.node_zhanai.on(Node.EventType.TOUCH_CANCEL, this.touchEnd, this)
  32. this.node_zhanai2.on(Node.EventType.TOUCH_START, this.touchStart, this)
  33. this.node_zhanai2.on(Node.EventType.TOUCH_MOVE, this.touchMove, this)
  34. this.node_zhanai2.on(Node.EventType.TOUCH_END, this.touchEnd2, this)
  35. this.node_zhanai2.on(Node.EventType.TOUCH_CANCEL, this.touchEnd2, this)
  36. }
  37. touchStart(e) {
  38. this.startPos = e.getUILocation()
  39. }
  40. touchMove() {
  41. }
  42. touchEnd(e) {
  43. let endpos = e.getUILocation()
  44. if (this.startPos.subtract(endpos).length() > 100) {
  45. tween(this.node_zhanai.getComponent(UIOpacity))
  46. .to(0.5, { opacity: 0 })
  47. .call(() => {
  48. this.node_zhanai.active = false
  49. this.arr_node_allitem[0].active = true
  50. })
  51. .start()
  52. }
  53. this.startPos = null
  54. }
  55. touchEnd2(e) {
  56. let endpos = e.getUILocation()
  57. if (this.startPos.subtract(endpos).length() > 100) {
  58. tween(this.node_zhanai2.getComponent(UIOpacity))
  59. .to(0.5, { opacity: 0 })
  60. .call(() => {
  61. this.node_zhanai2.active = false
  62. this.arr_node_allitem[6].active = true
  63. }).start()
  64. }
  65. }
  66. }