I have been working in cocos2d for a few years now. After making the switch to v3 I really miss being able to override the cleanup
function. In my sprites I would typically perform all my cleaning up in a way similar to this:
-(void)cleanup {
// Do other cleanup that is not covered by super.
// Call super cleanup.
[super cleanup];
}
With v3 it appears that the cleanup
function is private to CCNode
and cannot be overridden. The main reason for using this approach was that the function would be called automatically with a simple removeFromParent
call.
Does anyone have a suggestion how to go about doing something like that in v3 other than writing my destroy
function and calling it manually?
Depends on the use case.
Normally I just call [node removeFromParentAndCleanup:YES]
, which is enough for my needs.
If you want direct access to the private cleanup
method in a subclass of CCNode
you should just import CCNode_Private.h
in you header file instead of CCNode.h
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.