How to send an email with cocos2d

We will use MFMailComposeViewController, and we want to send a email with preformated subject and body, and an image as attachment: First, add the MFMailComposeViewControllerDelegate to your .h, this delegate method will be called when you have finish using the controller (after cancelling or sending the email): -(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error Here is the code, basically we pause the cocos2d animation, prepare the controller with the subject/body and a screenshot file which is...

read more

cocos2d – take a screenshot

How to make a screenshot with cocos2d 2.0 and CCRenderTexture: -(UIImage*) takeScreenShot { [CCDirector sharedDirector].nextDeltaTimeZero = YES; CGSize winSize = [CCDirector sharedDirector].winSize; CCLayerColor* blankLayer = [CCLayerColor layerWithColor:ccc4(255, 255, 255, 0) width:winSize.width height:winSize.height]; blankLayer.position = ccp(winSize.width/2, winSize.height/2); CCRenderTexture* rtx = [CCRenderTexture renderTextureWithWidth:winSize.width height:winSize.height]; [rtx begin]; [blankLayer visit]; [[[CCDirector sharedDirector] runningScene] visit]; [rtx end]; return [rtx...

read more

Localize your game with bitmap fonts and cocos2d

It’s my first tutorial ! I will explain here how to localize your game, using bitmap fonts and cocos2d, with creating a menu with buttons and text in it. During this tutorial we will also see how to make the HD and SD version, so it will work for the retina display too. Let’s prepare our ressources: 1. The buttons Take your button, in HD version: button-hd.png and also the SD version of it. To quickly convert my HD files, i’m using HD2x: drop button-hd.png in HD2x and click ‘HD2x’, you will have your button.png   I’m also creating a selected version...

read more