Closed fanmingfei closed 2 years ago
在 添加 RendererSystem 之前 new GameObject,会出现这种情况,因为 RendererSystem 会针对每个 GameObject 创建渲染容器,如果 RendererSystem 添加之前创建的 GameObject 不会生效。
import { Game, GameObject, resource, RESOURCE_TYPE } from '@eva/eva.js'; import { RendererSystem } from '@eva/plugin-renderer'; import { Img, ImgSystem } from '@eva/plugin-renderer-img'; resource.addResource([ { name: 'imageName', type: RESOURCE_TYPE.IMAGE, src: { image: { type: 'png', url: 'https://gw.alicdn.com/tfs/TB1DNzoOvb2gK0jSZK9XXaEgFXa-658-1152.webp', }, }, preload: true, }, ]); const image = new GameObject('image', { size: { width: 750, height: 1319 }, origin: { x: 0, y: 0 }, position: { x: 0, y: -319, }, anchor: { x: 0, y: 0, }, }); const game = new Game({ systems: [ new RendererSystem({ canvas: document.querySelector('#canvas'), width: 750, height: 1000, }), new ImgSystem(), ], }); image.addComponent( new Img({ resource: 'imageName', }), ); game.scene.addChild(image);
Eva.js
Expected Behavior
Current Behavior
在 添加 RendererSystem 之前 new GameObject,会出现这种情况,因为 RendererSystem 会针对每个 GameObject 创建渲染容器,如果 RendererSystem 添加之前创建的 GameObject 不会生效。
Possible Solution
Steps to Reproduce
Eva.js
version: 1.2.3