ECS Framework API / createQuery
Function: createQuery()
createQuery():
TypedQueryBuilder<[], [], []>
Defined in: packages/core/src/ECS/Core/Query/TypedQuery.ts:372
创建类型安全的查询构建器
Returns
TypedQueryBuilder<[], [], []>
Example
typescript
const query = createQuery()
.withAll(Position, Velocity)
.withNone(Disabled);
// 在System或Scene中使用
const entities = scene.query(query);
entities.forEach(entity => {
const pos = entity.getComponent(Position); // 自动推断为Position
const vel = entity.getComponent(Velocity); // 自动推断为Velocity
});