Loading.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import { _decorator, Color, Component, director, Label, Node, resources, SceneAsset, Sprite } from 'cc';
  2. import { DEBUG } from 'cc/env';
  3. import { AdManager } from './MyFrame/AD/AdManager';
  4. import { SDKManager } from './MyFrame/SDK/SDKManager';
  5. import { AudioManager } from './Set/AudioManager';
  6. const { ccclass, property } = _decorator;
  7. @ccclass('Loading')
  8. export class Loading extends Component {
  9. @property(Node)
  10. RankNode: Node = null;
  11. @property(Node)
  12. StartNode: Node = null;
  13. @property(Node)
  14. SliderNode: Node = null;
  15. @property(Node)
  16. SetNode: Node = null;
  17. @property(Node)
  18. TipsNode: Node = null;
  19. @property(Node)
  20. RankPanelNode: Node = null;
  21. @property(Node)
  22. SetPanelNode: Node = null;
  23. protected onLoad(): void {
  24. this.init()
  25. this.Startloading()
  26. AudioManager.Instance.playBgm(AudioManager.BGM)
  27. SDKManager.getInstance().login((res) => {
  28. })
  29. }
  30. init() {
  31. this.RankNode.active = false;
  32. this.SetNode.active = false;
  33. this.StartNode.active = false;
  34. this.TipsNode.active = false;
  35. this.SliderNode.active = true;
  36. this.SliderNode.getComponentInChildren(Sprite).fillRange = 0;
  37. }
  38. Startloading() {
  39. resources.preloadScene('Game', (finished: number, total: number) => {
  40. if ((finished / total) > this.SliderNode.getComponentInChildren(Sprite).fillRange) {
  41. this.SliderNode.getComponentInChildren(Sprite).fillRange = finished / total;
  42. }
  43. }
  44. , (err) => {
  45. if (err) {
  46. console.error(err);
  47. return;
  48. }
  49. this.OverLoading()
  50. console.log('预加载场景成功');
  51. if (DEBUG) {
  52. // this.ClickGame()
  53. }
  54. })
  55. }
  56. OverLoading() {
  57. this.SliderNode.active = false;
  58. this.StartNode.active = true;
  59. this.RankNode.active = true;
  60. this.TipsNode.active = true;
  61. this.SetNode.active = true;
  62. }
  63. ClickGame() {
  64. director.loadScene('Game', (err) => {
  65. if (err) {
  66. console.error(err);
  67. return;
  68. }
  69. console.log('加载场景成功');
  70. })
  71. AudioManager.Instance.playEffict(AudioManager.anniu)
  72. }
  73. ClickRank() {
  74. console.log('点击排行榜');
  75. this.RankPanelNode.active = true;
  76. AudioManager.Instance.playEffict(AudioManager.anniu)
  77. }
  78. ClickSet() {
  79. console.log('点击设置');
  80. this.SetPanelNode.active = true;
  81. AudioManager.Instance.playEffict(AudioManager.anniu)
  82. }
  83. ///////////////////
  84. banner() {
  85. // AdManager.getInstance().showBannerAd()
  86. }
  87. chapinng() {
  88. // AdManager.getInstance().showInterstitialAd()
  89. }
  90. jili() {
  91. // AdManager.getInstance().showRewardVideoAd((res: boolean) => {
  92. // console.log(res);
  93. // })
  94. }
  95. }