cocos2dx -- CREATE_FUNC
创建对象,然后自动释放内存,可以不用管理内存!
/** * define a create function for a specific type, such as CCLayer * @__TYPE__ class type to add create(), such as CCLayer */ #define CREATE_FUNC(__TYPE__) \ static __TYPE__* create() \ { \ __TYPE__ *pRet = new __TYPE__(); \ if (pRet && pRet->init()) \ { \ pRet->autorelease(); \ return pRet; \ } \ else \ { \ delete pRet; \ pRet = NULL; \ return NULL; \ } \ }
Code change the world
posted on 2015-04-07 19:42 MonotoneLight 阅读(119) 评论(0) 收藏 举报
浙公网安备 33010602011771号