unit135.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { _decorator, Node, tween, UIOpacity } from 'cc';
  2. import { BaseZhaocha } from '../../hall/script/BaseZhaocha';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('unit135')
  5. export class unit135 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[6].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[8].active = true
  64. }).start()
  65. }
  66. }
  67. }