unit101.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { _decorator, Node, tween, UIOpacity } from 'cc';
  2. import { BaseZhaocha } from '../../hall/script/BaseZhaocha';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('unit101')
  5. export class unit101 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 = 7;
  21. override str_tishi = "拖动男人上方的灯笼,露出后面的晴天娃娃";
  22. @property(Node)
  23. node_zhanai: Node = null;
  24. startPos = null
  25. override start(): void {
  26. super.start()
  27. this.node_zhanai.on(Node.EventType.TOUCH_START, this.touchStart, this)
  28. this.node_zhanai.on(Node.EventType.TOUCH_MOVE, this.touchMove, this)
  29. this.node_zhanai.on(Node.EventType.TOUCH_END, this.touchEnd, this)
  30. this.node_zhanai.on(Node.EventType.TOUCH_CANCEL, this.touchEnd, this)
  31. }
  32. touchStart(e) {
  33. this.startPos = e.getUILocation()
  34. }
  35. touchMove() {
  36. }
  37. touchEnd(e) {
  38. let endpos = e.getUILocation()
  39. if (this.startPos.subtract(endpos).length() > 100) {
  40. tween(this.node_zhanai.getComponent(UIOpacity))
  41. .to(0.5, { opacity: 0 })
  42. .call(() => {
  43. this.node_zhanai.active = false
  44. this.arr_node_allitem[this.num_showTip].active = true
  45. })
  46. .start()
  47. }
  48. this.startPos = null
  49. }
  50. }