Personal Project

Showing posts with label Cocos2dx. Show all posts
Showing posts with label Cocos2dx. Show all posts

Wednesday, August 3, 2016

How to Build an Android Project using Cocos2d-x 3.6 with Eclipse ?

1.Install


Download and install the following libs and SDKs.

    JDK   

        http://www.oracle.com/technetwork/java/javase/downloads/index.html

    Android SDK  

        http://developer.android.com/sdk/installing/index.html?pkg=tools

    Android NDK 10e

        http://dl.google.com/android/repository/android-ndk-r10e-darwin-x86_64.zip

    Apache Ant 

        http://ant.apache.org/bindownload.cgi


2. Configure settings using Eclipse 


Goto Eclipse --> Preference --> C/C++ --> Build --> Environment 

Edit the following settings as shown below.

ANDROID_SDK_ROOT
/Users/User/Applications/Android/sdk

ANR_ROOT
/Users/User/Desktop/cocos2d-x/apache-ant-1.9.7/bin

COCOS_CONSOLE_ROOT
/Users/User/Desktop/cocos2d-x/cocos2d-x-3.6/tools/cocos2d-console/bin

NDK_ROOT
/Users/User/Desktop/cocos2d-x/android-ndk-r10e

PATH
/usr/bin:/bin:/usr/sbin:/sbin:/Users/User/Desktop/cocos2d-x/cocos2d-x-3.6/tools/cocos2d-console/bin





Edit NDK location 





3. Import Cocos2d-x Lib


3.1 In Package Explorer, click import button --> Android --> Existing Android Code Into Workspace 

3.2 Select Cocos2d-x-3.6 --> cocos --> platform --> android --> java





4. Import Source Codes


4.1 Click import button --> Android --> Existing Android Code Into Workspace  --> select your android source codes project 

4.2  Check your project have a link to Cocos2d-x lib

Select your project --> Properties --> Android --> Library 

 



5. Run Configuration 


5.1. Goto Run --> Configurations --> Android Application  --> Tab Android

Name   :  Your Name 
Project :  Click Browse button and select the path of your Source Code

5.2. Goto Run --> Configurations --> Android Application  --> Tab Target 

Run on Android devices 
Check option - Launch on all compatible devices/AVDs

Run on Simulator 
Check option - Automatically pick compatible device : Always uses preferred AVD if set below, launches on compatible device/ AVD otherwise.

5.3. Execute Run button





Monday, February 29, 2016

Development Tool for Quick-Cocos2dx-Community Lua


I have tried many IDE tools for programming Lua. Cocos IDE v1.2 only supports Quick-cocos2d v3.3 and Sublime is nothing but an editor. I want to find an IDE that could make break point for debugging and easy to use. ZeroBraneStudio is the most easiest IDE i recommend you use.

// Download ZeroBraneStudio - https://studio.zerobrane.com/
1.Extract zip ZeroBraneStudio-1.30-38


2.Execute zbstudio.exe

3.Import source codes into zbstudio

4. Add ZeroBrane Studio [ZeroBrane]/lualibs/mobdebug/mobdebug.lua)to src/

5. Add the following line of code to  coinflip/scripts/main.lua
require("mobdebug").start()
6. At ZeroBrane Studio, select Project->Start Debugger Server
7.Set up break point
8.Open main.lua by player3
9.Debug

How to buld Quick-Cocos2dx-Community for Android and iPhone ?

Build APK for Android


1.Install


    JDK  

        http://www.oracle.com/technetwork/java/javase/downloads/index.html

    Android SDK 

        http://developer.android.com/sdk/installing/index.html?pkg=tools

    Android NDK 9d

        http://dl.google.com/android/ndk/android-ndk-r9-windows-x86_64.zip

    Apache Ant

        http://ant.apache.org/bindownload.cgi



2.Configure environment 


// Change settings for JAVA_HOME, ANT_ROOT,

//  NDK_ROOT, ANDROID_NDK_ROOT

//  ANDROID_SDK_ROOT,  ANDROID_HOME

$ vim ~/.profile

export JAVA_HOME="$(/usr/libexec/java_home)"

# Add environment variable ANT_ROOT for cocos2d-x

export ANT_ROOT=/usr/local/apache-ant/bin

        

# Add environment variable NDK_ROOT for cocos2d-x

export NDK_ROOT=/Users/Tester/Desktop/cocos2dx/android/android-ndk-r9d

export PATH=$NDK_ROOT:$PATH

export ANDROID_NDK_ROOT=/Users/Tester/Desktop/cocos2dx/android/android-ndk-r9d

export PATH=$ANDROID_NDK_ROOT:$PATH

   

# Add environment variable ANDROID_SDK_ROOT for cocos2d-x

export ANDROID_SDK_ROOT=/Users/Tester/Desktop/cocos2dx/android/android-sdk-macosx

export ANDROID_HOME=/Users/Tester/Desktop/cocos2dx/android/android-sdk-macosx

export PATH=$ANDROID_HOME:$PATH

PATH=/usr/local/bin:$PATH:~/bin:~/bin/python:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$ANT_ROOT:

# Quick cocos2dx

export QUICK_V3_ROOT=`cat ~/.QUICK_V3_ROOT`


3. Create a project named “dev” by player


// Goto Android folder of dev

cd dev/frameworks/runtime-src/proj.android

// clean files

./clean.sh

// Compile  Quick-Cocos2dx-Community Engine Lib and output libcocos2dlua.so

./ build_native.sh

// Update Android Settings

./android update project -p . -t 1

// Set up properties pointing to Quick-Cocos2d-Community folder

// Relative Path

vim project.properties

android.library.reference.1=../../../../../cocos2dx/Quick-Cocos2dx-Community/cocos/platform/android/java


4. Update Android settings in Quick-cocos2dx-Community folder


 cd cocos2dx/Quick-Cocos2dx-Community/cocos/platform/android/java

./android update project -p . -t 1

5.  Build apk and debug


// Goto Android folder of dev

cd dev/frameworks/runtime-src/proj.android

// Build

// Dev mode

ant debug 

// Release

ant release

//  Clean settings

ant clean

// Deploy Apk to Android device

apk is saved in proj.android/bin/dev-debug.apk

cd proj.android/bin/

adb install dev-debug.apk


Build IPA for iPhone


// Goto iPhone project folder

cd dev/frameworks/runtime-src/proj.ios_mac/

// Open xcode project and build ipa

cd dev/frameworks/runtime-src/proj.ios_mac/


Tuesday, February 2, 2016

Build Quick-Cocos2dx-Lua environment on Windows and Mac

I have used Corona SDK developing games for months.  Its not free and flexible to add some native features.  Quick Cocos2ds-Lua is open source and you have more freedom to add any features.
If you want to develop a 2D game and make it time to market, Quick Cocos2ds-Lua would be the best tool to boost your development speed.

Install Quick-Cocos2dx-Community_3.6 on Windows



uzip Quick-Cocos2dx-Community_3.6_release_190dccc.zip


cd C:\Cocos2d-x\Quick-Cocos2d-x\Quick-Cocos2dx-Community


execute setup_win.bat


Execute Simulator

C:\Cocos2d-x\Quick-Cocos2d-x\Quick-Cocos2dx-Community\quick\player\proj.win32/player3.exe



Install Quick-Cocos2dx-Community_3.6 on Mac

cd /Quick-Cocos2dx-Community

execute setup_mac.sh

Execute Simulator

/Applications/player3.app