I’m porting a book I wrote using cocos2d-iphone to cocos2dx. (can i use the same code obj-c inside c++?)
It’s possible to access photo library and choose a photo on both iOS and Android devices using cocos2dx?
- Of course you can use obj-c code mixed with c++ on iOS platform.
- cocos2d-x haven’t wrapped this interface. You had to implement it on iOS and Android, invoking system APIs.
My code has the classes:
MediaUtil.h + MediaUtil.mm (Obj-C*+ code to call the Obj-C code)
MediaUtil_objc.h + MediaUtil_objc.m
From C*+ i’m calling:
CCMenuItemImage photoSelect = CCMenuItemImage::itemFromNormalImage);
CCMenuphotoMenu = CCMenu::menuWithItem( photoSelect );
photoMenu~~>setPosition );
this~~>addChild( photoMenu );
The implementation of imagepicker it’s something like that (this method is called in OBJ-C++ code):
~~choosePhoto
{
if {
;
;
}
if ;
imagePicker = init] retain];
//imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.wantsFullScreenLayout = YES;
imagePicker.delegate = self;
pop = initWithContentViewController: imagePicker] retain];
;
UIViewController *viewController = init];
_bookViewController = viewController;
//adiciona a view que sera apresentada a selecao de foto
addSubview:viewController.view];
;
}
And the delegate method to handle selected photo never gets called:
~~(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSLog(@“Call me please!”);
}
Any ideas?
It’s possible to access the photo album folders via C++ and show images in Sprites?