unit44.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { _decorator, Node, tween, UIOpacity } from 'cc';
  2. import { BaseZhaocha } from '../../hall/script/BaseZhaocha';
  3. import { BundleName } from '../../script/Config/EnumCfg';
  4. import { LayerMgr } from '../../script/Manager/LayerMgr';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('unit44')
  7. export class unit44 extends BaseZhaocha {
  8. override answerName: Array<string> = [
  9. "作业本",
  10. "平板电脑",
  11. "碳纤维",
  12. "不锈钢壶",
  13. "披萨",
  14. "猫粮罐头",
  15. "芭比娃娃",
  16. "动漫贴纸",
  17. "台灯",
  18. "挂历",
  19. "两个月亮",
  20. "蚊香",
  21. ]
  22. override num_showTip: number = 10;
  23. override str_tishi = "拖动月亮旁边的树枝,露出藏在后面的第二个月亮";
  24. @property(Node)
  25. node_cat: Node = null;
  26. startPos = null
  27. override start(): void {
  28. super.start()
  29. this.node_cat.on(Node.EventType.TOUCH_START, this.touchStart, this)
  30. this.node_cat.on(Node.EventType.TOUCH_MOVE, this.touchMove, this)
  31. this.node_cat.on(Node.EventType.TOUCH_END, this.touchEnd, this)
  32. this.node_cat.on(Node.EventType.TOUCH_CANCEL, this.touchEnd, this)
  33. }
  34. touchStart(e) {
  35. this.startPos = e.getUILocation()
  36. }
  37. touchMove() {
  38. }
  39. touchEnd(e) {
  40. let endpos = e.getUILocation()
  41. if (this.startPos.subtract(endpos).length() > 100) {
  42. tween(this.node_cat.getComponent(UIOpacity))
  43. .to(0.5, { opacity: 0 })
  44. .call(() => {
  45. this.node_cat.active = false
  46. this.arr_node_allitem[10].active = true
  47. })
  48. .start()
  49. }
  50. this.startPos = null
  51. }
  52. }