Loading.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. AudioArr: { //音频
  5. type: cc.AudioClip,
  6. default: [],
  7. },
  8. ProgressBar: cc.Sprite,
  9. },
  10. // LIFE-CYCLE CALLBACKS:
  11. onLoad() {
  12. cc.audioEngine.playMusic(this.AudioArr[0]);
  13. this.startGame();
  14. },
  15. start() {
  16. },
  17. /**开始游戏 */
  18. startGame() {
  19. //let bundle = cc.assetManager.getBundle('01_graphics');
  20. this.ProgressBar.node.parent.active = true;
  21. //开始加载远程资源
  22. for (let i = 0; i < 100; i++) {
  23. this.schedule(function() {
  24. //对Sprite组件上的属性修改
  25. this.ProgressBar.fillRange += 0.01;
  26. cc.resources.loadDir("assets", (completeCount, totalCount) => {
  27. }, () => {
  28. cc.director.loadScene('Game');
  29. });
  30. }, (4 / 100) * i);
  31. }
  32. // cc.resources.loadDir("assets", (completeCount, totalCount) => {
  33. // this.ProgressBar.fillRange = completeCount / totalCount;
  34. // }, () => {
  35. // cc.director.loadScene('Game');
  36. // });
  37. // cc.loader.loadResDir('assets', cc.Asset, (completeCount, totalCount) => {
  38. // this.ProgressBar.fillRange = completeCount / totalCount;
  39. // }, () => {
  40. // cc.director.loadScene('Game');
  41. // });
  42. }
  43. // update (dt) {},
  44. });