TestScene.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /** @format */
  2. import {Data, GameControl, Mgr} from '../GameControl'
  3. import {Log} from '../utils/LogUtils'
  4. import {ccUtils} from '../utils/ccUtils'
  5. import {UI} from '../enums/UI'
  6. /** @format */
  7. const {ccclass, property} = cc._decorator
  8. @ccclass
  9. export default class TestScene extends cc.Component {
  10. async onLoad() {
  11. await this.startGame()
  12. }
  13. async startGame() {
  14. //开启动态合图
  15. cc.macro.CLEANUP_IMAGE_CACHE = false
  16. let isInit = await GameControl.init()
  17. if (!isInit) {
  18. Log.error('游戏初始化失败')
  19. return
  20. }
  21. Data.game.gameBundle = await ccUtils.getBundleAsync('game')
  22. Data.main.texBundle = await ccUtils.getBundleAsync('texture')
  23. //加载所有角色spine
  24. Data.main.texBundle.loadDir('Public/role/spine', sp.SkeletonData, (error, assets: sp.SkeletonData[]) => {
  25. if (error) {
  26. Log.error(error)
  27. } else {
  28. for (let i = 0; i < assets.length; i++) {
  29. Data.main.roleSpineMap.set(assets[i].name, assets[i])
  30. //近战spine释放
  31. assets[i]['_ref'] = Infinity
  32. }
  33. Mgr.ui.show(UI.GameLoadingUI)
  34. }
  35. })
  36. }
  37. }