Game Development Reference
In-Depth Information
Listing 13-5 . Conditional code compilation based on target platform
#if __CC_PLATFORM_IOS
// iOS specific code here
#elif __CC_PLATFORM_ANDROID
// Android specific code here
#endif
Try to build again. You'll get a nondescript error:
GameMenuLayer.m:49:38: Expected a type
The problematic line in GameMenuLayer.m is the method signature of the method in List-
ing 13-6 .
Listing 13-6 . What unexpected type?
-(void) applicationWillResignActive:(UIApplication
*)application
{
[self shouldPauseGame];
}
If you look closely, you'll notice that Xcode underlined in red the beginning of the
UIApplication keyword. That's where the error is. So apparently UIApplication
is also not available on Android. This makes sense because Android uses a different
launch mechanism. Since this method isn't crucial (it pauses the game when the app
enters background), just exclude the entire method from Android builds for now by
adding the highlighted lines in Listing 13-7 .
Listing 13-7 . Just ignore this on Android
#if __CC_PLATFORM_IOS
-(void) applicationWillResignActive:(UIApplication
*)application
{
[self shouldPauseGame];
}
#endif
Search WWH ::




Custom Search