unit68.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { _decorator, Node, tween, UIOpacity, utils } from 'cc';
  2. import { BaseZhaocha } from '../../hall/script/BaseZhaocha';
  3. import { AudioManager } from '../../script/Manager/AudioMgr';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('unit68')
  6. export class unit68 extends BaseZhaocha {
  7. override answerName: Array<string> = [
  8. "烟囱",
  9. "应援牌",
  10. "应援棒",
  11. "麦克风",
  12. "吉他",
  13. "电子琴",
  14. "音响",
  15. "洞洞鞋",
  16. "演出海报",
  17. "射灯",
  18. "牛打鼓",
  19. "卡通上衣",
  20. ]
  21. override num_showTip: number = 0;
  22. override str_tishi = "拖动城墙上的猫咪,露出藏在后面的烟囱";
  23. @property(Node)
  24. node_cat: Node = null;
  25. startPos = null
  26. override start(): void {
  27. super.start()
  28. this.node_cat.on(Node.EventType.TOUCH_START, this.touchStart, this)
  29. this.node_cat.on(Node.EventType.TOUCH_MOVE, this.touchMove, this)
  30. this.node_cat.on(Node.EventType.TOUCH_END, this.touchEnd, this)
  31. this.node_cat.on(Node.EventType.TOUCH_CANCEL, this.touchEnd, this)
  32. }
  33. touchStart(e) {
  34. this.startPos = e.getUILocation()
  35. }
  36. touchMove() {
  37. }
  38. touchEnd(e) {
  39. let endpos = e.getUILocation()
  40. if (this.startPos.subtract(endpos).length() > 100) {
  41. AudioManager.instance.playOtherBundleAudio("unit68", 'cat')
  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[0].active = true
  47. })
  48. .start()
  49. }
  50. this.startPos = null
  51. }
  52. }