在Cocos2dx有条简单的预处理语句,用于代码中如何就不同平台执行相应的代码
void CppSprite::myInit(){ #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) //ios UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"森" message:@"C++与Oc互调" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil]; [alert autorelease]; [alert show]; #else //adroid #endif };