Our first app with cocos2dx Jack-i-Lantern

Our first app with cocos2dx Jack-i-Lantern
0.0 0


Hi all.

This post is just to show all of you our first app done using this awesome framework.

We are an startup from Spain www.pulsarconcept.com and our app is about making pumpkins for halloween and share them :slight_smile:

First of all I want to thank Minggo Zhang and Walzer Wang, and all the people involved in the development of cocos2dx for the effort of making this framework possible.

Our app is free and it has been developed for iOS and Android devices, it works in most of the devices due to the scalable graphics.

iOS: http://itunes.apple.com/us/app/jack-i-lantern/id473052245?mt=8

Android : https://market.android.com/details?id=org.pulsarconcept.jackLantern&feature=search_result

It’s a simple app to use, but it has been a bit complicate due to the camera functions and the opengl screenshots etc. Thats why I also want to thank everyone in this forum who has helped us when we had some kind of doubts or answers.

So thank you everyone and if you have any question about the development of the app, I will be here to answer them :slight_smile:


Haha! So funny! I love this app :slight_smile:
This is my pumpkin made by jack-i-lantern

Anyone who can share a cooler one?


awesome! i just made a pumpkin and upload it to sinaweibo.
it’s so surprising that u combines cocos2dx with UIKit perfectly.
could u give me some tips about how u did this?(e.g. the photopicker)


Thank you very much both of you :).

Of course, we use a proxy in c++ which calls an objective-c class and after calling the photo picker, we set an app controller instance in the photoPicker.
Then just add the picker to the main window [[appControllerInstance getWindow] addSubview:cameraPicker]; and voila :slight_smile:


great!i ’ll try it.maybe u can make a tutorial about this. i think it has great potential.
cocos2dx will not only make games but apps in the future.
let’s keep in touch.


Oh, i have some experience of using the alertView and meet some problems.
when i mix alertView, the simplest object of UIKit, in my cocos2dx project, the program often breaks in the main.m.
i have no idea about this, have u ever encounterd this?


If I can get some time I will try to make a tutorial about this :).
On your second question, if you can tell me what is the error you are getting I can help you. I don’t remember having any trouble with main.m


thanks Jon
all my UIViews such as facebook connecting view when added chiledviews are using the code below
UIWindow* window = [UIApplication sharedApplication].keyWindow;
window = [[UIApplication sharedApplication].windows objectAtIndex:0];
[window addSubview:self];
instead of the way you said before.
is there a difference?i’ll try your method later.


Oh, i ’m sorry i forgot to change my id, the previous is my new account cause i want to change a head icon
i have another question, how do u convert a UIImage to a CCSprite?
the only way i known is to save the UIImage to document and make a new ccsprite from the file.that’s a little cumbersome.


About your first question, I’m getting the window where the appController is added, but i guess that should be the same that the key window, not really sure.
And about your second question, I haven’t found anyway to convert an UIIMage to a ccsprite, in iOS I’m making an UIImage from an screenshot from the opengl view, and then I’m mixing it with the uiimage that i get from the camera.


u use the filepath from the photopicker and make the ccsprite directly?


I’m doing that for android, but for iOS i make an screenshot of the openglView using this code:

UIImage * CameraProxyIOS::glToUIImage() { int width = [[UIScreen mainScreen] bounds].size.width * [UIScreen mainScreen].scale; int height = [[UIScreen mainScreen] bounds].size.height * [UIScreen mainScreen].scale; NSInteger myDataLength = width * height * 4; // allocate array and read pixels into it. GLubyte * buffer = (GLubyte *) malloc(myDataLength); glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); // gl renders "upside down" so swap top to bottom into new array. // there's gotta be a better way, but this works. buffer2 = (GLubyte *) malloc(myDataLength); for(int y = 0; y <height; y++) { for(int x = 0; x <width * 4; x++) { buffer2[(height-1 - y) * width * 4 + x] = buffer[y * 4 * width + x]; } } // make data provider with data. CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, buffer2, myDataLength, NULL); // prep the ingredients int bitsPerComponent = 8; int bitsPerPixel = 32; int bytesPerRow = 4 * width; CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedLast; CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault; // make the cgimage CGImageRef imageRef = CGImageCreate(width, height, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent); // then make the uiimage from that UIImage *myImage = [UIImage imageWithCGImage:imageRef]; CGDataProviderRelease(provider); CGImageRelease(imageRef); free(buffer); return myImage; }


thanks, u are so warm-hearted.
i don’t know exactly what your code does .i mean when i respond to the delegate method below. how do i use of the UIImage as a background?

 - (void)imagePickerController: (UIImagePickerController *)picker   
 didFinishPickingMediaWithInfo: (NSDictionary *)info  
     if (picker == picker_camera_)   
            UIImage* original_image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];  
            UIImageWriteToSavedPhotosAlbum(original_image, self,   

     UIImage* image = [info objectForKey: @"UIImagePickerControllerEditedImage"];  

     [self dismissModalViewControllerAnimated:YES];  
     [picker release];  


My code just take an screenshot of the whole opengl view, so every sprite, button etc that you have added to your scene will appear in this uiimage. what you want to do is add an uiimage view to the screen while you still have the cocos2dx graphics don’t you? you can just make an UIImageView, and add it over the openglView, as I told you before

[[appControllerInstance getWindow] addSubview:YurUIImageView];
[[appControllerInstance getWindow] bringSubviewToFront: YurUIImageView];

this should make the trick