⬆️ ⬇️

Creating a Cocos2D-x project in the Marmalade SDK





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



As it turned out, before the Cocos2D-x port branch on Marmalade was led by Francis Styck and in earlier versions there were examples of creating the Marmalade project, but he came across some difficulties and the porting work slowed down. Then the guys from Marmalade took over the work and at the moment on the Cocos2D-x githabe is hanging their pull request , 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 a guide on how to run cocos2d-x on Marmalade, so I decided to write my own, because quite often came across questions of how to do this from other participants in the action.

')

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



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



Then you can go to the samples \ HelloCpp \ proj.marmalade folder and run the HelloCPP.mkb file - it will perform all the necessary actions and launch the IDE that you specified when installing Marmalade with the HelloCpp open project. 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 called it Cocos2D-x. In this directory from the downloaded cocos2d-x repository, you need to copy 2 folders - cocos2dx and extensions , simultaneously deleting from them all the 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 , and the src folder from samples \ HelloCpp \ proj.marmalade . Immediately create the file m_test.mkb with the following content:



options { #    module_path="../cocos2dx/proj.marmalade/" #       s3e-data-dir = "Resources/iphone" } includepaths { Classes } subprojects { IwGL cocos2dx } assets { #        (Resources/iphone) CloseNormal.png CloseSelected.png HelloWorld.png } files { [Main] (src) Main.h Main.cpp (Classes) AppDelegate.h AppDelegate.cpp HelloWorldScene.h HelloWorldScene.cpp AppMacros.h } 




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

 WinWidth=480 WinHeight=320 


Under normal conditions, these lines set the emulator window size, but for some reason I only read the first parameter and 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 Configuration-> Surface menu.

Compile under x86 and enjoy the result.







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



I would be grateful if someone knows a way to create cocos2D-x project easier.

Source: https://habr.com/ru/post/157599/



All Articles