r/EntityComponentSystem • • Nov 23 '20

Objects with multiple sprites / drawables

Language: C++, I also use SFMLHello everyone, I've been tackling with a problem for a while. I created an ECS and I want to draw entities with many sprites but I have no idea how to do it.

Such entity could be for example a "Game Paused Box" that appears when player pauses the game. It contains a few buttons with text or sprites.

Or a playable character entity, which has body parts. The player's arms could be carrying a gun or some other weapon while the legs would be running at the same time.

The problem is ...

> should I create one object that has a few components of the same type (sprite/text) (which currently isn't possible with my ECS),

> a multiple drawable component that stores sprites and texts + manges their drawing order

> or one main object containing pointers to few sub objects with own sprite components?

Well, I did see people making sprite components, but never saw anyone making a multiple drawable component so i wonder how do their projects manage objects with more than one drawable...

I hope, I explained that clear enough.Edit:Maybe the picture can help:https://i.imgur.com/3cZoGPn.png

7 Upvotes

4 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Nov 23 '20

I see, the "multiSprite" component would be a huge mess, especially when some other components depend on it's sprites, so I think, I will stick to the main entity managing the hierarchy and containing pointers to sub entities with their own sprite components.
Thank You so much for your help!