Hi,
I am relatively new to the cocos2d environment and am encountering the following issue:
- If I launch an application while listening to a song via my iPod, the music does not stop/pause. The music continues to play in the background.
Desired effect:
- To stop/pause music when my application launches
I have searched through this forum & other cocos2d resources to see what the issue is, but have been unsuccessful. In examining other applications that contain the desired behavior (mentioned above), I have narrowed the issue down to the Director. While other applications uses the viewController to force this behavior, I have not figured out how to remedy this in the Director.
Here's a cut-out of my applicationDidFinishLaunching call:
- (void) applicationDidFinishLaunching:(UIApplication*)application
{
// Init the window
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// cocos2d will inherit these values
[window setUserInteractionEnabled:YES];
[window setMultipleTouchEnabled:NO];
// Try to use CADisplayLink director
// if it fails (SDK < 3.1) use Threaded director
if( ! [Director setDirectorType:CCDirectorTypeDisplayLink] )
[Director setDirectorType:CCDirectorTypeDefault];
// Use RGBA_8888 buffers
// Default is: RGB_565 buffers
[[Director sharedDirector] setPixelFormat:kPixelFormatRGBA8888];
// Default texture format for PNG/BMP/TIFF/JPEG/GIF images
// It can be RGBA8888, RGBA4444, RGB5_A1, RGB565
// You can change anytime.
[Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA8888];
// before creating any layer, set the landscape mode
[[Director sharedDirector] setDeviceOrientation:CCDeviceOrientationLandscapeLeft];
[[Director sharedDirector] setAnimationInterval:1.0/60];
[[Director sharedDirector] setDisplayFPS:NO];
// create an openGL view inside a window
[[Director sharedDirector] attachInView:window];
[window makeKeyAndVisible];
MenuScene *ms = [MenuScene node];
[[Director sharedDirector] runWithScene:ms];
}
Am I doing something wrong?