StartAnim.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
  7. import EventName from "../EventName/EventName";
  8. import PopComponet from "../Template/PopComponet";
  9. import PopManger from "./PopManger";
  10. const { ccclass, property } = cc._decorator;
  11. @ccclass
  12. export default class StartAnim extends PopComponet {
  13. //让这个动画播放最小的时间
  14. BeastShortTime = 1// 1500
  15. onLoad(): void {
  16. //重写父类 不删除这个 函数
  17. }
  18. start() {
  19. for (let index = 0; index < this.node.childrenCount; index++) {
  20. let item = this.node.getChildByName("item" + index)
  21. cc.tween(item).repeatForever(
  22. cc.tween()
  23. .by(1, { x: 600 })
  24. ).start();
  25. }
  26. let StartTime = cc.sys.now()
  27. this.scheduleOnce(() => {
  28. if (this.isValid) {
  29. PopManger.getInstance().LoadGameScene().then(
  30. (result) => {
  31. if (result == true) {
  32. let XC_Time = cc.sys.now() - StartTime
  33. if ((XC_Time) < this.BeastShortTime) {
  34. setTimeout(() => {
  35. PopManger.getInstance().loadScene_Game()
  36. }, this.BeastShortTime - XC_Time);
  37. } else {
  38. PopManger.getInstance().loadScene_Game()
  39. }
  40. }
  41. }
  42. )
  43. }
  44. }, 0)
  45. }
  46. }