Currently I am using builder-pattern to create my Entities

PooledEngine engine = new PooledEngine();


CharacterComponent character = engine.createComponent(CharacterComponent.class);
TextureComponent texture = engine.createComponent(TextureComponent.class);
SizeComponent size = engine.createComponent(SizeComponent.class);
TransformComponent transform = engine.createComponent(TransformComponent.class);
PhysicsComponent physics = engine.createComponent(PhysicsComponent.class);

Entity entity = engine.createEntity();
entity.flag = Constants.CHARACTER;



Because PooledEngine class didnt support the creation of casting an Entity to another class that extends Entity. Example engine.createEntity(Character.class);, I am having hard thinking how do I wrap these components into single class.


class interface ICharacter {
    void attack();

class interface IMoveable {
    void move();

class Character extends Entity implements ICharacter, IMoveable {

    private Body body;
    private Vector2 position;

    public Character() {
        PhysicsComponent physics = Mappers.physics.get(this);
        TransformComponent transform = Mappers.transform.get(this);

        body = physics.body;
        position = transform.position;

    public void attack() {


    public void move() {
        position.add(x, y);


You are totally defeating the purpose of using an Entity-Component-System by creating that Character class. The whole drive behind ECS architecture is the decoupling/separation of data(Components) and logic(Systems). What you need to do is create separate Systems to handle attack and movement logic.

Read these two articles, they'll help you get a better understanding of ECS architecture and how to use it:

What is an entity system framework for game development?

Why use an entity system framework for game development?


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .