问题
There's a method called didLoadFromCCB
that you can implement for any class that has been created in SpriteBuilder. This method is called when Cocos2d loads the class from a CCB file.
What I want to know is: where does this method come from?
Xcode doesn't seem to know it exists, as it doesn't autocomplete.
I'm not having any problems with the method, it's getting called and everything is working perfectly, I'd just like to know where it comes from.
Also, I'd like to know if there is any documentation that lists methods like this that can be called on classes loaded from CCB files. I've had a look around www.spritebuilder.com, but there doesn't seem to be anything of that nature.
回答1:
CCBReader sends this message. You can search the project in xcode if you need to find its exact origin.
The mistake is that this method wasn't declared in any of the CCBReader headers and isn't in a protocol either, therefore Xcode won't autocomplete it because it's considered a private method. This will be fixed eventually.
There is currently no CCNReader documentation besides the code itself. But didLoadFromCCB is the only method CCBReader will send to nodes.
EDIT: I opened an issue regarding autocomplete of didLoadFromCCB, it's been bothering me too.
来源:https://stackoverflow.com/questions/24153721/where-does-the-method-didloadfromccb-come-from-in-cocos2d-v3