unit107.ts 2.4 KB

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