Loading.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // import playSoundManager from "./Utiles/playSoundManager";
  2. // import Utiles from "./Utiles/Utiles";
  3. const { ccclass, property } = cc._decorator;
  4. @ccclass
  5. export default class Loading extends cc.Component {
  6. start() {
  7. const str: string = 'Loading...';
  8. const node: cc.Node = cc.find('label', this.node);
  9. const node2: cc.Node = cc.find('label/label', this.node);
  10. const t: number = 0.08;
  11. this.playLoadingTextEffect(node, t, str);
  12. this.playLoadingTextEffect(node2, t, str);
  13. this.scheduleOnce((): void => {
  14. const sceneName: string = "Main";
  15. cc.director.loadScene(sceneName);
  16. }, t * str.length + 0.3);
  17. // 加载配置数据
  18. // 加载音乐
  19. }
  20. private playLoadingTextEffect(node: cc.Node, t: number, str: string): void {
  21. let strTemp: string = '';
  22. for (let i: number = 0; i < str.length; i++) {
  23. cc.tween(node)
  24. .delay(t * i)
  25. .call((): void => {
  26. strTemp += str[i];
  27. node.getComponent(cc.Label).string = strTemp;
  28. })
  29. .start();
  30. }
  31. }
  32. }