2015-05-04 137 views
0

我有一個問題,希望能對你有所幫助。我得到一些Cocos2dx源代碼,我想在Play商店如何在eclipse中導入cocos2dx項目

我希望有人能告訴我如何添加Cocos2dx基於Eclipse在Windows機器上

,所以我將能夠發佈這些代碼,請您及時發佈人能告訴我一步我應該怎麼辦步驟..

感謝

+0

http://stackoverflow.com/questions/14096191/cant-link-to-cocos2dx-using-eclipse-for-android-on-osx?rq=1 –

+0

爵士的可能的複製,我有這些搜索鏈接,但沒有找到確切的解決方案。請幫助我。 – user2996533

+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 * ) 
0

嘗試以下鏈接

  1. 「如何在Android上運行的CPP-測試」: http://www.cocos2d-x.org/wiki/How_to_run_cpp-tests_on_Android
  2. 「唯一齊全的Cocos2D-X教程&指南列表」: The Completest Cocos2d-x Tutorial & Guide List
  3. 「的Cocos2D-X教程適用於iOS和Android:入門」: http://www.raywenderlich.com/33750/cocos2d-x-tutorial-for-ios-and-android-getting-started

簡單地說,你將有爲Android SDK 012

  1. 的Java JDK安裝庫
  2. 安裝庫NDK
  3. 提取Cocos2dx對於Cocos2dx 2.2.x,您可以使用Cygwin。對於 cocos2dx 3.x中,你可以使用Python和螞蟻
  4. 下載並在Eclipse
  5. 提取的Eclipse
  6. 安裝Eclipse插件ADT
  7. 導入Android項目
  8. 嘗試構建和運行它。

你在哪一步?