uiGuideHand.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import tween = cc.tween;
  2. const {ccclass, property} = cc._decorator;
  3. /**
  4. * 指引
  5. */
  6. @ccclass
  7. export default class UiGuideHand extends cc.Component {
  8. @property(cc.SpriteFrame)
  9. handSpriteFrames: cc.SpriteFrame [] = [];
  10. @property(cc.Node)
  11. cycleNode: cc.Node = null;
  12. @property(cc.Node)
  13. maskNode: cc.Node = null;
  14. @property(cc.Sprite)
  15. handSprite: cc.Sprite = null;
  16. cycleTime = 0.5;
  17. handTime = 0.5;
  18. onLoad() {
  19. tween(this.handSprite.node)
  20. .repeatForever(tween(this.handSprite.node)
  21. .call(() => {
  22. this.cycleNode.opacity = 255;
  23. this.cycleNode.scale = 0.2;
  24. tween(this.cycleNode)
  25. .to(0.8,{scale:2,opacity:0})
  26. .start();
  27. this.handSprite.spriteFrame = this.handSpriteFrames[1]
  28. })
  29. .delay(this.handTime)
  30. .call(() => {
  31. this.handSprite.spriteFrame = this.handSpriteFrames[0];
  32. })
  33. .delay(this.handTime)
  34. .start())
  35. .start();
  36. }
  37. init(node:cc.Node){
  38. this.node.position = node.position;
  39. }
  40. onEnable() {
  41. this.maskNode.on('touchstart', this.onTouchStart, this);
  42. }
  43. onDestroy() {
  44. this.maskNode.off('touchstart', this.onTouchStart, this);
  45. }
  46. clickSelf(){
  47. this.node.destroy();
  48. }
  49. onTouchStart(event:Event){
  50. this.node.destroy();
  51. //抛出事件
  52. //@ts-ignore
  53. this.maskNode._touchListener.setSwallowTouches(false);
  54. }
  55. }