Loading.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. SDKManager.getInstance().showShareMenu()
  30. }
  31. init() {
  32. this.RankNode.active = false;
  33. this.SetNode.active = false;
  34. this.StartNode.active = false;
  35. this.TipsNode.active = false;
  36. this.SliderNode.active = true;
  37. this.SliderNode.getComponentInChildren(Sprite).fillRange = 0;
  38. }
  39. Startloading() {
  40. resources.preloadScene('Game', (finished: number, total: number) => {
  41. if ((finished / total) > this.SliderNode.getComponentInChildren(Sprite).fillRange) {
  42. this.SliderNode.getComponentInChildren(Sprite).fillRange = finished / total;
  43. }
  44. }
  45. , (err) => {
  46. if (err) {
  47. console.error(err);
  48. return;
  49. }
  50. this.OverLoading()
  51. console.log('预加载场景成功');
  52. if (DEBUG) {
  53. // this.ClickGame()
  54. }
  55. })
  56. }
  57. OverLoading() {
  58. this.SliderNode.active = false;
  59. this.StartNode.active = true;
  60. this.RankNode.active = true;
  61. this.TipsNode.active = true;
  62. this.SetNode.active = true;
  63. }
  64. ClickGame() {
  65. director.loadScene('Game', (err) => {
  66. if (err) {
  67. console.error(err);
  68. return;
  69. }
  70. console.log('加载场景成功');
  71. })
  72. AudioManager.Instance.playEffict(AudioManager.anniu)
  73. }
  74. ClickRank() {
  75. console.log('点击排行榜');
  76. this.RankPanelNode.active = true;
  77. AudioManager.Instance.playEffict(AudioManager.anniu)
  78. }
  79. ClickSet() {
  80. console.log('点击设置');
  81. this.SetPanelNode.active = true;
  82. AudioManager.Instance.playEffict(AudioManager.anniu)
  83. }
  84. ///////////////////
  85. banner() {
  86. // AdManager.getInstance().showBannerAd()
  87. }
  88. chapinng() {
  89. // AdManager.getInstance().showInterstitialAd()
  90. }
  91. jili() {
  92. // AdManager.getInstance().showRewardVideoAd((res: boolean) => {
  93. // console.log(res);
  94. // })
  95. }
  96. }