* 初始化系统 * @param obj - 初始化参数 * @param obj.pixiSpine - PixiJS Spine 插件实例
({ pixiSpine })
| 50 | * @param obj.pixiSpine - PixiJS Spine 插件实例 |
| 51 | */ |
| 52 | init({ pixiSpine }) { |
| 53 | this.renderSystem = this.game.getSystem(RendererSystem) as RendererSystem; |
| 54 | this.renderSystem.rendererManager.register(this); |
| 55 | this.pixiSpine = pixiSpine; |
| 56 | this.game.canvas.addEventListener( |
| 57 | 'webglcontextrestored', |
| 58 | () => { |
| 59 | // 重建所有spine |
| 60 | const objs = this.game.gameObjects; |
| 61 | // clearCache(); |
| 62 | let toAdd: any[] = []; |
| 63 | for (let k in this.armatures) { |
| 64 | const id = +k; |
| 65 | for (let i = 0; i < objs.length; ++i) { |
| 66 | let obj = objs[i]; |
| 67 | if (obj.id === id) { |
| 68 | let sp = obj.getComponent(Spine); |
| 69 | if (sp) { |
| 70 | this.remove({ |
| 71 | type: OBSERVER_TYPE.REMOVE, |
| 72 | gameObject: obj, |
| 73 | component: sp, |
| 74 | componentName: Spine.componentName, |
| 75 | }); |
| 76 | toAdd.push({ |
| 77 | type: OBSERVER_TYPE.ADD, |
| 78 | gameObject: obj, |
| 79 | component: sp, |
| 80 | componentName: Spine.componentName, |
| 81 | }); |
| 82 | } |
| 83 | break; |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | setTimeout(() => { |
| 89 | toAdd.forEach(obj => { |
| 90 | this.add(obj); |
| 91 | }); |
| 92 | }, 1000); |
| 93 | }, |
| 94 | false, |
| 95 | ); |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * 每帧更新所有 Spine 动画 |
nothing calls this directly
no test coverage detected