1#include <each_w_entity_callback.h>
2#include <iostream>
3
4
5
6
7struct Position {
8 double x, y;
9};
10
11struct Velocity {
12 double x, y;
13};
14
15int main(int, char *[]) {
17
18
20 ecs.
query<Position,
const Velocity>();
21
22
24 .set<Position>({10, 20})
25 .set<Velocity>({1, 2});
26
28 .set<Position>({10, 20})
29 .set<Velocity>({3, 4});
30
31
33 .set<Position>({10, 20});
34
35
37 p.x += v.x;
38 p.y += v.y;
39 std::cout << e.
name() <<
": {" << p.x <<
", " << p.y <<
"}\n";
40 });
41
42
43
44
45}
conditional_t< sizeof...(Args)==0 &&_::is_sparse_query< Comps... >::value, flecs::sparse_query< Comps... >, flecs::query< Comps... > > query(Args &&... args) const
Create a query.
flecs::entity entity(Args &&... args) const
Create an entity.
flecs::string_view name() const
Return the entity name.
void each(Func &&func) const
Each iterator.