Skip to content

ECS Framework API v2.2.13


ECS Framework API / updateComponent

Function: updateComponent()

updateComponent<T>(entity, componentType, data): boolean

Defined in: packages/core/src/ECS/TypedEntity.ts:183

更新组件的部分字段

Type Parameters

T

T extends ComponentConstructor

Parameters

entity

Entity

实体实例

componentType

T

组件类型构造函数

data

Partial<ComponentInstance<T>>

要更新的部分数据

Returns

boolean

如果更新成功返回true,组件不存在返回false

Example

typescript
updateComponent(entity, Position, { x: 100 });

Released under the MIT License.