如何在eclipse

时间:2015-05-04 22:23:10

标签: android eclipse cocos2d-x

我遇到了问题,希望得到您的帮助。我得到了一些我想在Play商店发布的Cocos2dx源代码

我希望有人向我展示如何在Windows机器上的eclipse上添加Cocos2dx

所以我将能够发布这些代码。请任何人能够一步一步告诉我该怎么做..

由于

2 个答案:

答案 0 :(得分:1)

Hello friend i am also working on cocos2dx .. and i have done setup correctly and its working for me ... i am going to describe what i have done........it may help for you as well as others



=============cocos2dx android setup guide=====================================

-  check for these 6 things
   1-> adt
   2-> ndk
   3-> cocos2dx
   4-> Python 
   5-> cygwin (setup-x86_64)
   6-> jdk

// now do all steps one by one

1-> first create a specific folder where you want to setup android 
2-> copy all these files (which mentioned above) 
3-> extract adt
4-> extract ndk
5-> extract cocos2dx
6-> install python 
7-> install cygwin  (to install this you need internet connection ..so follow the steps under -- how to install cygwin)
8-> setup environment variable for cygwin -----
                  -to set this open environment variable which you find mycomputer->properties->advance settings->environment variable
                  - now find path variable and add the path of cygwin ex-- mine ic c:/cygwin64/bin
                  - add another variable for ndk   NDK_ROOT ->  mine is F:\myworkspace\Android\adt-bundle-windows-x86-20130219\android-ndk-r10d

9 -> check for java (jdk) for eclipse , if not then install java
10-> set environment variable -> edit path ---add path for java ; C:\Program Files (x86)\Java\jdk1.6.0_20\bin;
  at start of this path
 11->you have done android setup ;




 how to install cygbin
 =============================

 -> double click on cygbin file->click next->next->next->next->next-
 -> now select mirror any one i choose http://cygbin.mirror.constant.com
 -> click next
 -> now u got select package -> search for the following one by one
       autoconf, automake, binutils, gcc-core, gcc-g**, gcc4-core, gcc4-g**, gdb, pcre, pcre-devel, gawk, make


       neccesory packages--->   make 

       ->and follow the instructions


======================================     
    finally ... you have done with setup now open elipse
    import your project -race track->proj.android
    import libcocos2dx--->   CoCos2Dx\cocos2dx\platform\android\java

now open cygbin.bat file-> go to you project resourse directory -> run command --   chmod -R 777 *  
    clean your project and run








==============================================================================================================
    CREATE NEW PROJECT IN COCOS2DX BY COMMAND PROMPT
