Pages

Getting Cocos2dx apps published on the Microsoft Store

I've just had my first Cocos2dx approved for the Windows Phone store.  Time will tell whether it was worth it, but here's a very brief overview of what you need to do.

1) Install the Windows Phone 8 SDK.  If you are working on a Mac and want to run Windows 8 in a VM read this post as it's not straight forward! http://www.mwebb.me.uk/2014/03/xde-stopped-working-vmware.html

2) Download Cocos2dx 2.2.2 or later. If you haven't seen it, this version comes with a really cool project creator  You need Python 2 (NOT 3!!) to run this.  It will create a whole bunch of folders. Just drop your classes and resources into the right folder, and open the .vcxproj file in proj.wp8 to open the Windows 8 Project.

3).  You are going to have to find your way around Visual Studio!  Briefly, things to think about/do:

  •  You have to run your app in Win32 to debug, and then switch to ARM for release. 
  • Drag your classes into the classes folder in Solution Explorer.  You don't need to do this for your resources though
  •  You need to swap the icons in proj.wp8 for ones that match your game (but you can ignore AlignmentGrid.png).
  • You may have trouble compiling Box2d for ARM.  I didn't solve this, but wasn't using it, so just removed it.
4) You need to make the Back button take you back a scene on every scene, otherwise Microsoft will reject your app.  You'll find a file called <appname>.cpp.  This is where you have to control the back button.  I did it by tagging each scene, and then using the tag to determine what the back button should be (which for me was go back to the main menu, unless you are on the main menu and then you can quit).  If you set args->Handled to false it will quit the app, otherwise it won't.  Here's my code as an example:




void ZombieAttack::OnBackButtonPressed(Object^ sender, BackPressedEventArgs^ args)
{
    // Leave args->Handled set to false and the app will quit when user presses the back button on the phone

    int tag = CCDirector::sharedDirector()->getRunningScene()->getTag();

    CCScene * s = CCDirector::sharedDirector()->getRunningScene();

  if (tag!=1)
 {
           CCTransitionScene* trans = CCTransitionSlideInL::create(0.3, HelloWorld::scene());
            CCDirector::sharedDirector()->replaceScene(trans);
            args->Handled = true;

  }

  else

  {
  args->Handled = false;

  }

}

(I got this idea from a forum posting - if I find it again I will credit!)

Finally, when you build your app it creates a file with a .xap extension in a location like this:

C:\Users\xxxxx\Documents\cocos2d-x-2.2.3\projects\ZombieAttack\proj.wp8\WP8\ARM\Release\ZombieAttack\ZombieAttack_Release_ARM.xap

That's the file you should submit to Microsoft.

It's too early to tell if has been worth it from a download perspective.  I'll post something on that later.

No comments:

Post a comment