librelist archives

« back to archive

Issue with EntityManager

Issue with EntityManager

From:
Date:
2013-10-01 @ 22:58
I'm using the example provided on your main part, but get an error in the 
CollisionSystem about the es declared in its parameters.  It looks like:
class CollisionSystem : public entityx::System<CollisionSystem>
    {
        public:
            void update(entityx::ptr<entityx::EntityManager> es, 
entityx::ptr<entityx::EventManager> events, double dt) override
            {
                entityx::ptr<Position> left_position, right_position;
                for (auto left_entity : 
es.entities_with_components<Position>(left_position))
                {
                    for (auto right_entity : 
es.entities_with_components<Position>(right_position))
                    {
                        if (collide(left_position, right_position))
                        {
                            events.emit<Collision>(left_entity, right_entity);
                        }
                    }
                }
            }
    };

and gives me the error: "error: 'entityx::ptr<entityx::EntityManager>' has
no member named 'entities_with_components'"

Re: [entityx] Issue with EntityManager

From:
Alec Thomas
Date:
2013-10-01 @ 23:00
Ah, apologies, it looks like I failed to update that documentation.

You'll need to use es->entities_with_components<Position>(left_position)

Note the -> rather than .

Same with events->emit<Collision>(left_entity, right_entity)


On Tue, Oct 1, 2013 at 6:58 PM, <wolfdan@cox.net> wrote:

> I'm using the example provided on your main part, but get an error in the
> CollisionSystem about the es declared in its parameters.  It looks like:
> class CollisionSystem : public entityx::System<CollisionSystem>
>     {
>         public:
>             void update(entityx::ptr<entityx::EntityManager> es,
> entityx::ptr<entityx::EventManager> events, double dt) override
>             {
>                 entityx::ptr<Position> left_position, right_position;
>                 for (auto left_entity :
> es.entities_with_components<Position>(left_position))
>                 {
>                     for (auto right_entity :
> es.entities_with_components<Position>(right_position))
>                     {
>                         if (collide(left_position, right_position))
>                         {
>                             events.emit<Collision>(left_entity,
> right_entity);
>                         }
>                     }
>                 }
>             }
>     };
>
> and gives me the error: "error: 'entityx::ptr<entityx::EntityManager>' has
> no member named 'entities_with_components'"
>

Re: [entityx] Issue with EntityManager

From:
Date:
2013-10-01 @ 23:09
I kinda figured that out since I figured it was a smart pointer form the 
::ptr part. Now in the manager part, I'm getting an error that I can't 
allocate an object of abstract type 'DebugSystem' when I try to add<> it. 
Are there any methods besides configure and receive that it needs?