Hi folks,
I was implementing a little game and found some bugs on cocos code.
The first one is on the override remove method from BatchableNode. The
method right now is as follows:
def remove(self, child):
child.set_batch( None, None )
super(BatchableNode, self).remove(child)
This is okay until I try to remove a node by name. An exception is
raised because a str object obviously doesn't have a set_batch method.
As removing by name is supported on the cocosnode version of the
method it should be here too, I think. I made a very quick fix like
this:
def remove(self, child):
if isinstance(child, str):
child = self.get(child)
child.set_batch( None, None )
super(BatchableNode, self).remove(child)
And it seems to work. The only thing, though, is that it could be a
bit annoying for all subclasses wishing to override remove doing this
type of thing. Anyway, I can't think of a better way right now. Maybe
there is some nice design pattern that could be used here?
The other issue I've observed is that when one adds a named child to a
node and then remove it by reference, the name doesn't get removed.
This way, when I try to add another children with the same name I get
a "Name already exists". From my point of view, as names are unique,
when an named instance is removed by reference, the associated name
should be removed as well.
--
Kao Cardoso Félix
Página pessoal: http://www.inf.ufrgs.br/~kcfelix
Blog: http://kaofelix.blogspot.com
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---