mirror of https://github.com/axmolengine/axmol.git
Merge branch 'gles20' of https://github.com/cocos2d/cocos2d-x into gles20
Conflicts: cocos2dx/cocoa/CCDictionary.cpp cocos2dx/platform/win32/CCImage.cpp
This commit is contained in:
commit
394af672d8
|
@ -41,18 +41,19 @@ CCAutoreleasePool::~CCAutoreleasePool(void)
|
||||||
|
|
||||||
void CCAutoreleasePool::addObject(CCObject* pObject)
|
void CCAutoreleasePool::addObject(CCObject* pObject)
|
||||||
{
|
{
|
||||||
CCAssert(false == pObject->m_bManaged, "this object is already in autorelese pool");
|
|
||||||
|
|
||||||
m_pManagedObjectArray->addObject(pObject);
|
m_pManagedObjectArray->addObject(pObject);
|
||||||
|
|
||||||
CCAssert(pObject->m_uReference > 1, "reference count should be greater than 1");
|
CCAssert(pObject->m_uReference > 1, "reference count should be greater than 1");
|
||||||
|
++(pObject->m_uAutoReleaseCount);
|
||||||
pObject->release(); // no ref count, in this case autorelease pool added.
|
pObject->release(); // no ref count, in this case autorelease pool added.
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCAutoreleasePool::removeObject(CCObject* pObject)
|
void CCAutoreleasePool::removeObject(CCObject* pObject)
|
||||||
{
|
{
|
||||||
m_pManagedObjectArray->removeObject(pObject, false);
|
for (int i = 0; i < pObject->m_uAutoReleaseCount; ++i)
|
||||||
|
{
|
||||||
|
m_pManagedObjectArray->removeObject(pObject, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCAutoreleasePool::clear()
|
void CCAutoreleasePool::clear()
|
||||||
|
@ -70,7 +71,7 @@ void CCAutoreleasePool::clear()
|
||||||
if(!pObj)
|
if(!pObj)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
pObj->m_bManaged = false;
|
--(pObj->m_uAutoReleaseCount);
|
||||||
//(*it)->release();
|
//(*it)->release();
|
||||||
//delete (*it);
|
//delete (*it);
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
|
|
@ -91,13 +91,12 @@ CCArray* CCDictionary::allKeysForObject(CCObject* object)
|
||||||
|
|
||||||
CCObject* CCDictionary::objectForKey(const std::string& key)
|
CCObject* CCDictionary::objectForKey(const std::string& key)
|
||||||
{
|
{
|
||||||
if (m_eDictType != kCCDictStr)
|
// if dictionary wasn't initialized, return NULL directly.
|
||||||
{
|
if (m_eDictType == kCCDictUnknown) return NULL;
|
||||||
return NULL;
|
// CCDictionary only supports one kind of key, string or integer.
|
||||||
}
|
// This method uses string as key, therefore we should make sure that the key type of this CCDictionary is string.
|
||||||
|
|
||||||
CCAssert(m_eDictType == kCCDictStr, "this dictionary does not use string as key.");
|
CCAssert(m_eDictType == kCCDictStr, "this dictionary does not use string as key.");
|
||||||
|
|
||||||
CCObject* pRetObject = NULL;
|
CCObject* pRetObject = NULL;
|
||||||
CCDictElement *pElement = NULL;
|
CCDictElement *pElement = NULL;
|
||||||
HASH_FIND_STR(m_pElements, key.c_str(), pElement);
|
HASH_FIND_STR(m_pElements, key.c_str(), pElement);
|
||||||
|
@ -110,13 +109,12 @@ CCObject* CCDictionary::objectForKey(const std::string& key)
|
||||||
|
|
||||||
CCObject* CCDictionary::objectForKey(int key)
|
CCObject* CCDictionary::objectForKey(int key)
|
||||||
{
|
{
|
||||||
if (m_eDictType != kCCDictInt)
|
// if dictionary wasn't initialized, return NULL directly.
|
||||||
{
|
if (m_eDictType == kCCDictUnknown) return NULL;
|
||||||
return NULL;
|
// CCDictionary only supports one kind of key, string or integer.
|
||||||
}
|
// This method uses integer as key, therefore we should make sure that the key type of this CCDictionary is integer.
|
||||||
|
|
||||||
CCAssert(m_eDictType == kCCDictInt, "this dictionary does not use integer as key.");
|
CCAssert(m_eDictType == kCCDictInt, "this dictionary does not use integer as key.");
|
||||||
|
|
||||||
CCObject* pRetObject = NULL;
|
CCObject* pRetObject = NULL;
|
||||||
CCDictElement *pElement = NULL;
|
CCDictElement *pElement = NULL;
|
||||||
HASH_FIND_INT(m_pElements, &key, pElement);
|
HASH_FIND_INT(m_pElements, &key, pElement);
|
||||||
|
|
|
@ -38,7 +38,7 @@ CCObject* CCCopying::copyWithZone(CCZone *pZone)
|
||||||
}
|
}
|
||||||
|
|
||||||
CCObject::CCObject(void)
|
CCObject::CCObject(void)
|
||||||
:m_bManaged(false)
|
:m_uAutoReleaseCount(0)
|
||||||
,m_uReference(1) // when the object is created, the reference count of it is 1
|
,m_uReference(1) // when the object is created, the reference count of it is 1
|
||||||
,m_nLuaID(0)
|
,m_nLuaID(0)
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,7 @@ CCObject::~CCObject(void)
|
||||||
{
|
{
|
||||||
// if the object is managed, we should remove it
|
// if the object is managed, we should remove it
|
||||||
// from pool manager
|
// from pool manager
|
||||||
if (m_bManaged)
|
if (m_uAutoReleaseCount > 0)
|
||||||
{
|
{
|
||||||
CCPoolManager::sharedPoolManager()->removeObject(this);
|
CCPoolManager::sharedPoolManager()->removeObject(this);
|
||||||
}
|
}
|
||||||
|
@ -97,8 +97,6 @@ void CCObject::retain(void)
|
||||||
CCObject* CCObject::autorelease(void)
|
CCObject* CCObject::autorelease(void)
|
||||||
{
|
{
|
||||||
CCPoolManager::sharedPoolManager()->addObject(this);
|
CCPoolManager::sharedPoolManager()->addObject(this);
|
||||||
|
|
||||||
m_bManaged = true;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,8 +55,8 @@ public:
|
||||||
protected:
|
protected:
|
||||||
// count of references
|
// count of references
|
||||||
unsigned int m_uReference;
|
unsigned int m_uReference;
|
||||||
// is the object autoreleased
|
// count of autorelease
|
||||||
bool m_bManaged;
|
unsigned int m_uAutoReleaseCount;
|
||||||
public:
|
public:
|
||||||
CCObject(void);
|
CCObject(void);
|
||||||
virtual ~CCObject(void);
|
virtual ~CCObject(void);
|
||||||
|
|
|
@ -26,7 +26,6 @@ package org.cocos2dx.lib;
|
||||||
import org.cocos2dx.lib.Cocos2dxHelper.Cocos2dxHelperListener;
|
import org.cocos2dx.lib.Cocos2dxHelper.Cocos2dxHelperListener;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -43,7 +42,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
||||||
// Fields
|
// Fields
|
||||||
// ===========================================================
|
// ===========================================================
|
||||||
|
|
||||||
private Cocos2dxGLSurfaceView mGLSurefaceView;
|
private Cocos2dxGLSurfaceView mGLSurfaceView;
|
||||||
private Cocos2dxHandler mHandler;
|
private Cocos2dxHandler mHandler;
|
||||||
|
|
||||||
// ===========================================================
|
// ===========================================================
|
||||||
|
@ -54,7 +53,9 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
||||||
protected void onCreate(final Bundle savedInstanceState) {
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
this.init();
|
this.mHandler = new Cocos2dxHandler(this);
|
||||||
|
|
||||||
|
this.mGLSurfaceView = onCreateView();
|
||||||
|
|
||||||
Cocos2dxHelper.init(this, this);
|
Cocos2dxHelper.init(this, this);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +73,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
Cocos2dxHelper.onResume();
|
Cocos2dxHelper.onResume();
|
||||||
this.mGLSurefaceView.onResume();
|
this.mGLSurfaceView.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -80,7 +81,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
Cocos2dxHelper.onPause();
|
Cocos2dxHelper.onPause();
|
||||||
this.mGLSurefaceView.onPause();
|
this.mGLSurfaceView.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,16 +102,15 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runOnGLThread(final Runnable pRunnable) {
|
public void runOnGLThread(final Runnable pRunnable) {
|
||||||
this.mGLSurefaceView.queueEvent(pRunnable);
|
this.mGLSurfaceView.queueEvent(pRunnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================
|
// ===========================================================
|
||||||
// Methods
|
// Methods
|
||||||
// ===========================================================
|
// ===========================================================
|
||||||
|
|
||||||
public void init() {
|
public Cocos2dxGLSurfaceView onCreateView() {
|
||||||
// Init handler
|
// Init handler
|
||||||
this.mHandler = new Cocos2dxHandler(this);
|
|
||||||
|
|
||||||
// FrameLayout
|
// FrameLayout
|
||||||
ViewGroup.LayoutParams framelayout_params =
|
ViewGroup.LayoutParams framelayout_params =
|
||||||
|
@ -130,20 +130,18 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
||||||
framelayout.addView(edittext);
|
framelayout.addView(edittext);
|
||||||
|
|
||||||
// Cocos2dxGLSurfaceView
|
// Cocos2dxGLSurfaceView
|
||||||
this.mGLSurefaceView = this.onCreateGLSurfaceView();
|
Cocos2dxGLSurfaceView gLSurfaceView = new Cocos2dxGLSurfaceView(this);
|
||||||
|
|
||||||
// ...add to FrameLayout
|
// ...add to FrameLayout
|
||||||
framelayout.addView(mGLSurefaceView);
|
framelayout.addView(gLSurfaceView);
|
||||||
|
|
||||||
mGLSurefaceView.setCocos2dxRenderer(new Cocos2dxRenderer());
|
gLSurfaceView.setCocos2dxRenderer(new Cocos2dxRenderer());
|
||||||
mGLSurefaceView.setCocos2dxEditText(edittext);
|
gLSurfaceView.setCocos2dxEditText(edittext);
|
||||||
|
|
||||||
// Set framelayout as the content view
|
// Set framelayout as the content view
|
||||||
setContentView(framelayout);
|
setContentView(framelayout);
|
||||||
}
|
|
||||||
|
return gLSurfaceView;
|
||||||
public Cocos2dxGLSurfaceView onCreateGLSurfaceView() {
|
|
||||||
return new Cocos2dxGLSurfaceView(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================
|
// ===========================================================
|
||||||
|
|
|
@ -126,8 +126,8 @@ public:
|
||||||
}
|
}
|
||||||
GetObjectA(m_hFont, sizeof(tOldFont), &tOldFont);
|
GetObjectA(m_hFont, sizeof(tOldFont), &tOldFont);
|
||||||
|
|
||||||
if (tOldFont.lfHeight == tNewFont.lfHeight &&
|
if (tOldFont.lfHeight == tNewFont.lfHeight
|
||||||
!strcmp(tOldFont.lfFaceName, tNewFont.lfFaceName))
|
&& 0 == strcmp(tOldFont.lfFaceName, tNewFont.lfFaceName))
|
||||||
{
|
{
|
||||||
// already has the font
|
// already has the font
|
||||||
bRet = true;
|
bRet = true;
|
||||||
|
|
|
@ -493,10 +493,10 @@ void CCScrollView::addChild(CCNode * child)
|
||||||
*/
|
*/
|
||||||
void CCScrollView::beforeDraw()
|
void CCScrollView::beforeDraw()
|
||||||
{
|
{
|
||||||
if (m_bClippingToBounds)
|
if (m_bClippingToBounds)
|
||||||
{
|
{
|
||||||
// TODO: This scrollview should respect parents' positions
|
// TODO: This scrollview should respect parents' positions
|
||||||
CCPoint screenPos = this->convertToWorldSpace(this->getParent()->getPosition());
|
CCPoint screenPos = this->getParent()->convertToWorldSpace(this->getPosition());
|
||||||
|
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
float s = this->getScale();
|
float s = this->getScale();
|
||||||
|
@ -531,8 +531,6 @@ void CCScrollView::visit()
|
||||||
|
|
||||||
kmGLPushMatrix();
|
kmGLPushMatrix();
|
||||||
|
|
||||||
// glPushMatrix();
|
|
||||||
|
|
||||||
if (m_pGrid && m_pGrid->isActive())
|
if (m_pGrid && m_pGrid->isActive())
|
||||||
{
|
{
|
||||||
m_pGrid->beforeDraw();
|
m_pGrid->beforeDraw();
|
||||||
|
@ -584,8 +582,6 @@ void CCScrollView::visit()
|
||||||
}
|
}
|
||||||
|
|
||||||
kmGLPopMatrix();
|
kmGLPopMatrix();
|
||||||
|
|
||||||
// glPopMatrix();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCScrollView::ccTouchBegan(CCTouch* touch, CCEvent* event)
|
bool CCScrollView::ccTouchBegan(CCTouch* touch, CCEvent* event)
|
||||||
|
@ -595,7 +591,8 @@ bool CCScrollView::ccTouchBegan(CCTouch* touch, CCEvent* event)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CCRect frame;
|
CCRect frame;
|
||||||
frame = CCRectMake(this->getPosition().x, this->getPosition().y, m_tViewSize.width, m_tViewSize.height);
|
CCPoint frameOriginal = this->getParent()->convertToWorldSpace(this->getPosition());
|
||||||
|
frame = CCRectMake(frameOriginal.x, frameOriginal.y, m_tViewSize.width, m_tViewSize.height);
|
||||||
|
|
||||||
//dispatcher does not know about clipping. reject touches outside visible bounds.
|
//dispatcher does not know about clipping. reject touches outside visible bounds.
|
||||||
if (m_pTouches->count() > 2 ||
|
if (m_pTouches->count() > 2 ||
|
||||||
|
@ -645,7 +642,9 @@ void CCScrollView::ccTouchMoved(CCTouch* touch, CCEvent* event)
|
||||||
float newX, newY;
|
float newX, newY;
|
||||||
|
|
||||||
m_bTouchMoved = true;
|
m_bTouchMoved = true;
|
||||||
frame = CCRectMake(this->getPosition().x, this->getPosition().y, m_tViewSize.width, m_tViewSize.height);
|
CCPoint frameOriginal = this->getParent()->convertToWorldSpace(this->getPosition());
|
||||||
|
frame = CCRectMake(frameOriginal.x, frameOriginal.y, m_tViewSize.width, m_tViewSize.height);
|
||||||
|
|
||||||
newPoint = this->convertTouchToNodeSpace((CCTouch*)m_pTouches->objectAtIndex(0));
|
newPoint = this->convertTouchToNodeSpace((CCTouch*)m_pTouches->objectAtIndex(0));
|
||||||
moveDistance = ccpSub(newPoint, m_tTouchPoint);
|
moveDistance = ccpSub(newPoint, m_tTouchPoint);
|
||||||
m_tTouchPoint = newPoint;
|
m_tTouchPoint = newPoint;
|
||||||
|
|
|
@ -246,6 +246,25 @@ int processGetTask(CCHttpRequest *request, write_callback callback, void *stream
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* handle custom header data */
|
||||||
|
/* create curl linked list */
|
||||||
|
struct curl_slist *cHeaders=NULL;
|
||||||
|
/* get custom header data (if set) */
|
||||||
|
std::vector<std::string> headers=request->getHeaders();
|
||||||
|
if(!headers.empty())
|
||||||
|
{
|
||||||
|
for(std::vector<std::string>::iterator it=headers.begin();it!=headers.end();it++)
|
||||||
|
{
|
||||||
|
/* append custom headers one by one */
|
||||||
|
cHeaders=curl_slist_append(cHeaders,it->c_str());
|
||||||
|
}
|
||||||
|
/* set custom headers for curl */
|
||||||
|
code = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, cHeaders);
|
||||||
|
if (code != CURLE_OK) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
code = curl_easy_setopt(curl, CURLOPT_URL, request->getUrl());
|
code = curl_easy_setopt(curl, CURLOPT_URL, request->getUrl());
|
||||||
if (code != CURLE_OK)
|
if (code != CURLE_OK)
|
||||||
{
|
{
|
||||||
|
@ -276,6 +295,9 @@ int processGetTask(CCHttpRequest *request, write_callback callback, void *stream
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* free the linked list for header data */
|
||||||
|
curl_slist_free_all(cHeaders);
|
||||||
|
|
||||||
code = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, responseCode);
|
code = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, responseCode);
|
||||||
if (code != CURLE_OK || *responseCode != 200)
|
if (code != CURLE_OK || *responseCode != 200)
|
||||||
{
|
{
|
||||||
|
@ -301,6 +323,25 @@ int processPostTask(CCHttpRequest *request, write_callback callback, void *strea
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* handle custom header data */
|
||||||
|
/* create curl linked list */
|
||||||
|
struct curl_slist *cHeaders=NULL;
|
||||||
|
/* get custom header data (if set) */
|
||||||
|
std::vector<std::string> headers=request->getHeaders();
|
||||||
|
if(!headers.empty())
|
||||||
|
{
|
||||||
|
for(std::vector<std::string>::iterator it=headers.begin();it!=headers.end();it++)
|
||||||
|
{
|
||||||
|
/* append custom headers one by one */
|
||||||
|
cHeaders=curl_slist_append(cHeaders,it->c_str());
|
||||||
|
}
|
||||||
|
/* set custom headers for curl */
|
||||||
|
code = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, cHeaders);
|
||||||
|
if (code != CURLE_OK) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
code = curl_easy_setopt(curl, CURLOPT_URL, request->getUrl());
|
code = curl_easy_setopt(curl, CURLOPT_URL, request->getUrl());
|
||||||
if (code != CURLE_OK) {
|
if (code != CURLE_OK) {
|
||||||
break;
|
break;
|
||||||
|
@ -330,6 +371,9 @@ int processPostTask(CCHttpRequest *request, write_callback callback, void *strea
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* free the linked list for header data */
|
||||||
|
curl_slist_free_all(cHeaders);
|
||||||
|
|
||||||
code = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, responseCode);
|
code = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, responseCode);
|
||||||
if (code != CURLE_OK || *responseCode != 200) {
|
if (code != CURLE_OK || *responseCode != 200) {
|
||||||
code = CURLE_HTTP_RETURNED_ERROR;
|
code = CURLE_HTTP_RETURNED_ERROR;
|
||||||
|
|
|
@ -175,7 +175,20 @@ public:
|
||||||
{
|
{
|
||||||
return _pSelector;
|
return _pSelector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set any custom headers **/
|
||||||
|
inline void setHeaders(std::vector<std::string> pHeaders)
|
||||||
|
{
|
||||||
|
_headers=pHeaders;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get custom headers **/
|
||||||
|
inline std::vector<std::string> getHeaders()
|
||||||
|
{
|
||||||
|
return _headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// properties
|
// properties
|
||||||
HttpRequestType _requestType; /// kHttpRequestGet, kHttpRequestPost or other enums
|
HttpRequestType _requestType; /// kHttpRequestGet, kHttpRequestPost or other enums
|
||||||
|
@ -185,6 +198,7 @@ protected:
|
||||||
CCObject* _pTarget; /// callback target of pSelector function
|
CCObject* _pTarget; /// callback target of pSelector function
|
||||||
SEL_CallFuncND _pSelector; /// callback function, e.g. MyLayer::onHttpResponse(CCObject *sender, void *data)
|
SEL_CallFuncND _pSelector; /// callback function, e.g. MyLayer::onHttpResponse(CCObject *sender, void *data)
|
||||||
void* _pUserData; /// You can add your customed data here
|
void* _pUserData; /// You can add your customed data here
|
||||||
|
std::vector<std::string> _headers; /// custom http headers
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_CC_EXT_END
|
NS_CC_EXT_END
|
||||||
|
|
|
@ -67,10 +67,12 @@ done
|
||||||
|
|
||||||
if [[ "$buildexternalsfromsource" ]]; then
|
if [[ "$buildexternalsfromsource" ]]; then
|
||||||
echo "Building external dependencies from source"
|
echo "Building external dependencies from source"
|
||||||
|
set -x
|
||||||
"$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \
|
"$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \
|
||||||
"NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source"
|
"NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source"
|
||||||
else
|
else
|
||||||
echo "Using prebuilt externals"
|
echo "Using prebuilt externals"
|
||||||
|
set -x
|
||||||
"$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \
|
"$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \
|
||||||
"NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt"
|
"NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
APPNAME="HelloCpp"
|
||||||
|
APP_ANDROID_NAME="org.cocos2dx.hellocpp"
|
||||||
|
|
||||||
|
if [ -z "${SDK_ROOT+aaa}" ]; then
|
||||||
|
# ... if SDK_ROOT is not set, use "$HOME/bin/android-sdk"
|
||||||
|
SDK_ROOT="$HOME/bin/android-sdk"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${NDK_ROOT+aaa}" ]; then
|
||||||
|
# ... if NDK_ROOT is not set, use "$HOME/bin/android-ndk"
|
||||||
|
NDK_ROOT="$HOME/bin/android-ndk"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${COCOS2DX_ROOT+aaa}" ]; then
|
||||||
|
# ... if COCOS2DX_ROOT is not set
|
||||||
|
# ... find current working directory
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
# ... use paths relative to current directory
|
||||||
|
COCOS2DX_ROOT="$DIR/../../.."
|
||||||
|
APP_ROOT="$DIR/.."
|
||||||
|
APP_ANDROID_ROOT="$DIR"
|
||||||
|
else
|
||||||
|
APP_ROOT="$COCOS2DX_ROOT/samples/$APPNAME"
|
||||||
|
APP_ANDROID_ROOT="$COCOS2DX_ROOT/samples/$APPNAME/proj.android"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "NDK_ROOT = $NDK_ROOT"
|
||||||
|
echo "SDK_ROOT = $SDK_ROOT"
|
||||||
|
echo "COCOS2DX_ROOT = $COCOS2DX_ROOT"
|
||||||
|
echo "APP_ROOT = $APP_ROOT"
|
||||||
|
echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT"
|
||||||
|
echo "APP_ANDROID_NAME = $APP_ANDROID_NAME"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Killing and restarting ${APP_ANDROID_NAME}"
|
||||||
|
echo
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
"${SDK_ROOT}"/platform-tools/adb shell am force-stop "${APP_ANDROID_NAME}"
|
||||||
|
|
||||||
|
NDK_MODULE_PATH="${COCOS2DX_ROOT}":"${COCOS2DX_ROOT}"/cocos2dx/platform/third_party/android/prebuilt \
|
||||||
|
"${NDK_ROOT}"/ndk-gdb \
|
||||||
|
--adb="${SDK_ROOT}"/platform-tools/adb \
|
||||||
|
--verbose \
|
||||||
|
--start \
|
||||||
|
--force
|
|
@ -101,18 +101,40 @@ void HttpClientTest::onMenuGetTestClicked(cocos2d::CCObject *sender)
|
||||||
|
|
||||||
void HttpClientTest::onMenuPostTestClicked(cocos2d::CCObject *sender)
|
void HttpClientTest::onMenuPostTestClicked(cocos2d::CCObject *sender)
|
||||||
{
|
{
|
||||||
CCHttpRequest* request = new CCHttpRequest();
|
// test 1
|
||||||
request->setUrl("http://www.httpbin.org/post");
|
{
|
||||||
request->setRequestType(CCHttpRequest::kHttpPost);
|
CCHttpRequest* request = new CCHttpRequest();
|
||||||
request->setResponseCallback(this, callfuncND_selector(HttpClientTest::onHttpRequestCompleted));
|
request->setUrl("http://www.httpbin.org/post");
|
||||||
|
request->setRequestType(CCHttpRequest::kHttpPost);
|
||||||
|
request->setResponseCallback(this, callfuncND_selector(HttpClientTest::onHttpRequestCompleted));
|
||||||
|
|
||||||
|
// write the post data
|
||||||
|
const char* postData = "visitor=cocos2d&TestSuite=Extensions Test/NetworkTest";
|
||||||
|
request->setRequestData(postData, strlen(postData));
|
||||||
|
|
||||||
|
request->setTag("POST test1");
|
||||||
|
CCHttpClient::getInstance()->send(request);
|
||||||
|
request->release();
|
||||||
|
}
|
||||||
|
|
||||||
// write the post data
|
// test 2: set Content-Type
|
||||||
const char* postData = "visitor=cocos2d&TestSuite=Extensions Test/NetowrkTest";
|
{
|
||||||
request->setRequestData(postData, strlen(postData));
|
CCHttpRequest* request = new CCHttpRequest();
|
||||||
|
request->setUrl("http://www.httpbin.org/post");
|
||||||
request->setTag("POST test");
|
request->setRequestType(CCHttpRequest::kHttpPost);
|
||||||
CCHttpClient::getInstance()->send(request);
|
std::vector<std::string> headers;
|
||||||
request->release();
|
headers.push_back("Content-Type: application/json; charset=utf-8");
|
||||||
|
request->setHeaders(headers);
|
||||||
|
request->setResponseCallback(this, callfuncND_selector(HttpClientTest::onHttpRequestCompleted));
|
||||||
|
|
||||||
|
// write the post data
|
||||||
|
const char* postData = "visitor=cocos2d&TestSuite=Extensions Test/NetworkTest";
|
||||||
|
request->setRequestData(postData, strlen(postData));
|
||||||
|
|
||||||
|
request->setTag("POST test2");
|
||||||
|
CCHttpClient::getInstance()->send(request);
|
||||||
|
request->release();
|
||||||
|
}
|
||||||
|
|
||||||
// waiting
|
// waiting
|
||||||
m_labelStatusCode->setString("waiting...");
|
m_labelStatusCode->setString("waiting...");
|
||||||
|
|
|
@ -3,6 +3,7 @@ APPNAME="TestJavascript"
|
||||||
# options
|
# options
|
||||||
|
|
||||||
buildexternalsfromsource=
|
buildexternalsfromsource=
|
||||||
|
PARALLEL_BUILD_FLAG=
|
||||||
|
|
||||||
usage(){
|
usage(){
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
@ -12,15 +13,19 @@ Build C/C++ code for $APPNAME using Android NDK
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-s Build externals from source
|
-s Build externals from source
|
||||||
|
-p Run make with -j8 option to take advantage of multiple processors
|
||||||
-h this help
|
-h this help
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts "sh" OPTION; do
|
while getopts "sph" OPTION; do
|
||||||
case "$OPTION" in
|
case "$OPTION" in
|
||||||
s)
|
s)
|
||||||
buildexternalsfromsource=1
|
buildexternalsfromsource=1
|
||||||
;;
|
;;
|
||||||
|
p)
|
||||||
|
PARALLEL_BUILD_FLAG=\-j8
|
||||||
|
;;
|
||||||
h)
|
h)
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -90,6 +95,6 @@ echo
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
"$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \
|
"$NDK_ROOT"/ndk-build $PARALLEL_BUILD_FLAG -C "$APP_ANDROID_ROOT" $* \
|
||||||
"NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt" \
|
"NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt" \
|
||||||
NDK_LOG=1 V=1
|
NDK_LOG=1 V=1
|
||||||
|
|
|
@ -52,6 +52,12 @@ copy_build_native(){
|
||||||
chmod u+x $APP_DIR/proj.android/build_native.sh
|
chmod u+x $APP_DIR/proj.android/build_native.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# copy debugger script and replace templated parameters
|
||||||
|
copy_ndkgdb(){
|
||||||
|
sed "s#__projectname__#$APP_NAME#;s#__packagename__#$PACKAGE_PATH#" $COCOS2DX_ROOT/template/android/ndkgdb.sh > $APP_DIR/proj.android/ndkgdb.sh
|
||||||
|
chmod u+x $APP_DIR/proj.android/ndkgdb.sh
|
||||||
|
}
|
||||||
|
|
||||||
# copy .project and .classpath and replace project name
|
# copy .project and .classpath and replace project name
|
||||||
modify_project_classpath(){
|
modify_project_classpath(){
|
||||||
sed "s/HelloCpp/$APP_NAME/" $COCOS2DX_ROOT/template/android/.project > $APP_DIR/proj.android/.project
|
sed "s/HelloCpp/$APP_NAME/" $COCOS2DX_ROOT/template/android/.project > $APP_DIR/proj.android/.project
|
||||||
|
@ -92,6 +98,7 @@ copy_cpp_h
|
||||||
copy_resouces
|
copy_resouces
|
||||||
copy_src_and_jni
|
copy_src_and_jni
|
||||||
copy_build_native
|
copy_build_native
|
||||||
|
copy_ndkgdb
|
||||||
modify_project_classpath
|
modify_project_classpath
|
||||||
modify_androidmanifest
|
modify_androidmanifest
|
||||||
modify_applicationdemo
|
modify_applicationdemo
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
APPNAME="__projectname__"
|
||||||
|
APP_ANDROID_NAME="__packagename__"
|
||||||
|
|
||||||
|
if [ -z "${SDK_ROOT+aaa}" ]; then
|
||||||
|
# ... if SDK_ROOT is not set, use "$HOME/bin/android-sdk"
|
||||||
|
SDK_ROOT="$HOME/bin/android-sdk"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${NDK_ROOT+aaa}" ]; then
|
||||||
|
# ... if NDK_ROOT is not set, use "$HOME/bin/android-ndk"
|
||||||
|
NDK_ROOT="$HOME/bin/android-ndk"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${COCOS2DX_ROOT+aaa}" ]; then
|
||||||
|
# ... if COCOS2DX_ROOT is not set
|
||||||
|
# ... find current working directory
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
# ... use paths relative to current directory
|
||||||
|
COCOS2DX_ROOT="$DIR/../.."
|
||||||
|
APP_ROOT="$DIR/.."
|
||||||
|
APP_ANDROID_ROOT="$DIR"
|
||||||
|
else
|
||||||
|
APP_ROOT="$COCOS2DX_ROOT/$APPNAME"
|
||||||
|
APP_ANDROID_ROOT="$COCOS2DX_ROOT/$APPNAME/proj.android"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "NDK_ROOT = $NDK_ROOT"
|
||||||
|
echo "SDK_ROOT = $SDK_ROOT"
|
||||||
|
echo "COCOS2DX_ROOT = $COCOS2DX_ROOT"
|
||||||
|
echo "APP_ROOT = $APP_ROOT"
|
||||||
|
echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT"
|
||||||
|
echo "APP_ANDROID_NAME = $APP_ANDROID_NAME"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Killing and restarting ${APP_ANDROID_NAME}"
|
||||||
|
echo
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
"${SDK_ROOT}"/platform-tools/adb shell am force-stop "${APP_ANDROID_NAME}"
|
||||||
|
|
||||||
|
NDK_MODULE_PATH="${COCOS2DX_ROOT}":"${COCOS2DX_ROOT}"/cocos2dx/platform/third_party/android/prebuilt \
|
||||||
|
"${NDK_ROOT}"/ndk-gdb \
|
||||||
|
--adb="${SDK_ROOT}"/platform-tools/adb \
|
||||||
|
--verbose \
|
||||||
|
--start \
|
||||||
|
--force
|
Loading…
Reference in New Issue