[PLEASE ANSWER] Project creation in Cocos lacks windows phone project

I have a question, which bothers me for a longer time. I posted it many times on forums, but got no respond. From some time (since cocos2d-x 3.4 I believe) there was a significant change in project template. Before cocos2d source code was included in each project, first compilation was long and project size was huge. But from 3.4 project template contains only precompiled library, which leads to small project size and fast compilation time. But not all project templates are made. Windows phone project is missing. I really love new template, but because of this I’m forced to use the old one. Why is that so?

I wanted to ask the same.

Please help :slight_smile:

Hey devs, can you respond?

Bump bump.

Gonna ask this again.

Just downloaded 3.7 and still no windows phone project.

What is the reason you want a Windows Phone Project instead of using the proj.win8.1-universal?

You can develop in the shared project in VisualStudio 2013 Community Update 4+ proj.win8.1-universal using the WindowsPhone.proj and just ignore the Windows project if you don’t want it. But I chose to support both because there is a minimal amount setup to get them both working.

For connecting Analytics, IAP, and Ads to the universal app, it looks like that can probably be done in the shared project XAML files and by adding required dlls similarly to how it was done in the proj.wp8-xaml. Maybe update the OpenGLESPage.xaml or create a new .xaml and tie it into the project somehow… not sure. But in OpenGLESPage.xaml.cpp I see that we can conditionally check in the shared project if it is a phone or a windows app with #if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP).

I have been using the proj.ios_mac, proj.android and proj.win8.1-universal with good results so far.

I might be wrong, but I think I read that the proj.wp8-xaml went away because as of 3.6 (just a guess since I cannot find the reference I am citing) there were changes regarding Angle or something else. So the Cocos2d-x team and MS Open Tech would not support that project for windows phone 8 going forward. But like I said, I cannot find the article on this so I might be wrong about this.

First of all there’s no windows-phone universal project.

After making a new project I have these directiories:

Classes
cocostudio
proj.android
proj.ios_mac
proj.win32
Resources

Same on mac os x and windows.

Now, even if it’ll create universal project there are some serious issues with it. There are a lot of libraries missing for universal. Admob for example. Also I’m not sure that IAP and stuff like that can be done here.

@stammen @stammen2 Can you please share the reason why there is not a WP8.1 project with C#/XAML to C++ glue code like there used to be (proj.wp8-xaml) in Cocos2d-x? Is there a possibility to add something like that back into Cocos2d-x?

