Skip to content

Component

Alan Jefferson edited this page Oct 13, 2019 · 1 revision

Components represent the data in your application.


Tags

A tag is an empty component. You can use it as a boolean for an entity or series of components.

// Given a number of entities..
std::vector<entt::entity> vec(10);
registry.create<Position>(vec.begin(), vec.end());

// ..tag the first entity..
registry.assign<entt::tag<"first"_hs>>(vec[0]);

// ..and then loop over all entites with a given tag
registry.view<Position, entt::tag<"first"_hs>>().each([]() {
   printf("I'll only iterate on positions that have a 'first' tag\n");
});