Import box2d, CocosDenshion, extensions to windows phone 8 project for cocos2dx 2.2

Import box2d, CocosDenshion, extensions to windows phone 8 project for cocos2dx 2.2
0.0 0


Nice work excellent day, I did it yay ho ho.

So I am gonna summarize them in the following steps for windows phone 8
* If your create a fresh project through you will have your multi platform project created in projects folder. Goto proj.wp8 in your current project.
* Open up your project in Visual Studio (I am using 2012). In solution explorer on left you will see only two projects under your solution. One by your project name given during script creation. And the other will be libcocos2d.
* So the point is CocosDenshion is not added to your solution by default you need to add it manually. Same goes for Box2D if you want to integerate. So here it is
* Goto your cocos2dx2.2 folder. You will see CocosDenshion folder. In that you will see proj.wp8. There is your CocosDenshion.vcxproj. Add it to your solution as a project by right clicking.
* So in order to generate its dll and lib we need to connect them in the solution. So right click on your solution and choose properties. Goto CommonProperties/ProjectDependencies. Check CocosDenshion or libBox2d (if you want to add Box2d to your app) and click apply and ok. Now If you tap on “Device” to run your libraries will be generated.
* Next question how to link them to your project. Easy pesi through Linker.
* Now first you need to give the path where your .lib are present. In order to do them goto your current project properties. Goto ConfigurationProperties\Linker\General\additionalLibraryDirectories. tap on edit and add these as in my case

C:\software\cocos2d-x-2.2.0\cocos2d-x-2.2.0\projects\HungryFish\proj.wp8\WP8\ARM\Release\CocosDenshion; C:\software\cocos2d-x-2.2.0\cocos2d-x-2.2.0\projects\HungryFish\proj.wp8\WP8\ARM\Release\Box2D;%(AdditionalLibraryDirectories)

So your paths are set.

  • Now to add .lib files. Goto Linker\Input\AdditionalDependencies and add libBox2D.lib;CocosDenshion.lib;.

thats it compile and it will work. Worked for me. If you want to use extensions follow the same steps. Also change path for debug configuration.


@Saud Ahmed
Thanks for sharing.


@Mingo Zhang
My code is now linking correctly but when I create SimpleAudioEngine shared object anywhere in the code my game closes with a message that .lib missing I guess even it never goes into appdidfinishLaunching. But when i comment those declarations my code executes perfectly. Box2d and other extensions are working perfectly fine through above process.

One more thing to point out when i use CCScrollView in any layer. Lets say if there is a layer with CCScrollView added as child and i go to that layer. My whole screen crops down. Currently I am testing on HTC 8X with screen resolution 720x1280.


ty, it helped me a lot. Now i will make everything more clear :slight_smile:
Step 1, add CocosDenshion.vcxproj by Your Solution > Right Click> Add Exist Project > link to cocos2d-x-2.2.0/CocosDenshion/proj.wp8/CocosDenshion.vcxproj.
Step 2, Your Solution
> Right Click > Properties> Projects (chose Your Project) + Depends on (Check CocosDenshion).
Step 3, Your Project > Right Click> Properties > Common Properties> Framework and References > Add New Reference> Check CocosDenshion.
Step 4, Your Project > Right Click> Properties > Configution Properties> C/C++ > General> Additional Include Directories > Edit> New Line > Link to cocos2d-x-2.2.0/CocosDenshion/include.
Step 5, Your Project
> Right Click > Properties> Configution Properties > Linker> General > Additional Library Directories> Edit > New Line> Link to cocos2d-x-2.2.0/WP8/Win32/Debug/CocosDenshion.
Step 6, Your Project > Right Click> Properties > Configution Properties> Linker > Input> Additional Dependencies > Edit> add CocosDenshion.lib.

That’s all to fix issue CocosDenshion missing when create a new project through project-creator/

Bonus: to init sound
#include “SimpleAudioEngine.h”
using namespace CocosDenshion;

you can add sound by :
Your Project~~ Assets~~ Right Click choose Add Exist Item - Link to your sound file.
And make sure your sound file in your Assets folder too.

to play sound:
SimpleAudioEngine::sharedEngine()->playBackgroundMusic(“Your sound path”, true);

Hope it helps


Hello, performed all of the steps.

Posted by

SimpleAudioEngine :: sharedEngine () > preloadBackgroundMusic ;
SimpleAudioEngine :: sharedEngine
> setEffectsVolume (0.5);

Launched the application on the phone for OS WP8, the application immediately closes. If you run an emulator application WVGA 512MB of error:

Error 2 error LNK1112: module machine type ‘ARM’ conflicts with target machine type ‘X86’ D: cocos2d-x-2.2 projects runner proj.wp8 CocosDenshion.lib (CocosDenshion.dll) runner

P.S. sry for my bad english.


First of all, library compiled with ‘ARM’ configuration does not work on the emulator. You have to compile the win32 library for the emulator for testing.

Seems the crash is caused by missing ‘SomethingTheme.mp3’ file? Have you add the mp3 file to the Asset folder in the project view? Have you set the property ‘Content’ to ‘True’ of the mp3 file? Cocos2dx use Asset/Resources as the root folder for audio by default.


@Ivan Samoylov
cocos2d-x-2.2 for wp8 only support wav file. So you must convert your mp3 file to wav format.
If you put it in Assets/Resources/Sound/something.wav -> your path is: “Sound/something.wav”!
Try this!
Best regards.


Trịnh Ngọc Huy, thanks.



I followed all steps,
My game now running fine on simulator in release mode, but when i select ARM for device testing, its giving me an error,

“error MSB4019: The imported project”C:Files (x86)1.0\Microsoft.Windows.UI.Xaml.Cpp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk."

and when I am clicking on error message, the cursor pointing to following line in “Microsoft.CppCommon.targets” named file.

" "

what should I do?
I am attaching a screenshot about the problem.

I believe its box2d not adding properly.
But I have removed and added it again, but still not making any sense.



@vinit somani
Maybe the problem is your Visual Studio.
First, try to rebuild your project.
If it didn’t work, check the path “C:Files (x86)1.0”. If the folder is empty, i think you should uninstall all Visual Studio product installed on your machine and re-install only one Visual Studio product.


@Trịnh Ngọc Huy

Thanks for response,but the path you have given me to check
“C:Files (x86)1.0”
I don’t have “WindowsXaml” folder in Microsoft. And I have tried several set-ups, iso images as well as normal visual studio 2012 direct download, And all are showing the same error, Solution just recognising and adding Box2d project (lib) when there is release + win32 mode in selected tool bar. Otherwise they are not getting project path.