I'm just curious, semantically correct, to use traits to create game objects. On the one hand, I see this as a relation (the object has components), but on the other hand, I consider the components as constituting the object.
For instance. You have a GameObject. GameObject does almost nothing on its own, but the things you mix with it give it additional properties. Components can be HealthComponent (has health), PhysicsComponent (simulates physics), ClickableComponent (can be clicked).
I like the idea of ββusing tags because all properties and methods are added to the source object, and I can do player.getHP instead of player.getHealthComponent.getHP . On the other hand, I find that the naming and semantics of using traits are strange. trait HealthComponent extends GameObject - this makes no sense. A HealthComponent owned by GameObject, it does not fulfill the relationships that extend means. Am I right in thinking that traits are usually treated as specialized versions of their parent class? If so, what would I call something like the above object?
source share