Loading.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. AudioArr: { //音频
  5. type: cc.AudioClip,
  6. default: [],
  7. },
  8. },
  9. // LIFE-CYCLE CALLBACKS:
  10. onLoad() {
  11. cc.audioEngine.playMusic(this.AudioArr[0]);
  12. // this.init();
  13. this.progressBar = this.node.getChildByName('prograss_bg').getChildByName('Loading_Bar').getComponent(cc.Sprite);
  14. this.startGame();
  15. },
  16. start() {
  17. },
  18. /**开始游戏 */
  19. startGame() {
  20. // cc.resources.loadDir("", cc.Asset, (completeCount, totalCount) => {
  21. // this.progressBar.fillRange = completeCount / totalCount;
  22. // }, () => {
  23. // this.node.removeAllChildren(true);
  24. // this.node.active = false;
  25. // this.UiController.change_interface(this.UiController.interfacaArr, 0);
  26. // });
  27. cc.resources.loadDir("texture", (completeCount, totalCount) => {
  28. this.progressBar.fillRange = completeCount / totalCount;
  29. }, () => {
  30. cc.director.preloadScene("Game", function() {
  31. cc.director.loadScene("Game");
  32. });
  33. });
  34. },
  35. // update (dt) {},
  36. init() {
  37. this.game = cc.find("Canvas/Game");
  38. this.UiController = cc.find("Canvas/UiController").getComponent('UiController');
  39. },
  40. });