From 13c786cbeceb7d0d385a30326e34caaec7b84a17 Mon Sep 17 00:00:00 2001 From: Alec Thomas <alec@swapoff.org> Date: Sun, 8 Jun 2014 02:58:04 +1000 Subject: Add convenience `Component<T>::Handle` typedef. --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 9f8ee62..e6cc70c 100644 --- a/README.md +++ b/README.md @@ -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)) { -- cgit v1.2.3