==============================================================================================================  


    1-> open cmd
    2-> 

    go to path--CoCos2Dx\tools\project-creator   ( MINE WAS F:\myworkspace\Android\adt-bundle-windows-x86-20130219\CoCos2Dx\tools\project-creator)
      now typing   cd above path  then press enter 
      now type f:  press enter
 3-> type command   create_project.py -project MyGame -package com.sensiblemobiles.mygame -language cpp
 then press enter

 4-> you have done with this. a project is created in cocos2dx/projects  folder
 5-> now to add this project in adt follow istruction (HOWW TO ADD COCOS2DX PROJECT IN ADT






=============================================================================================================== 
                        HOW TO ADD COCOS2DX PROJECT IN ADT
==============================================================================================================

follow thest steps to import a cocos2dx project for android in adt eclipse



1->  open eclipse go to file->import->Existing android code into workspace (under android tab) ->click next-> click on Browse
2-> Go to your project root folder like MyGame->proj.android
3-> finish  , your project will be added into project explorer


4-> to enable cocos2dx you need to import libcocos2dx follow above instruction same and go to root directory by following below path

 ->  CoCos2Dx\cocos2dx\platform\android\java    (F:\myworkspace\Android\adt-bundle-windows-x86-20130219\CoCos2Dx\cocos2dx\platform\android\java)

5-> now add this libcocos2dx in to your project
   -> right click on your project ->properties->click android tab ->  click add button -> select libcocos2dx -> ok -> apply ->ok

6-> Now to see your classes in this project follow below instruction

  -> right click on your project -> properties -> explore resourse tab -> linked resourse -> path variables -> Now click on add (a dialog will be Open)
      - Name   :  COCOS2DX
      - Location : enter path of your cocos2dx   (mine was F:\myworkspace\Android\adt-bundle-windows-x86-20130219\CoCos2Dx)
     -   click ok  -> again OK

7-> you need some more steps below

        -> right click on your project -> explore  tab C/c++ General -> select Code Analysis -> select Use Project Setting -> now uncheck Syntax and Symantic errors -> apply -> ok 

8-> Add path of cocosdension

 again go to your project -> right click -> explore  tab C/c++ General -> Path and Symbol -> selsect Include Tab -> select GNU++ -> click on Add button 
        -> fill dialog box  paste path of cocos2dx/cocosdension / include   (mine was F:\myworkspace\Android\adt-bundle-windows-x86-20130219\CoCos2Dx\CocosDenshion\include)        
        - press ok -> apply -> ok 

9->Now go to Project Tab of adt -> clean your project

10-> finally you have done 



=============================================================================================================================
     NOW MAKE FEW CHANGES TO YOUR ANDROID.MK FILE
=============================================================================================================================
EXPLORE YOUR PROJECT -> JNI -> ANDROID.MK

 NOTE :  LOCAL_SRC_FILES := hellocpp/main.cpp \
                   ../../Classes/AppDelegate.cpp \
                   ../../Classes/HelloWorldScene.cpp

            BELOW THE ABOVE LINES YOU HAVE TO ADD ALL CPP FILES LIKE ABOVE WITHOUT ANY SPACES 



===============================================================================================================================
         ENABLE BOX 2D IF YOU WANT TO USE BOX2D
===============================================================================================================================
FOLLOW ALL THE ABOVE STEPS TO CREATE NEW PROJECT AND IMPORT IT IN ADT ECLIPSE ;

NOW FOLLOW SOME MORE STEPS TO ENABLE BOX2D;


1->     right click on your project -> properties -> explore resourse tab -> linked resourse -> path variables -> Now click on add (a dialog will be Open)
      - Name   :  Box2D
      - Location : enter path of your Box2d   (mine was F:\myworkspace\Android\adt-bundle-windows-x86-20130219\CoCos2Dx\external\Box2D)
     -   click ok  -> again OK   

2->   now include box2d in include  
        again go to your project -> right click -> explore  tab C/c++ General -> Path and Symbol -> selsect Include Tab -> select GNU++ -> click on Add button 
        -> fill dialog box  paste path of \CoCos2Dx\external\Box2D   (mine was F:\myworkspace\Android\adt-bundle-windows-x86-20130219\CoCos2Dx\external\Box2D)      
        - press ok -> apply -> ok 

3->         now add Box2D source 

            again go to your project -> right click -> explore  tab C/c++ General -> Path and Symbol -> select Source Location Tab -> select Link Folder -> check the chek box
        ->   paste path of \CoCos2Dx\external\Box2D   (mine was F:\myworkspace\Android\adt-bundle-windows-x86-20130219\CoCos2Dx\external\Box2D)     
        - press ok -> apply -> ok 

4-> change in application.mk file 

    EXPLORE YOUR PROJECT -> JNI -> application.mk
        replace this line (     APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCOCOS2D_DEBUG=1)
        to -- APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=0 -DCOCOS2D_DEBUG=1 -DCC_ENABLE_BOX2D_INTEGRATION=1

Note -> this will enable Box2d and disable chipmunk 
  finaly save this file     

 5->   change in android.mk file 

    EXPLORE YOUR PROJECT -> JNI -> android.mk

      after this line (LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes) with "space" 
        add path of box2d like ($(LOCAL_PATH)/../../../../external/Box2D) after the line 

Note -> this will include Box2d  
  finalLy save this file        

 6-> ok you have done with box2d .   clean your project an enjoy... best of luck



 =============================================================================================================================================
 REMEMBER   FEW THINGS 
 ============================================================================================================================================

 1-> ADD NEW CLASS IN CLASSES FOLDER
 2-> ADD ALL RESOURCE INTO RESOURSEC FOLDER
 3-> AFTER ADDING NEW RESOURE REFRESH YOUR ANDROID PROJECT THEN RUN (PERMISSION) COMMAND INTO CYGWIN
       (cygbin.bat file-> go to you project resourse directory -> run command --   chmod -R 777 *   )

答案 1 :(得分:0)

试试这些链接

  1. “如何在Android上运行cpp-tests”: http://www.cocos2d-x.org/wiki/How_to_run_cpp-tests_on_Android
  2. “最完整的Cocos2d-x教程和指南列表”: The Completest Cocos2d-x Tutorial & Guide List
  3. “适用于iOS和Android的Cocos2D-X教程:入门”: http://www.raywenderlich.com/33750/cocos2d-x-tutorial-for-ios-and-android-getting-started
  4. 简而言之,你必须

    1. 安装Java JDK库
    2. 安装适用于Android SDK和NDK的库
    3. 提取Cocos2dx对于Cocos2dx 2.2.x,您可以使用Cygwin。对于 cocos2dx 3.x,你可以使用Python和Ant
    4. 下载并解压缩Eclipse
    5. 为ADT安装Eclipse插件
    6. 在Eclipse中导入android项目
    7. 尝试构建并运行它。
    8. 你在哪一步?