diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -118,8 +118,8 @@ entity.assign<Position>(1.0f, 2.0f); To query all entities with a set of components assigned, use ``entityx::EntityManager::entities_with_components()``. This method will return only those entities that have *all* of the specified components associated with them, assigning each component pointer to the corresponding component instance: ```c++ -ComponentHandle<Position> position; -ComponentHandle<Direction> direction; +Position::Handle position; +Direction::Handle direction; for (Entity entity : entities.entities_with_components(position, direction)) { // Do things with entity, position and direction. } @@ -128,7 +128,7 @@ for (Entity entity : entities.entities_with_components(position, direction)) { To retrieve a component associated with an entity use ``entityx::Entity::component<C>()``: ```c++ -ComponentHandle<Position> position = entity.component<Position>(); +Position::Handle position = entity.component<Position>(); if (position) { // Do stuff with position } @@ -161,8 +161,8 @@ A basic movement system might be implemented with something like the following: ```c++ struct MovementSystem : public System<MovementSystem> { void update(entityx::EntityManager &es, entityx::EventManager &events, double dt) override { - ComponentHandle<Position> position; - ComponentHandle<Direction> direction; + Position::Handle position; + Direction::Handle direction; for (Entity entity : es.entities_with_components(position, direction)) { position->x += direction->x * dt; position->y += direction->y * dt; @@ -198,7 +198,7 @@ Next we implement our collision system, which emits ``Collision`` objects via an class CollisionSystem : public System<CollisionSystem> { public: void update(entityx::EntityManager &es, entityx::EventManager &events, double dt) override { - ComponentHandle<Position> left_position, right_position; + Position::Handle left_position, right_position; for (Entity left_entity : es.entities_with_components(left_position)) { for (Entity right_entity : es.entities_with_components(right_position)) { if (collide(left_position, right_position)) { |