The following is not tested, only new cocos2d-x projects under windows are tested, and run in elicpse configuration, refer to the eclipse configuration steps below http://blog.csdn.net/jinjian2009/article/details/8059267 #1
Note that you still need to copy the resources steps below #1 ~
The following tutorial is for reference
Certificate -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
From: http://mobile.51cto.com/iphone-330448.htm
Cocos2d simplegame is written by Ray wenderlich. Almost all beginners of cocos2d-iphone have read his series of tutorials.
First you need to download the latest stable version of http://download.cocos2d-x.org in cocos2d-x. When I write this article, the version is still cocos2d-0.99.5-x-0.8.2, and then the game resource is updated to 0.9.1. The 0.99.5 flag indicates that the C ++ interface is based on its parent version cocos2d-iphone 0.99.5, And the suffix 0.8.2 indicates the version number of our cocos2d-x interface.
The source code of cocos2dxsimplegame is downloaded here:
Http://www.cocos2d-x.org/attachments/535/Cocos2dxSimpleGame-0.9.1.rar
I have tested the source code on the cocos2d-1.0.1-x-0.9.1.
Let's get started. You can directly jump from the following directory to your platform.
Chapter 1-how to create new cocos2d-x projects on multiple platforms
1 From Win32
1.2 install wizard on Visual Studio
1.3 create a new cocos2d-win32 Project
1.4 compile and run
For more information about 1.5 people with bad luck, see here.
2. From vphone
3 from iPhone
4. Start with Android
4.1 In Windows
4.1.1 create a project
4.1.2 compile native code
4.1.3 move the project to eclipse
4.1.4 compile and run the Java code
4.2 in Linux
1. Start with Win32
The Cocos2d-win32 interface has been tested properly in WINXP + vistualstudio2008/2010. However, in Vista/win7, I cannot ensure that it runs well. If you still cannot run the cocos2d-win32 interface as per the tutorial, here is a reference.
1.2 install wizard on Visual Studio
After you download and decompress the source package, find the cocos2d-x folder, click "build-win32.bat" to compile the entire project, and then click "install-templates-msvc.bat" to install the wizard. The bat script automatically corresponds to vs2008 or 2010. For more details, see this document Coscos2d-x Application Wizard for Visual Studio User Guide
1.3 create a new cocos2d-win32 Project
Now you can open the cocos2d-x/cocos2d-win32.vs2008.sln through vs2008, and we can see the library file from here.
Right-click "solution 'cocos2d-win32.vc2008 '" and select "Add-> new project ",
Select cocos2d-x-> cocos2d-win32 application, write "cocos2dxsimplegame" in the name column, and use the default path settings.
Note: In the Win32 & wophone interface, the game path must be put down under the root directory of the cocos2d-x.
Click "OK-> next". box2d is not checked because cocos2dsimplegame does not use the physical system. Make sure that "simpleaudioengine in cocosdenshion" is selected, and then click "finished ".
1.4 compile and run
Now we can see that "cocos2dsimplegame. Win32" has been created. Our game now relies on libcocos2d & libcocosdenshion libraries.
Well, compile and run. Normally, if you are not lucky, you will see the figure below.
For more information about 1.5 people with bad luck, see here.
Maybe some people cannot successfully run this helloworld template on Win32, because the cocos2d-win32 interface is based on powervr OpenGL ES 1.1 SDK for PC emulation (Windows Vista/XP)
Http://www.imgtec.com/PowerVR/insider/sdkdownloads/index.asp#GLES1b
We integrated the powervr library into the path
Cocos2d-x-root/cocos2dx/platform/Win32/third_party/Libraries
Therefore:
For win7 users: powervr has not released Windows 7 interfaces. But you can still try it. Many win7 users in the Forum have successfully run this example.
For WINXP/Vista users: If helloworld crashes due to any glxxx or eglxxx function, update your graphics driver and go to the NVIDIA/ATI/Intel website to find the latest driver.
For bad luck users: You can create a cocos2d-x project in xcode, or go to church/temple to find some luck: P
2. Start from vphone
If you are a wophone developer, the above Win32 steps also apply to you. There are only three differences:
1. You have to set the cocos2d-x-root to the d:/work7 directory, there are strict app path requirements for wophone.
2. Please use vs2008 to open D:/work7/cocos2d-x/cocos2d-wophone.sln instead of cocos2d-win32
3. Select cocos2d-wophone application in the add new project dialog box, as shown below
The result of helloworld compilation and running of cocos2d-wophone is as follows:
3. Start with iPhone
We have the template for xcode since version 0.8.2. You can simply create a cocos2d-iphone project as you do when creating a cocos2d-x project. First, find the root directory of the cocos2d-x, and then run the install-templates.sh under the MAC Shell
/Install-templates-xcode.sh-u-F |
Here you can select your xcode version, xcode3 or xcode4.
After the installation is complete, you can open xcode and then click "creat a new xcode project ". You will see this dialog box
Select cocos2d-x application, click choose, and enter the name of the project. Xcode will help you create a project for your cocos2d-x.
Please note that the IOS cocos2d-x project can be created anywhere you want. The wizard in xcode copies all cocos2dx, cocosdenshion, and other libraries to the project folder. This is different from the wizard of Win32 & vphone on Visual Studio.
After compilation and running, you will see the following helloworld
4. Starting from Android
The android project in ndk has two parts, one corresponding to Java and the other corresponding to C ++. We will run the creat-android-project.bat (or run the create-android-project.sh under Linux) to create the android ndk project.
4.1 In Windows
4.1.1 create a project
The create-android-project.bat is in the root directory of the cocos2d-x. You should make some changes based on your environment.
To adapt to my configuration environment, I made some changes in the create-android-project.bat.
Set_cygbin = c: \ cygwin \ bin
Cygwin bin path
Set_androidtools = D: \ Android-SDK-Windows \ tools
Android SDK tools path
Set_ndkroot = D: \ Android \ android-ndk-r5b
Root directory of ndk
Now you can run create-android-project.bat to create an android project:
Go to the root directory of the cocos2d-x, double-click the create-android-project.bat, enter the project name and target ID, as shown below
After version 0.8.2, you may be required to enter the package path in the format of org. cocos2dx. cocos2dxsimplegame.
The target ID varies with different environments. Make sure that you enter a valid target ID. Currently, cocos2dx supports 2.1-update1 and android2.2. It has not been tested in other versions.
4.1.2 compile native code
Now you can see a folder named "cocos2dxsimplegame" under the root directory of the cocos2d-x, run your cygwin, then go to "cocos2dxsimplegame/android", and then run "build_native.sh ".
4.1.3 move the project to eclipse
Run your eclipse, click File-> New-> Project-> Android project, and move it to the project as follows:
4.1.4 compile and run the Java code
Right-click the project and select "build project". Right-click the project and choose "Run as"> "Android Application ". Then you will see the following results:
4.2 in Linux
You should run creat-android-project.sh to create an android project, the other steps are the same as in windows.
You should define some environment variables in your environment to run "create-android-project.sh ".
Initialize some environment variables.
Ndk_root
Root directory of ndk
Android_sdk_root
Root directory of Android SDK