Haxeflixel use case; ECS?



  • I tried (twice) making an entity-component system with HaxeFlixel; it always seems like I'm fighting the architecture -- FlxObject, FlxSprite, etc. just have loads of properties (position, velocity, image, etc.) and are "supposed" to be used as the building-blocks of monolithic classes?

    I don't know if I'm getting it. Can someone provide a non-trivial (like non-demo) version of a game that shows how HaxeFlixel is supposed to be used, and/or architected?



  • I once made something with HaxeFlixel and Edge, which is a ECS engine: PongECS. In this, every entity has a FlxSprite as a component and newly added components. But it ended up a mess anyway.

    I came up with this idea of a ECS engine built on HaxeFlixel, which means HF would run as an underlying system for rendering, updating and other processes.
    Inside the engine, Entities would be mapped to a FlxSprite or FlxObject of their own. When a component data was changed, the new data would be copied to the FlxSprite mapped to its Entity.
    For example, we have an Entity with a Position component which stores 2 values x and y, if any of them is set to a new value, the position of the FlxSprite is also changed. Same thing for othe concepts.
    All of this happens under the hood so the users virtually don't know of the HaxeFlixel API at all but indirectly through the API of this ECS engine.


Log in to reply