Or, is there a way to add Admob (or other C# based DLL’S) to the proj.win8.1-universal/Windows Phone project?

@piotrros, if you are using Cocos2d-x 3.7 and configured your environment as descried here: https://github.com/cocos2d/cocos2d-x , then it should generate the following structure.

Edit: Since this question is under cocos2d-x C++ I assumed you are using the cocos console to create a C++ project. But I just noticed that you have cocosstudio in your directories. How are you creating your project?

Classes
CMakeLists.txt
cocos2d
LICENSE
proj.android
proj.android-studio
proj.ios_mac
proj.linux
proj.win8.1-universal
proj.win10
proj.win32
Resources

Here is the reference that I cited above about Cocos2d-x dropping support for WP8 as of 3.6.

@piotrros are you hoping to get a Windows 8.1 with C# and C++ project template?
I agree that would be useful.

You are probably right about not being able to add Admob to the universal project. I looked into it some more and there is not an obvious way to get it to work. Hopefully VS 2013 has some hidden tricks up its sleeves…

Ok I figured out why I have different structure. It’s because I’m creating project via “cocos” gui (well in console it makes the same), which uses downloaded “cocos 3.7 framework”, which differs from standalone cocos2d-x 3.7. So the project structure differs that much, huh. No idea why is that so. Anyway how much GB’s is your empty (after compilation) project? It should be huge. And mine is like few megabytes, because everything is precompiled and attached from the outside. Also compilation time is blazing fast. But it lacks windows phone. And android studio would be useful :slight_smile:

In my case cocos2d-x 3.7 generates pure c++ projects - it means you CANNOT use any C# libs.

You could use c# if base project would be c#: going from c# to c++ and back to c# is allowed, going from c++ to c# is not.

What I am doing right now is I am using WinRT Shared component written in c++/cx, which allows me to use in app purchases and other things (unfortunately no admob)

best regards

Is it possible to have a C#/cx project in windows phone 8.1 with Cocos2d-x 3.7? Like the proj.wp8-xaml, but upgraded to proj.wp8.1-xaml?

Were there performance reasons that proj.wp8-xml was removed and replaced with the pure C++ project proj.wp8.1-universal somewhere between 3.0 and 3.7?

In the previous proj.wp8.xaml I think was a c++/cx project.
I’m not certain how to verify that is what it is called, but it was a c# based project with a C++ lib extension, so I think it was.

@ghua, not sure why you said “going from c++ to c# is not allowed”.

With that project in Cocos2d-x 2.2.6 and 3.0 I was able to integrate Flurry Analytics and Admob, with C++ calling into the c# code to show interstitial ads and to send Flurry events. But those projects targeted Windows Phone 8.0, not 8.1.

Here is some information that I found that seems to reflect what I did.
http://blogs.msdn.com/b/ujjwalk/archive/2014/05/05/calling-c-code-from-c-for-windows-phone-apps-and-games.aspx

I added C# objects and code to MainPage.xaml.cs and a class called NativeEventHelper.cpp where the C++ code lives. If I recall, I just copied the style of C++ to C# code and C# to C++ code that was already implemented in these classes. These two classes then glued the C++ and C# together similarly to how JNI works with Android.

Not having such a feature in the Windows Phone 8.1 Universal project makes it kind of useless.

Yeah, that sucks. Perfect solution will be precompiled library as It saves a lot of space (my projects have 7gigs+ because of visual studio) and compilation time.

Could you please check the project you added flurry and admob to - I bet it was C# project that was running C++ cocos code which executed some C# functionality of mentioned libraries.

In latest cocos it is C++ core project - if you find a way to run admob in it, please let me know - you will save my day :wink:
It is still possible to use C++/CX as Windows Runtime Component and then call WinRT, but it is NOT possible to use C# libs - at least I am unable to.

I cannot tell you exactly WHY - it has something to do with transitions between managed C# and unmanaged C++.
best regards

check out this one

it’s possible to call c++ from c# and vice versa. Via CLI ofc :slight_smile:

I have 25 games that I have published for WP8 using the C++/CX project format for WP8 and they use Admob and Flurry.

But as I stated above my challenge is to:

1) Identify a solution that will work with WP8.1, and

2) Clarify if there was a reason that the C++/CX project was removed and replaced with a C++ project.

I really hoping @stammen or someone else can comment on why the C++/CX project was removed. I dont want to waste time reimplementing something that was removed for a good reason.

@ghua, yes the working solution that I have is a C# project with a C++ lib extension, e.g. C++/CX. But it is for Windows Phone 8.0. The image I posted above with the Windows Phone 8.0 next to each project shows that it is a C# and C++ solution.

@piotrros, the link to Stack Overflow that you posted shows how to get to work on Windows Phone 8. It seems to be the same way that I implemented it and linked to above. By the way, in the link you posted, the #if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) is only true if it is Windows Phone 8.

For the Windows Phone 8.1 Universal Windows Phone Project, it needs to be #if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT for it to be compiled into the phone project app.

I’m pretty sure the previous proj.wp8-xaml was technically called a C++/CX project. It definitely was C# based and had a C++ lib extension.

C++/CX (component extensions) is a language extension for C++ compilers from Microsoft that enables C++ programmers to write programs for the new Windows Runtime platform, or WinRT.

The following post hopefully will have more information soon from @zhangxm or @stammen:

Windows phone c# project missing from a whole cocos2d-x has been explained (and it’s sad), but why project created from “cocos” via gui differs from that one created from console? Via gui c++ wp-universal project is missing as well as c# project.

As it was said before, fresh project directory contents (excluding files in root dir) from gui (small directory size, fast compilation, uses precompiled cocos2d-x libs):

Classes
cocostudio
proj.android
proj.ios_mac
proj.win32
Resources

and from console (more projects, but cocos2d-x whole source code is included, which multiplies directory size and project compilation time):

Classes
cocos2d
proj.android
proj.android-studio
proj.ios_mac
proj.linux
proj.win8.1-universal
proj.win10
proj.win32
Resources

So no android-studio, win10, win8.1-universal and linux in “gui” created project.

Hi, Mr. ghua

If you know,
Would you please tell me By using WinRT Shared component written in c++/cx , pubcenter ads are allowded ?
By the way ,can you share the steps how to add IAP by using WinRT Shared component written in c++/cx.

Best Regards
Roger Phang