FocusEff.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. import GuideLabel from "./GuideLabel";
  8. const { ccclass, property } = cc._decorator;
  9. @ccclass
  10. export default class FocusEff extends cc.Component {
  11. @property(cc.Node)
  12. maskNode: cc.Node = null;
  13. @property(cc.Node)
  14. desNode: cc.Node = null;
  15. @property(cc.Node)
  16. loadBlock: cc.Node = null;
  17. @property(cc.Node) //有些步骤的desNode不是直接指向文字内容,重新引用一个新的
  18. talkNode: cc.Node = null;
  19. @property(cc.Node)
  20. headIcon:cc.Node = null
  21. @property(cc.Node)
  22. talkBg:cc.Node = null
  23. // LIFE-CYCLE CALLBACKS:
  24. // onLoad () {}
  25. start() {
  26. }
  27. onEnable() {
  28. this.loadBlock.active = true
  29. this.maskNode.setScale(15)
  30. if (this.desNode) {
  31. this.desNode.active = false
  32. }
  33. if(cc.isValid(this.talkNode)){
  34. this.talkNode.active = false
  35. }
  36. if(cc.isValid(this.headIcon)){
  37. this.headIcon.active = false
  38. }
  39. if(cc.isValid(this.talkBg)){
  40. this.talkBg.active = false
  41. }
  42. cc.tween(this.maskNode)
  43. .to(0.3, { scale: 1 })
  44. .call(() => {
  45. if (this.desNode) {
  46. this.desNode.active = true
  47. }
  48. })
  49. .delay(0.3)
  50. .call(() => {
  51. this.loadBlock.active = false
  52. if(cc.isValid(this.desNode)){
  53. this.desNode.active = true
  54. }
  55. if(cc.isValid(this.headIcon)){
  56. this.headIcon.active = true
  57. }
  58. if(cc.isValid(this.talkBg)){
  59. this.talkBg.active = true
  60. }
  61. if(cc.isValid(this.talkNode)){
  62. this.talkNode.active = true
  63. let gLbale = this.talkNode.addComponent(GuideLabel)
  64. // gLbale.setView()
  65. }
  66. })
  67. .start()
  68. }
  69. // update (dt) {}
  70. }