On Sat, Sep 25, 2010 at 10:06 PM, Mike Wyatt <[email protected]>wrote:
> In my cocos2d project, I'm using an MVC structure similar to the > tetrico demo. > > *** The setup *** > The Model manages all entities in the game (ships, cannon balls, > etc.). An entity represents an object in the world with associated > physics, pathfinding logic, event-handling, etc. > > The Controller handles pyglet events and passes events to the model > and entities. It is aware of the view, for example calculating which > tile on the map the user clicked on. > > The View contains a sprite for each entity and is only responsible for > drawing a representation of the model to the screen. > > *** The problem *** > I want to use the cocos action framework for model entities. In most > examples, a sprite *is* the entity, and there is no separation of > events, physics, user input, or rendering. Is there a good reason for > this, or is it just to keep the demos simple? Examples in the test directory are meant to show how different CocosNodes (view elements) behave, with code as simple as possible, so they not use any MVC. But the current cocos don't have any special support for MVC, except for publish - subscribe by way of events subsystem. Would it be better for > me to port over the "do" method from the CocosNode to my Entity base > class, or is there a simpler way? > > If you you want to use the 'action' concept in your model AND want to use something that still can be called MVC , yes, in general you will need to implement in your model entities the methods needed by action operation (the 'action execute interface' if you want, that comprises 'do', '_step', 'pause', 'resume', 'remove_action'). In retrospect, that interface could have been defined as a subclass, to be inherited by CocosNode and, should the developer wanted, the model objects. -- claudio -- You received this message because you are subscribed to the Google Groups "cocos2d discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/cocos-discuss?hl=en.
