This documentation will show you how to use cocos console to create and run a new project.
Runtime Requirements
Android 2.3 or newer
iOS 5.0 or newer
OS X 10.7 or newer
Windows 7 or newer
Linux Ubuntu 12.04 (or newer)
cocos2d-x v3.0rc(or newer)
Software Requirements
Xcode 4.6 (for iOS or Mac)
gcc 4.7 for Linux or Android. For Android ndk-r9 or newer is required.
Visual Studio 2012 (for Windows)
Python 2.7.5
Create A New Project
$ cd cocos2d-x
$ ./setup.py
$ source ~/.bash_profile # may be ~/.bash_login or ~/.profile, depends on your environemnt
$ cocos new MyGame -p com.MyCompany.MyGame -l cpp -d ~/MyCompany
MyGame: name of your project
-p com.MyCompany.MyGame: package name for android
-l cpp: programming language used for the project, valid value is cppand lua
-d ~/MyCompany: directory to hold your project
Folder structure of the generated project is as following:
(Note: The directory may be different when the project type is lua.)
Build And Run New Project
$ cocos run -s ~/MyCompany/MyGame -p ios
-s: directory of the new project. This could be an absolute path or a relative path.
-p: which platform to run on. Options are ios,android,win32,mac and linux.
(Note: You are a tmux user, you should add reattach-to-user-namespace before the command cocos. For more information, please refer to (this link)[https://github.com/phonegap/ios-sim] for more information.)
You can run cocos run --help for more detail information.
YuYe, could you additionally help us with creating a new game that is Less than 20mbs, currently this creates a 200+mb game which is hurting my computer she can’t handle it that big
Thank you for writing the tutorials. I have some feedback to help clarify your tutorials for new comers to Cocos2D-X. The purpose of my writing is not to pick on you but to provide my personal experience when I first started to learn Cocos2D-X. I had to go through so much frustration trying to make sense of tutorials that were written very poorly, and wasting a lot of my time looking for answers to error messages on forums because the tutorials had missing steps or poorly written.
Firstly, the steps are not complete, you are missing the steps with assumption that everyone that reads them already has the same understanding as you do. Remember you are writing the tutorial for someone who is coming to Cocos2D-X as a new user or someone who is not experienced. Try to put yourself in their shoes and think from their perspective.
Secondly you listed all platforms, development tools and mobile OS but only show some of the steps to create a new project in Mac OS and compiling the source code for iOS.
My recommendations to help others make the best of your tutorials are:
Clarify all prerequisites (e.g.: Assumption is that you already have the Android/iOS, whatever environment setup and configured). You can point them to Apple documentation or Android documentation, but either way clearly stating that if the prerequisite is not met, Cocos2D-X setup will not work.
Explain your steps clearly, e.g.: ‘cd cocos2d-x’ you and I know that its changing directory to point to the Cocos2D-X root folder. A new comer may or may not know that, especially if they don’t use command line.
Since the steps are not well explained, how will a user get help if they get error messages
Explain how to setup environment variables. By just saying “depends on your environment” will only make new users curse at your name.
There is no such thing as a ‘bash_profile’ in Windows, so if I were trying to follow your tutorial would be stuck right now.
Last but not least proof read the tutorial before posting it. Ask a non-developer to read it and get their feedback if the tutorial makes sense to them before posting. Type it up in a Word processor program like Google Docs or MS Word to help check grammar and spelling.
Thank you for taking time and writing these tutorials. I appreciate your effort and want to help make sure readers of your tutorials are getting the most of it.
Firstly, thanks for the tutorial, I’m able to run the project on iPhone simulator. However, it fails to run on my android Samsung Galaxy S2 simulator ( I use genymotion ) to run. On the android simulator it report that “Unfortunately, xxx has stoped”.
Hi,
Great article,I got it imported onto Xcode perfectly for Cocos2dx 3.0.
I wanted to know about setup on Windows enviornment.Following the above steps for windows
I encounter errors regarding Cygwin,which I read somehwere is no longer required,there is not much documentation regarding windows setup.A tutorial would be greatly appreciated.
@yuye
thnks for the reply.The setup.py goes of without a hitch. This is the error I get when I do "cocos new test1 -p com.MyCompany.test1 -l cpp -d F:\And
roid\ProjectsCocosV3"
cygwin warning: MS-DOS style path detected: \Python27 Preferred POSIX equivalent is: /cygdrive/f/Python27 CYGWIN environment variable option "nodosfilewarning" turns off this warning. Consult the user's guide for more details about POSIX paths: http://cygwin.com/cygwin-ug-net/using.html#using-pathnames Traceback (most recent call last): File "F:\Android\cocos2d-x-3.0\tools\cocos2d-console\bin\/cocos.py", line 379, in <module> plugins = parse_plugins() File "F:\Android\cocos2d-x-3.0\tools\cocos2d-console\bin\/cocos.py", line 287, in parse_plugins cp = ConfigParser.ConfigParser(allow_no_value=False) TypeError: __init__() got an unexpected keyword argument 'allow_no_value'