Skip to content

Support children class in view #6

@buckle2000

Description

@buckle2000

If I have a interface represent the graphics of an entity.

interface RenderComponent {
    function getDrawable():IBitmapDrawable;
}

and this implement:

class SpriteRenderComponent implements RenderComponent
{   
    public var target:Sprite;

    public function new() {
        target = new Sprite();
    }

    public function getDrawable():IBitmapDrawable {
        return target;
    }
}

and I create a view:

var v:View = new View([RenderComponent],null,context);

add an entity:

var e:Entity = context.entities.create();
e.set(new SpriteRenderComponent ());

But I can't get the SpriteRenderComponent using context.entities.
Also, this doesn't work either:

var e:Entity = context.entities.create();
e.set(cast (a,RenderComponent));

I found that it is related to some methods in ComponentManager.hx.

Anyway, am I supposed to do this, does it volatile the concept of ECS?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions