Skip to content

ECS Framework API v2.2.13


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
});

Released under the MIT License.