(1) I agree that this is an interface change. (2) Most objects use the object's id for the hash so one could assume most subclasses would allow use as a dictionary key. (3) It might get slow if you had thousands of nodes, but I suppose that's unlikely.
I however think it is useful for a CocosNode to know its own name (1). I'll try to think of an example situation. -Winston On Apr 10, 2011, at 2:40 PM, Claudio Canepa wrote: > > >> Comment #2 on issue 74 by [email protected]: add with name, remove with >> reference, add gain with name >> failsttp://code.google.com/p/los-cocos/issues/detail?id=74 >> >> I'd also like to see this change so that adding by name and then removing by >> object works. I can submit a patch with tests if you will allow it. One >> could solve it by >> (1) adding a 'name' field to a cocos_node, > first look: easy and should do the work > > second look: what if user changes the name ? -> 'name' should be a > property, either Read Only or with a setter that adjust the name -> > obj dictionary > > third look: it is an interface change, and could broke user code using > the attribute 'name' in their code > >> (2) adding a dictionary of {node : object} > a dict of cocosnode instance: name ? > > An instance of CocosNode base class can be used as a dictionary key, > but, is that true for any subclass ? > >> (3) search through children_names to find the name and object. I can do it >> any way you prefer. > while slower, I don't see any side effect or hidden requirements > added. > > I personally prefer the third one. > > Anyone (developers or users) have another take on the issue ? > > -- > 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. > -- 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.
