unit87.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { _decorator, Node, sp, tween, UIOpacity } from 'cc';
  2. import { BaseZhaocha } from '../../hall/script/BaseZhaocha';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('unit87')
  5. export class unit87 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 = 5;
  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. this.schedule(() => {
  32. this.pig.setAnimation(0, "animation", false)
  33. }, 5)
  34. }
  35. touchStart(e) {
  36. this.startPos = e.getUILocation()
  37. }
  38. touchMove() {
  39. }
  40. touchEnd(e) {
  41. let endpos = e.getUILocation()
  42. if (this.startPos.subtract(endpos).length() > 100) {
  43. tween(this.node_zhanai.getComponent(UIOpacity))
  44. .to(0.5, { opacity: 0 })
  45. .call(() => {
  46. this.node_zhanai.active = false
  47. this.arr_node_allitem[5].active = true
  48. })
  49. .start()
  50. }
  51. this.startPos = null
  52. }
  53. @property(sp.Skeleton)
  54. pig: sp.Skeleton = null;
  55. }