1#include <each_w_iter_callback.h>
2#include <iostream>
3
4
5
6
7
8
9struct Position {
10 double x, y;
11};
12
13struct Velocity {
14 double x, y;
15};
16
17int main(int, char *[]) {
19
20
22 ecs.
query<Position,
const Velocity>();
23
24
26 .set<Position>({10, 20})
27 .set<Velocity>({1, 2});
28
30 .set<Position>({10, 20})
31 .set<Velocity>({3, 4});
32
33
35 .set<Position>({10, 20});
36
37
38 q.
each([](
flecs::iter& it,
size_t row, Position& p,
const Velocity& v) {
40 p.x += v.x;
41 p.y += v.y;
42 std::cout << e.
name() <<
": {" << p.x <<
", " << p.y <<
"}\n";
43 });
44
45
46
47
48}
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.
Class for iterating over query results.
flecs::entity entity(size_t row) const
Obtain a mutable handle to the entity being iterated over.
void each(Func &&func) const
Each iterator.