Loading.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. @property(cc.Node)
  7. privacyBtn: cc.Node = null;
  8. @property(cc.Node)
  9. teamBtn: cc.Node = null;
  10. start() {
  11. const str: string = 'Loading...';
  12. const node: cc.Node = cc.find('label', this.node);
  13. const node2: cc.Node = cc.find('label/label', this.node);
  14. const t: number = 0.08;
  15. this.playLoadingTextEffect(node, t, str);
  16. this.playLoadingTextEffect(node2, t, str);
  17. this.scheduleOnce((): void => {
  18. const sceneName: string = "Main";
  19. cc.director.loadScene(sceneName);
  20. }, t * str.length + 0.3);
  21. this.privacyBtn.on('click',this.privacyEvent,this)
  22. this.teamBtn.on('click',this.teamEvent,this)
  23. }
  24. private privacyEvent():void{
  25. cc.sys.openURL('https://span36e.space/privacy.html');
  26. }
  27. private teamEvent():void{
  28. cc.sys.openURL('https://span36e.space');
  29. }
  30. private playLoadingTextEffect(node: cc.Node, t: number, str: string): void {
  31. let strTemp: string = '';
  32. for (let i: number = 0; i < str.length; i++) {
  33. cc.tween(node)
  34. .delay(t * i)
  35. .call((): void => {
  36. strTemp += str[i];
  37. node.getComponent(cc.Label).string = strTemp;
  38. })
  39. .start();
  40. }
  41. }
  42. }