I have this basic component class that looks like this
class Component {
constructor() {
this.manager = null;
}
behavior(){
//some behavior
}
}
I want an instance of GameObject to dynamically inherit that behavior by doing something like
var myGameObject = new GameObject();
myGameObject.attach(myComponent);
so that I can easily do
myGameObject.behavior();
Is this possible through ES6? if not what other alternatives do I have?
I did found a way to do this, but not sure if this is just bad practice