* 将实体添加到此场景,并返回它 * @param name 实体名称
(name: string)
| 620 | * @param name 实体名称 |
| 621 | */ |
| 622 | public createEntity(name: string) { |
| 623 | const entity = new Entity(name, this.identifierPool.checkOut()); |
| 624 | |
| 625 | const handle = this.handleManager.create(); |
| 626 | entity.setHandle(handle); |
| 627 | this._handleToEntity.set(handle, entity); |
| 628 | |
| 629 | this.eventSystem.emitSync('entity:created', { entityName: name, entity, scene: this }); |
| 630 | |
| 631 | return this.addEntity(entity); |
| 632 | } |
| 633 | |
| 634 | /** |
| 635 | * 清除所有EntitySystem的实体缓存 |