Loading.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // import playSoundManager from "./Utiles/playSoundManager";
  2. // import Utiles from "./Utiles/Utiles";
  3. import { gameModel } from "./Module/Module";
  4. const { ccclass, property } = cc._decorator;
  5. @ccclass
  6. export default class Loading extends cc.Component {
  7. @property(cc.Node)
  8. privacyBtn: cc.Node = null;
  9. @property(cc.Node)
  10. teamBtn: cc.Node = null;
  11. start() {
  12. const historyScores = localStorage.getItem('historyScores');
  13. if (historyScores) {
  14. gameModel.historyScores = JSON.parse(historyScores);
  15. }
  16. const str: string = 'Loading...';
  17. const node: cc.Node = cc.find('label', this.node);
  18. const node2: cc.Node = cc.find('label/label', this.node);
  19. const t: number = 0.08;
  20. this.playLoadingTextEffect(node, t, str);
  21. this.playLoadingTextEffect(node2, t, str);
  22. this.scheduleOnce((): void => {
  23. const sceneName: string = "Main";
  24. cc.director.loadScene(sceneName);
  25. }, 2);
  26. this.privacyBtn.on('click',this.privacyEvent,this)
  27. this.teamBtn.on('click',this.teamEvent,this)
  28. }
  29. private privacyEvent():void{
  30. cc.sys.openURL('https://span36e.space/privacy.html');
  31. }
  32. private teamEvent():void{
  33. cc.sys.openURL('https://span36e.space');
  34. }
  35. private playLoadingTextEffect(node: cc.Node, t: number, str: string): void {
  36. let strTemp: string = '';
  37. for (let i: number = 0; i < str.length; i++) {
  38. cc.tween(node)
  39. .delay(t * i)
  40. .call((): void => {
  41. strTemp += str[i];
  42. node.getComponent(cc.Label).string = strTemp;
  43. })
  44. .start();
  45. }
  46. }
  47. }