Quantcast
Channel: MS Open Tech » Tutorial
Viewing all articles
Browse latest Browse all 17

How to Install Cocos2d-x to Build Windows Store Apps

$
0
0

Since our last contributions to Cocos2d-x [v2 Universal App and v3 Universal App], developers now have two primary ways to create applications for Windows RT (Windows 8.0 and 8.1), Windows Phone 8.0 and Windows phone 8.1. Both of these versions are available in the MS Open Tech GitHub repository, as well as in the official Cocos2d-x repository.

I have created this brief step by step clarifying the installation process for each of these two versions as I hit myself some bumps on the road while doing it. Hopefully, these tips will help others get started with Cocos2d-x on Windows quickly and easily.

There are 3 different ways to setup Cocos2d-X on your machine:

· Using the Git Command Line

· Using the Git for Windows application

· Downloading and executing the zip file from GitHub or the Cocos2d website

Git Command Line:

It is the hardest, but also the powerful way. The main idea is to clone the repo on your machine, update the sub module and download all the dependencies.

Pre requisite: Get GIT working on your windows development machine

Go on GitHub site and install the git for windows, you’ll have the git UI, and you’ll find in C:\Users\<user name>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\GitHub,Inc the Git Shell shortcut. (see here for more detail for installing GitHub)

I use PowerShell, because it is easier with the two factor authentication.

clip_image001

Working with the v2.2.5 of Cocos2d-x.

First you have to clone the MS Open Tech or the Cocos repo, note that in the MS Open Tech repo you will find the latest version for Windows version (there is always a delay between the pull request made by MS Open Tech and the merge into the Cocos repo)

Start the Git Shell, change to the directory where you want to clone the repo, the clone command will create for you the sub directory <cocos2d-x>. Type these commands:

Steps to get the v2.2.5 Universal App version

  1. git clone https://github.com/MSOpenTech/cocos2d-x.git
  2. cd cocos2d-x
  3. git checkout v2-universal
  4. git submodule update --init
  5. download-deps.py

To create your first project in v2.2.5:

  1. cd tools\project-creator
  2. create_project.py -project MyGame -package com.foo.bar -language cpp
  3. open MyGame.sln in cocos2d-x\projects\MyGame\proj-win8.1-universal\

 

Working with the v3.3 of Cocos2d-x

At the time of writing this, we highly recommend to have a separate repo to work on v3. You’ll have two repo (v2 and v3) into two separate directories in your computer.

How to get the v3.3 Universal App version

  1. git clone https://github.com/MSOpenTech/cocos2d-x.git
  2. cd cocos2d-x
  3. git checkout v3.3-stable
  4. git submodule update --init
  5. download-deps.py
  6. setup.py (then restart your console to update settings)

Create your first project:

  1. cocos new MyGame -p com.bar.foo -l cpp -d projects
  2. open MyGame.sln in cocos2d-x\projects\MyGame\proj-win8.1-universal\

Note in the v3, there no more the python script to create new projects, cocos.exe became a command line program allowing you creating new projects.

 

Working with GitHub for Windows

From the GitHub web site, select the repo you want to clone (here cocos2d-x v3 branch)

clip_image003

Then click on Clone on Desktop, and if you have GitHub for Windows installed, the GitHub app will be launched and start to clone the repo on your computer. You can change the branch from the tools, the only thing you have to do is running the python scripts from the root of the repo (like in the git command line case above)

  1. download-deps.py
  2. setup.py (then restart your console to update settings) (for the v3.x only)

clip_image005

Downloading the Cocos2d-x Zip File

The last option may be the simplest to use. Just click on the Download link on the MS Open Tech GitHub project site or from the cocos2d-x site to extract all of the files into a working folder on your computer. The zip file contains in theory all the dependencies (that is not the case for all the sources I tested, so in case the dependencies are not included, you may need to run the Python script from the root of your installation directory like we saw with the git command line process).

  1. download-deps.py
  2. setup.py (then restart your console to update settings) (for the v3.x only)

Note that the zip versions are not the latest one, in fact the zip file need to be prepared by the team in charge of the version, and sometime that take few weeks to see an updated version of the zip file…

I hope this article will help you to start in a good condition using cocos2d-x on Windows, and help you saving time at the installation/preparation process.

A bientôt

Eric


Viewing all articles
Browse latest Browse all 17

Trending Articles