ECS Framework API / addAndConfigure
Function: addAndConfigure()
addAndConfigure<
T>(entity,component,configure):Entity
Defined in: packages/core/src/ECS/TypedEntity.ts:132
添加组件并立即配置
Type Parameters
T
T extends Component
Parameters
entity
实体实例
component
T
组件实例
configure
(component) => void
配置回调函数
Returns
实体实例(支持链式调用)
Example
typescript
addAndConfigure(entity, new Health(), health => {
health.maxValue = 100;
health.value = 50;
});