您好我正在尝试使用cocos2d相机。它有时会发生,有时会完美地运作。这是我的代码和错误:
-(void)playAction{
CCLOG(@"Take Picture");
UIImagePickerController *photoPicker = [[UIImagePickerController alloc] init];
photoPicker.delegate = self;
photoPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
//[self presentViewController:photoPicker animated:YES completion:NULL];
[[CCDirector sharedDirector] presentModalViewController:photoPicker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)photoPicker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImageView *imageView = [[UIImageView alloc] initWithImage:[info valueForKey:UIImagePickerControllerOriginalImage]];
//ConfigureCharacterLayer *asd = [[[ConfigureCharacterLayer alloc]init] autorelease];
[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:[ConfigureCharacterLayer scene:imageView.image]]];
[imageView release];
[photoPicker dismissViewControllerAnimated:YES completion:nil];
}
创建图片并按下Apple提供的“使用图像”按钮时会发生此错误。
OpenGL error 0x0506 in -[CCSprite draw] 530
OpenGL error 0x0506 in -[CCSprite draw] 530
OpenGL error 0x0506 in -[CCSprite draw] 530
OpenGL error 0x0506 in -[CCTextureAtlas drawNumberOfQuads:fromIndex:] 573
OpenGL error 0x0506 in -[CCTextureAtlas drawNumberOfQuads:fromIndex:] 573
OpenGL error 0x0506 in -[CCTextureAtlas drawNumberOfQuads:fromIndex:] 573
OpenGL error 0x0502 in -[CCGLView swapBuffers] 283
这是我加载图片的地方:
image3 = [[UIImageView alloc]initWithFrame:CGRectMake(50, 50, 250, 250)];
image3.layer.zPosition = 200;
CCLOG(@"Image: %@",capturedImage);
[image3 setImage:capturedImage];
[[[CCDirector sharedDirector] view] addSubview:image3];