GuideLayer.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. const { ccclass, property } = cc._decorator;
  2. export let guideLayer: GuideLayer = null;
  3. @ccclass
  4. export default class GuideLayer extends cc.Component {
  5. @property(cc.Node)
  6. bgLoadNode: cc.Node = null;
  7. @property(cc.Node)
  8. points: cc.Node = null;
  9. @property(cc.Node)
  10. fjLoadNode: cc.Node = null;
  11. @property(sp.Skeleton)
  12. fjAni: sp.Skeleton = null;
  13. onLoad() {
  14. guideLayer = this;
  15. cc.game.addPersistRootNode(this.node);
  16. this.node.setPosition(cc.winSize.width / 2, cc.winSize.height / 2);
  17. this.node.setContentSize(cc.winSize);
  18. }
  19. start() {
  20. this.showPoint();
  21. this.schedule(this.showPoint, 0.5);
  22. }
  23. /////////////////////// 过渡动画 ///////////////////////////////
  24. curIndex = 0;
  25. /** 点变化效果 */
  26. showPoint() {
  27. for (let i = 0; i < this.points.childrenCount; i++) {
  28. if (i <= this.curIndex) {
  29. this.points.children[i].opacity = 255;
  30. } else {
  31. this.points.children[i].opacity = 0;
  32. }
  33. }
  34. if (++this.curIndex > this.points.childrenCount) {
  35. this.curIndex = 0;
  36. }
  37. }
  38. /** 显示过渡动画 */
  39. showBgAni() {
  40. this.bgLoadNode.active = true;
  41. this.curIndex = 0;
  42. }
  43. /** 隐藏过度动画 */
  44. hideBgAni() {
  45. this.bgLoadNode.active = false;
  46. }
  47. /////////////////////// 加载动画(直升机) ///////////////////////////////
  48. /** 显示飞机动画 */
  49. showFjAni() {
  50. this.fjLoadNode.active = true;
  51. this.fjAni.setAnimation(0, "jiazai", false);
  52. this.fjAni.addAnimation(0, "jiazai2", true);
  53. }
  54. /** 隐藏飞机动画 */
  55. hideFjAni() {
  56. this.fjLoadNode.active = false;
  57. }
  58. }