-
Notifications
You must be signed in to change notification settings - Fork 74
Visuals as components #286
Comments
You can make a component which has I'm not an expert in Luxe philosophy but that's how I would go about solving this problem. |
Well, it's a workaround but is counterintuitive that's why I'm suggesting it. |
iirc I read in the luxe docs that using an inheritance based programming approach or a component based one should be both valid options. Making sprite a component would make the first approach more difficult. |
Can't see how this will make it more difficult. |
hey, Let's tackle this one bit a time,
But all that is tertiary, the real logic behind all this follows. To word this plainly, Sprite is an entity-quad-geometry-with-sprite-powers. This is the most important point - When looking at it, we don't want to be conflating "entity with geometry" to "is a sprite" - that is not the case here, and won't be (that's a better specialization to be had on it's own). To be even more precise: For your point about SpriteAnimation being a component, that was where it landed right now - it is a It is not a generic entity (that would be Entity) *(and visual has some work to go as its currently harbouring old quad identity). So stepping back where does that leave us? It means that Rendering-as-a-component is not the real concern here for me, it's the inverse, using a specialization in another paradigm. If you want to render stuff you create a geometry or use the onrender hooks that are there already (including their associated costs - I'd use geometry because it's more efficient that way).
Specialize a component - specifically to what you want it to be. Make a Along the way, Short term, the simpler imperative approach is preferred, because it doesn't require an existing set of knowledge to get something on the screen ("what is a component?") - it's just a class instance. Hope that clarifies things a bit for everyone :) minor notes:
|
Hi, thanks for the explanation. Transformation data like rotation_z is more of a entity property rather than a sprite property to me. Also because I was used to think of entity as generic objects and the components are the ones to make features. |
The way I understand it, you would like to use multiple visual elements to display one single If it happens to be the case, For example:
This component will draw a red triangle with a radius of 32 pixels using However, as of this moment, A very detailed example using |
@JunoNgx Not really. I don't have problems at all coding a custom component. It's just a suggestion of a design decision to be explored by the engine. Btw, I think you are creating a ngon each frame instead of batch it. |
Instead of class Sprite extends Visual (extends Entity)
{
// lots of sprite specific codes....
} could it become class Sprite extends Entity
{
var visual:VisualComponent; // all the sprite specific codes moved into the component
public var rotation_z(get, set); // forward the properties to the component
} So at the end, new users can get things to display on screen with the same minimal effort as now. But that would also enable advanced users to compose their own class with the visual/sprite component? |
You're not unable to compose your own, as it is. |
I am just trying to give some suggestions that makes Luxe easy to use for both new users and advanced users. |
Sprite being an entity is limiting.
I can't attach or detach the behavior of a sprite to existing entity or extend its functionality to a custom component.
The some goes for all visual classes.
We can't freely use more than one visual feature to the same entity, loop through its components to fetch them or create a new visual taking advantage of the system.
A base VisualComponent class with an "onDraw" method to be overridden would make the render system easier to customize and extend.
The text was updated successfully, but these errors were encountered: