aduros / flambe

Rapidly cook up games for HTML5, Flash, Android, and iOS.
https://github.com/aduros/flambe/wiki
MIT License
745 stars 118 forks source link

@:componentBase to extended components #349

Closed markknol closed 8 years ago

markknol commented 9 years ago

Hi Bruno, How are you doing?

I have an idea / suggestion for a situation I'm dealing with. I have a base Gun component with basic shoot functionality and some classes that extend this class. It's nice because in code I can do owner.get(Gun).shoot(direction).

There can never be two guns in one component and that is good; I don't want to change that. But I want to give the player another gun (a specialize second one). This is also a class that extends Gun. What I want is a feature to be able to don't grab it owner.get(Gun), only using owner.get(SpecialGun). I tried to add @:componentBase to the SpecialGun, but that doesn't work. It would be neat to have such metadata tag to make a component its own base. I know it's a bit against the composition design pattern rules but in some cases you extend stuff to have basic functionality but you don't want to share it the same base (and be able to add this SpecialGun component without removing another Gun).

Can you help how to make this happen? I think it should be done somewhere in the ComponentBuilder, but I don't know how.

aduros commented 9 years ago

Hmm, if I understand correctly, would adding @:componentBase to Gun work?

markknol commented 9 years ago

No, that would make all guns its own base (also it doesnt seem to work too?). I only want one of them as own componentBase.

markknol commented 8 years ago

I misunderstood how @:componentBase worked. This issue can be closed.