I am trying to find out frameworks for objective-c that supports entity-component pattern. I looked about Cocos2d, Kobold2d, KoboldTouch.. but none of them seems related to that. Can anyone please guide me if there is any available framework for objective-c ?
I am trying to find out frameworks for objective-c that supports entity-component pattern. I
Share
You can manually add the entity-component pattern to cocos2d/etc, though it’s not directly built into the API.
-addChild:(et al) in the Entity to add Components.-parentin a Component to access its Entity.-update:in a Component to update its Entity.SomeCCNodeEntity.m
MoveComponent.m
The above code moves the Entity whenever the Component’s -update: method is called. This is covered a bit on Learn-Cocos2d: Prefer Composition over Inheritance
As for a messaging system between different Entities, you’d also have to roll your own. Apple’s API’s have used the idea of delegates, notifications, and observers to tell other objects stuff. Only one object can be a delegate, to perform an optional or required task for another. Multiple objects can register for notifications, or become observers.
This can get complex quick, especially if, say, you have 10 objects registered as observers, and the order which they receive observation messages is important. Should they get messages based on order they registered in, like FIFO or LIFO? Something more complex? Etc…