Creating a Cocos2D-x Project in the Marmalade SDK

Some time ago, RIM, together with Marmalade, held an action in which I also managed to get a Blackberry Playbook tablet. Under the terms of the promotion, within six months from the date of registration, it is necessary to develop and upload a game made using the Marmlade SDK to the Blackberry App World. After studying a certain amount of material about this SDK on the network, I came across records that it was possible to use Cocos2D-x, which would probably reduce my development time (although I have no experience with either Marmalade or Cocos2D-x). Next, I downloaded the latest Cocos2D-x release and did not find any signs of interaction with the Marmalade SDK in it.

As it turned out, before the Cocos2D-x port branch on Marmalade was led by Francis Styckand in earlier versions there were examples of creating a Marmalade project, but he came across some difficulties and the porting work slowed down. Then the guys from Marmalade got down to work and at the moment on the Cocos2D-x github their pull request hangs , which should be included in the next release. Nevertheless, a working version of Cocos2D-x with Marmalade support can be downloaded from here .

Nowhere in the network I could not find manuals on how to run cocos2d-x on Marmalade, so I decided to write my own, because quite often came across questions about how to do this from other participants in the action.

If you have not already installed the Marmalade SDK, then you should do this by clicking on the link to download and install the correct version.

So, after installing the Marmalade SDK, download the version of cocos2d-x from this repository . Unless, of course, by the time you read this article, examples for Marmalade were not added to the main thread.

Next, you can go to the samples \ HelloCpp \ proj.marmalade folder and run the HelloCPP.mkb file - it will perform all the necessary steps and launch the IDE that you specified when installing Marmalade with the HelloCpp project open. But what if you want to create your own, new project? To do this, you need to manually transfer the necessary libraries and edit the HelloCPP.mkb file .

I created a new directory and named it Cocos2D-x. You need to copy 2 folders to this directory from the downloaded cocos2d-x repository - cocos2dxand extensions , simultaneously deleting from them all folders with the proj prefix except proj.marmalade . Now here we create a folder for our project, for example m_test. In our m_test folder, copy the Classes and Resources folders from samples \ HelloCpp , as well as the src folder from samples \ HelloCpp \ proj.marmalade . Then we create the m_test.mkb file with the following contents:

	#Папка для поиска субпроектов
    #Папка из которой эмулятор берёт ресурсы игры
	s3e-data-dir = "Resources/iphone"
    #Папка из которой реальное устройство берёт ресурсы игры

Save and run the file. Our new project will open, open the file AppMacros.h and in the 9th line change kDesignResolution_2048x1536 to kDesignResolution_480x320. Next, open app.icf and look for these lines there:

Under normal conditions, these lines set the size of the emulator window, but for some reason I only read the first parameter and was assigned both width and height, so if you have a similar problem, just delete these lines and specify the dimensions of the emulator window in the emulator itself in the menu Configuration-> Surface.
Compile for x86 and enjoy the result.

Any additional information on the parameters of the mkb file and on Marmalade in general can be obtained from the documentation supplied with the SDK, it can be opened through the Marmalade LaunchPad or simply from the docs folder in the directory with the installed SDK.

I would appreciate it if anyone knows a way to make a cocos2D-x project easier.

Also popular now: