Search code examples
silverlightxamlwindows-phone-8cocos2d-x

Cocs2d-x + XAML on windows phone 8


A couple of weeks ago the new cocos2d-x (version 2.2.1) was released with great support for windows phone. However, there is one thing missing in the templates and examples: integration of XAML with Cocos2d-x. A feature that is absolutely necessary for free to play games that use ads since every single ad network uses a silverlight component.

I tried to implement the integration myself but I am stuck and all I get is a black screen. I used the following strategy for implementing it:

  1. modified the CCEGLView class. The create method takes the follwing arguments:

    bool CCEGLView::Create(In IDrawingSurfaceRuntimeHostNative* host, In ID3D11Device1* device)

  2. in the XamlComponent class of the visual studio template I have added CCApplication member variable and the Connect methos create the CCEGLView and runs theCCAplication.

Everything compiles without any errors and runs without any crashes. However, the screen remains black :-( My guess is that the drawing surface / windows is not correctly passed but I do not know how I can do this.

Any help and ideas appreciated.

Cheers Tom


Solution

  • Cocos2dx 2.2.1 used native mode, currently it's not support XAML+native hybrid mode. CoreWindow is a fundamental component, do you remove all the referene to CoreWindow?

    You can look up from this project, they've a branch for wp8+waml.

    https://github.com/MSOpenTech/cocos2d-x/tree/wp8-xaml