We have a CREATE_FUNC
macro, which allows us to call the create()
function of a class without implementing this function - as long as we add CREATE_FUNC( myclass ) to the header file.
It seems like a good idea to also have a SCENE_FUNC
macro, since this would spare us from having to put a scene()
function into every CCLayer
derived class that we are writing.
Example (based on CREATE_FUNC
):
/**
* define a scene function for a specific type, such as CCLayer
* @__TYPE__ class type to add scene(), such as CCLayer
*/
#define SCENE_FUNC(__TYPE__) \
static CCScene* scene( void ) \
{ \
CCScene* pScene = CCScene::create(); \
__TYPE__ *pRet = new __TYPE__(); \
if( pRet && pRet->init() ) \
{ \
pRet->autorelease(); \
pScene->addChild( pRet ); \
return pScene; \
} \
else \
{ \
delete pRet; \
pRet = NULL; \
return NULL; \
} \
}
What do you think about this idea?