Start.ts 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import { _decorator, Component, Node, Vec3, tween,UIOpacity, director,Button, find } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. @ccclass('Start')
  4. export class Start extends Component {
  5. @property(Node)
  6. progressBar:Node = null;
  7. @property(Node)
  8. bar:Node = null;
  9. @property(Node)
  10. logoPic:Node = null;
  11. @property(Node)
  12. loadingPic:Node = null;
  13. @property(Node)
  14. updatePic:Node = null;
  15. start() {
  16. //this.bar.setScale(2,1);
  17. this.updatePic.getComponent(UIOpacity).opacity = 0;
  18. this.Logo();
  19. }
  20. Logo(){
  21. let opacityLogo = this.logoPic.getComponent(UIOpacity);
  22. tween(opacityLogo)
  23. .call(()=>{opacityLogo.opacity = 10;})
  24. .to(2,{opacity:255})
  25. .call(()=>{this.Loading();opacityLogo.opacity = 0;})
  26. .start();
  27. }
  28. Loading(){
  29. // let opacityLoadingPic = this.loadingPic.getComponent(UIOpacity);
  30. // let opacityProgressBar = this.progressBar.getComponent(UIOpacity);
  31. // tween(opacityLoadingPic)
  32. // .call(()=>{opacityLoadingPic.opacity = 255})
  33. // .start();
  34. // tween(opacityProgressBar)
  35. // .call(()=>{opacityProgressBar.opacity = 255})
  36. // .start();
  37. const setOpacity = (component,targetOpacity) => {
  38. const opacityComponent = component.getComponent(UIOpacity);
  39. tween(opacityComponent)
  40. .call(()=>{opacityComponent.opacity = targetOpacity;})
  41. .start();
  42. }
  43. setOpacity(this.loadingPic,255);
  44. setOpacity(this.progressBar,255);
  45. tween(this.bar)
  46. .call(()=>{this.bar.setScale(0,1)})
  47. .to(2,{scale:new Vec3(2,1)})
  48. .call(()=>{director.loadScene("LoginScene")})
  49. //.call(()=>{this.bar.setScale(1.5,1)})
  50. //.call(()=>{setOpacity(this.updatePic,255);setOpacity(this.loadingPic,0);setOpacity(this.progressBar,0);})
  51. .start();
  52. }
  53. onBtnLogin(){
  54. director.loadScene("SelectScene");
  55. }
  56. update(deltaTime: number) {
  57. }
  58. }
  59. // Loading() {
  60. // const setOpacity = (component, targetOpacity) => {
  61. // const opacityComponent = component.getComponent(UIOpacity);
  62. // tween(opacityComponent)
  63. // .call(() => { opacityComponent.opacity = targetOpacity; })
  64. // .start();
  65. // };
  66. // setOpacity(this.loadingPic, 255);
  67. // setOpacity(this.progressBar, 255);
  68. // tween(this.bar)
  69. // .call(() => { this.bar.setScale(0, 1); })
  70. // .to(2, { scale: new Vec3(2, 1) })
  71. // .start();
  72. // }