From 626ba2686f2b67eed27cbc4a3b9a4c79decb3943 Mon Sep 17 00:00:00 2001 From: Jaroslaw Lewandowski Date: Tue, 9 Jul 2013 21:21:43 +0100 Subject: [PATCH 01/31] Solving 'black screen' on android --- cocos2dx/platform/CCFileUtils.cpp | 3 + cocos2dx/platform/CCPlatformMacros.h | 2 +- cocos2dx/textures/CCTexture2D.cpp | 150 +++++++----------- cocos2dx/textures/CCTextureCache.cpp | 22 +-- cocos2dx/textures/CCTextureCache.h | 13 +- .../proj.android/jni/hellocpp/main.cpp | 2 - .../proj.android/jni/hellocpp/main.cpp | 2 - .../proj.android/jni/hellocpp/main.cpp | 2 - .../proj.android/jni/hellocpp/main.cpp | 2 - .../TestCpp/proj.android/jni/testcpp/main.cpp | 2 - .../proj.android/jni/cocosdragonjs/main.cpp | 2 - .../proj.android/jni/crystalcraze/main.cpp | 2 - .../proj.android/jni/moonwarriors/main.cpp | 2 - .../proj.android/jni/testjavascript/main.cpp | 2 - .../jni/watermelonwithme/main.cpp | 2 - .../proj.android/jni/hellocpp/main.cpp | 2 - 16 files changed, 66 insertions(+), 146 deletions(-) diff --git a/cocos2dx/platform/CCFileUtils.cpp b/cocos2dx/platform/CCFileUtils.cpp index 13b3646085..b08fa0721b 100644 --- a/cocos2dx/platform/CCFileUtils.cpp +++ b/cocos2dx/platform/CCFileUtils.cpp @@ -654,6 +654,7 @@ const char* FileUtils::fullPathFromRelativeFile(const char *pszFilename, const c void FileUtils::setSearchResolutionsOrder(const std::vector& searchResolutionsOrder) { bool bExistDefault = false; + _fullPathCache.clear(); _searchResolutionsOrderArray.clear(); for (std::vector::const_iterator iter = searchResolutionsOrder.begin(); iter != searchResolutionsOrder.end(); ++iter) { @@ -695,6 +696,7 @@ void FileUtils::setSearchPaths(const std::vector& searchPaths) { bool bExistDefaultRootPath = false; + _fullPathCache.clear(); _searchPathArray.clear(); for (std::vector::const_iterator iter = searchPaths.begin(); iter != searchPaths.end(); ++iter) { @@ -741,6 +743,7 @@ void FileUtils::addSearchPath(const char* path_) void FileUtils::setFilenameLookupDictionary(Dictionary* pFilenameLookupDict) { + _fullPathCache.clear(); CC_SAFE_RELEASE(_filenameLookupDict); _filenameLookupDict = pFilenameLookupDict; CC_SAFE_RETAIN(_filenameLookupDict); diff --git a/cocos2dx/platform/CCPlatformMacros.h b/cocos2dx/platform/CCPlatformMacros.h index 59ac1ba07b..d08122bda2 100644 --- a/cocos2dx/platform/CCPlatformMacros.h +++ b/cocos2dx/platform/CCPlatformMacros.h @@ -81,7 +81,7 @@ to be different from other platforms unless there's a good reason. It's new in cocos2d-x since v0.99.5 */ -#if 0 +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #define CC_ENABLE_CACHE_TEXTURE_DATA 1 #else #define CC_ENABLE_CACHE_TEXTURE_DATA 0 diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index c6e21dc772..e24d33f45e 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -442,107 +442,55 @@ bool Texture2D::initWithString(const char *text, const char *fontName, float fon bool Texture2D::initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions, TextAlignment hAlignment, VerticalTextAlignment vAlignment) { - #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + FontDefinition tempDef; - FontDefinition tempDef; - - tempDef._shadow._shadowEnabled = false; - tempDef._stroke._strokeEnabled = false; - - - tempDef._fontName = std::string(fontName); - tempDef._fontSize = fontSize; - tempDef._dimensions = dimensions; - tempDef._alignment = hAlignment; - tempDef._vertAlignment = vAlignment; - tempDef._fontFillColor = Color3B::WHITE; - - return initWithString(text, tempDef); - - - #else - - - #if CC_ENABLE_CACHE_TEXTURE_DATA - // cache the texture data - VolatileTexture::addStringTexture(this, text, dimensions, hAlignment, vAlignment, fontName, fontSize); - #endif - - bool bRet = false; - Image::ETextAlign eAlign; - - if (kVerticalTextAlignmentTop == vAlignment) - { - eAlign = (kTextAlignmentCenter == hAlignment) ? Image::kAlignTop - : (kTextAlignmentLeft == hAlignment) ? Image::kAlignTopLeft : Image::kAlignTopRight; - } - else if (kVerticalTextAlignmentCenter == vAlignment) - { - eAlign = (kTextAlignmentCenter == hAlignment) ? Image::kAlignCenter - : (kTextAlignmentLeft == hAlignment) ? Image::kAlignLeft : Image::kAlignRight; - } - else if (kVerticalTextAlignmentBottom == vAlignment) - { - eAlign = (kTextAlignmentCenter == hAlignment) ? Image::kAlignBottom - : (kTextAlignmentLeft == hAlignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight; - } - else - { - CCAssert(false, "Not supported alignment format!"); - return false; - } - - do - { - Image* pImage = new Image(); - CC_BREAK_IF(NULL == pImage); - bRet = pImage->initWithString(text, (int)dimensions.width, (int)dimensions.height, eAlign, fontName, (int)fontSize); - CC_BREAK_IF(!bRet); - bRet = initWithImage(pImage); - CC_SAFE_RELEASE(pImage); - } while (0); - - - return bRet; - - - #endif + tempDef._shadow._shadowEnabled = false; + tempDef._stroke._strokeEnabled = false; + + tempDef._fontName = std::string(fontName); + tempDef._fontSize = fontSize; + tempDef._dimensions = dimensions; + tempDef._alignment = hAlignment; + tempDef._vertAlignment = vAlignment; + tempDef._fontFillColor = Color3B::WHITE; + + return initWithString(text, tempDef); } bool Texture2D::initWithString(const char *text, const FontDefinition& textDefinition) { - #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - #if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture data - VolatileTexture::addStringTexture(this, text, textDefinition._dimensions, textDefinition._alignment, textDefinition._vertAlignment, textDefinition._fontName.c_str(), textDefinition._fontSize); + VolatileTexture::addStringTexture(this, text, textDefinition); #endif - - bool bRet = false; - Image::ETextAlign eAlign; - - if (kVerticalTextAlignmentTop == textDefinition._vertAlignment) - { - eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignTop - : (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight; - } - else if (kVerticalTextAlignmentCenter == textDefinition._vertAlignment) - { - eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignCenter - : (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight; - } - else if (kVerticalTextAlignmentBottom == textDefinition._vertAlignment) - { - eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignBottom - : (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight; - } - else - { - CCAssert(false, "Not supported alignment format!"); - return false; - } - + + bool bRet = false; + Image::ETextAlign eAlign; + + if (kVerticalTextAlignmentTop == textDefinition._vertAlignment) + { + eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignTop + : (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight; + } + else if (kVerticalTextAlignmentCenter == textDefinition._vertAlignment) + { + eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignCenter + : (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight; + } + else if (kVerticalTextAlignmentBottom == textDefinition._vertAlignment) + { + eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignBottom + : (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight; + } + else + { + CCAssert(false, "Not supported alignment format!"); + return false; + } + + #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + // handle shadow parameters bool shadowEnabled = false; float shadowDX = 0.0f; @@ -612,10 +560,22 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin #else + bool requestUnsupported = textDefinition->_shadow._shadowEnabled || textDefinition->_stroke._strokeEnabled; - CCAssert(false, "Currently only supported on iOS and Android!"); - return false; + CCAssert(requestUnsupported == false, "Currently shadow and stroke only supported on iOS and Android!"); + do + { + CCImage* pImage = new CCImage(); + CC_BREAK_IF(NULL == pImage); + bRet = pImage->initWithString(text, (int)textDefinition->_dimensions.width, (int)textDefinition->_dimensions.height, eAlign, textDefinition->_fontName.c_str(), (int)textDefinition->_fontSize); + CC_BREAK_IF(!bRet); + bRet = initWithImage(pImage); + CC_SAFE_RELEASE(pImage); + } while (0); + + + return bRet; #endif } @@ -624,7 +584,7 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin void Texture2D::drawAtPoint(const Point& point) { - GLfloat coordinates[] = { + GLfloat coordinates[] = { 0.0f, _maxT, _maxS,_maxT, 0.0f, 0.0f, diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 8aee499d15..688faaf630 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -646,14 +646,9 @@ VolatileTexture::VolatileTexture(Texture2D *t) , _pixelFormat(kTexture2DPixelFormat_RGBA8888) , _fileName("") , _fmtImage(Image::kFmtPng) -, _alignment(kTextAlignmentCenter) -, _vAlignment(kVerticalTextAlignmentCenter) -, _fontName("") , _text("") , uiImage(NULL) -, _fontSize(0.0f) { - _size = CCSizeMake(0, 0); _texParams.minFilter = GL_LINEAR; _texParams.magFilter = GL_LINEAR; _texParams.wrapS = GL_CLAMP_TO_EDGE; @@ -727,8 +722,7 @@ void VolatileTexture::addDataTexture(Texture2D *tt, void* data, Texture2DPixelFo vt->_textureSize = contentSize; } -void VolatileTexture::addStringTexture(Texture2D *tt, const char* text, const Size& dimensions, TextAlignment alignment, - VerticalTextAlignment vAlignment, const char *fontName, float fontSize) +void VolatileTexture::addStringTexture(Texture2D *tt, const char* text, const FontDefinition& fontDefinition) { if (isReloading) { @@ -738,12 +732,8 @@ void VolatileTexture::addStringTexture(Texture2D *tt, const char* text, const Si VolatileTexture *vt = findVolotileTexture(tt); vt->_cashedImageType = kString; - vt->_size = dimensions; - vt->_fontName = fontName; - vt->_alignment = alignment; - vt->_vAlignment = vAlignment; - vt->_fontSize = fontSize; vt->_text = text; + vt->_fontDefinition = fontDefinition; } void VolatileTexture::setTexParameters(Texture2D *t, const ccTexParams &texParams) @@ -834,13 +824,7 @@ void VolatileTexture::reloadAllTextures() break; case kString: { - vt->texture->initWithString(vt->_text.c_str(), - vt->_fontName.c_str(), - vt->_fontSize, - vt->_size, - vt->_alignment, - vt->_vAlignment - ); + vt->texture->initWithString(vt->_text.c_str(), vt->_fontDefinition); } break; case kImage: diff --git a/cocos2dx/textures/CCTextureCache.h b/cocos2dx/textures/CCTextureCache.h index 5a95a5520a..6f8068fd61 100644 --- a/cocos2dx/textures/CCTextureCache.h +++ b/cocos2dx/textures/CCTextureCache.h @@ -213,8 +213,7 @@ public: ~VolatileTexture(); static void addImageTexture(Texture2D *tt, const char* imageFileName, Image::EImageFormat format); - static void addStringTexture(Texture2D *tt, const char* text, const Size& dimensions, TextAlignment alignment, - VerticalTextAlignment vAlignment, const char *fontName, float fontSize); + static void addStringTexture(Texture2D *tt, const char* text, const FontDefinition& fontDefinition); static void addDataTexture(Texture2D *tt, void* data, Texture2DPixelFormat pixelFormat, const Size& contentSize); static void addImage(Texture2D *tt, Image *image); @@ -245,13 +244,9 @@ protected: std::string _fileName; Image::EImageFormat _fmtImage; - ccTexParams _texParams; - Size _size; - TextAlignment _alignment; - VerticalTextAlignment _vAlignment; - std::string _fontName; - std::string _text; - float _fontSize; + ccTexParams _texParams; + std::string _text; + FontDefinition _fontDefinition; }; #endif diff --git a/plugin/samples/HelloPlugins/proj.android/jni/hellocpp/main.cpp b/plugin/samples/HelloPlugins/proj.android/jni/hellocpp/main.cpp index 62149196e9..801f23c234 100644 --- a/plugin/samples/HelloPlugins/proj.android/jni/hellocpp/main.cpp +++ b/plugin/samples/HelloPlugins/proj.android/jni/hellocpp/main.cpp @@ -31,7 +31,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi AppDelegate *pAppDelegate = new AppDelegate(); Application::sharedApplication()->run(); } - /* else { ccDrawInit(); @@ -42,7 +41,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::sharedDirector()->setGLDefaultValues(); } - */ } } diff --git a/samples/Cpp/AssetsManagerTest/proj.android/jni/hellocpp/main.cpp b/samples/Cpp/AssetsManagerTest/proj.android/jni/hellocpp/main.cpp index 9df6544ccc..c48f9af11f 100644 --- a/samples/Cpp/AssetsManagerTest/proj.android/jni/hellocpp/main.cpp +++ b/samples/Cpp/AssetsManagerTest/proj.android/jni/hellocpp/main.cpp @@ -28,7 +28,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi AppDelegate *pAppDelegate = new AppDelegate(); Application::sharedApplication()->run(); } - /* else { ccDrawInit(); @@ -39,7 +38,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::sharedDirector()->setGLDefaultValues(); } - */ } } diff --git a/samples/Cpp/HelloCpp/proj.android/jni/hellocpp/main.cpp b/samples/Cpp/HelloCpp/proj.android/jni/hellocpp/main.cpp index 2521065482..55e7874cc8 100644 --- a/samples/Cpp/HelloCpp/proj.android/jni/hellocpp/main.cpp +++ b/samples/Cpp/HelloCpp/proj.android/jni/hellocpp/main.cpp @@ -30,7 +30,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi AppDelegate *pAppDelegate = new AppDelegate(); Application::sharedApplication()->run(); } - /* else { ccDrawInit(); @@ -41,7 +40,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::sharedDirector()->setGLDefaultValues(); } - */ } } diff --git a/samples/Cpp/SimpleGame/proj.android/jni/hellocpp/main.cpp b/samples/Cpp/SimpleGame/proj.android/jni/hellocpp/main.cpp index 0663ce4913..421ed0e412 100644 --- a/samples/Cpp/SimpleGame/proj.android/jni/hellocpp/main.cpp +++ b/samples/Cpp/SimpleGame/proj.android/jni/hellocpp/main.cpp @@ -30,7 +30,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi AppDelegate *pAppDelegate = new AppDelegate(); Application::sharedApplication()->run(); } - /* else { ccDrawInit(); @@ -41,7 +40,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::sharedDirector()->setGLDefaultValues(); } - */ } } diff --git a/samples/Cpp/TestCpp/proj.android/jni/testcpp/main.cpp b/samples/Cpp/TestCpp/proj.android/jni/testcpp/main.cpp index 33457710cd..6895986ba0 100644 --- a/samples/Cpp/TestCpp/proj.android/jni/testcpp/main.cpp +++ b/samples/Cpp/TestCpp/proj.android/jni/testcpp/main.cpp @@ -30,7 +30,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi AppDelegate *pAppDelegate = new AppDelegate(); Application::sharedApplication()->run(); } - /* else { ccDrawInit(); @@ -41,7 +40,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::sharedDirector()->setGLDefaultValues(); } - */ } } diff --git a/samples/Javascript/CocosDragonJS/proj.android/jni/cocosdragonjs/main.cpp b/samples/Javascript/CocosDragonJS/proj.android/jni/cocosdragonjs/main.cpp index 9ec70a81e0..a204013e7a 100644 --- a/samples/Javascript/CocosDragonJS/proj.android/jni/cocosdragonjs/main.cpp +++ b/samples/Javascript/CocosDragonJS/proj.android/jni/cocosdragonjs/main.cpp @@ -30,7 +30,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi AppDelegate *pAppDelegate = new AppDelegate(); Application::sharedApplication()->run(); } - /* else { ccDrawInit(); @@ -41,7 +40,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::sharedDirector()->setGLDefaultValues(); } - */ } } diff --git a/samples/Javascript/CrystalCraze/proj.android/jni/crystalcraze/main.cpp b/samples/Javascript/CrystalCraze/proj.android/jni/crystalcraze/main.cpp index 9ec70a81e0..a204013e7a 100644 --- a/samples/Javascript/CrystalCraze/proj.android/jni/crystalcraze/main.cpp +++ b/samples/Javascript/CrystalCraze/proj.android/jni/crystalcraze/main.cpp @@ -30,7 +30,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi AppDelegate *pAppDelegate = new AppDelegate(); Application::sharedApplication()->run(); } - /* else { ccDrawInit(); @@ -41,7 +40,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::sharedDirector()->setGLDefaultValues(); } - */ } } diff --git a/samples/Javascript/MoonWarriors/proj.android/jni/moonwarriors/main.cpp b/samples/Javascript/MoonWarriors/proj.android/jni/moonwarriors/main.cpp index 9ec70a81e0..a204013e7a 100644 --- a/samples/Javascript/MoonWarriors/proj.android/jni/moonwarriors/main.cpp +++ b/samples/Javascript/MoonWarriors/proj.android/jni/moonwarriors/main.cpp @@ -30,7 +30,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi AppDelegate *pAppDelegate = new AppDelegate(); Application::sharedApplication()->run(); } - /* else { ccDrawInit(); @@ -41,7 +40,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::sharedDirector()->setGLDefaultValues(); } - */ } } diff --git a/samples/Javascript/TestJavascript/proj.android/jni/testjavascript/main.cpp b/samples/Javascript/TestJavascript/proj.android/jni/testjavascript/main.cpp index 9ec70a81e0..a204013e7a 100644 --- a/samples/Javascript/TestJavascript/proj.android/jni/testjavascript/main.cpp +++ b/samples/Javascript/TestJavascript/proj.android/jni/testjavascript/main.cpp @@ -30,7 +30,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi AppDelegate *pAppDelegate = new AppDelegate(); Application::sharedApplication()->run(); } - /* else { ccDrawInit(); @@ -41,7 +40,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::sharedDirector()->setGLDefaultValues(); } - */ } } diff --git a/samples/Javascript/WatermelonWithMe/proj.android/jni/watermelonwithme/main.cpp b/samples/Javascript/WatermelonWithMe/proj.android/jni/watermelonwithme/main.cpp index 9ec70a81e0..a204013e7a 100644 --- a/samples/Javascript/WatermelonWithMe/proj.android/jni/watermelonwithme/main.cpp +++ b/samples/Javascript/WatermelonWithMe/proj.android/jni/watermelonwithme/main.cpp @@ -30,7 +30,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi AppDelegate *pAppDelegate = new AppDelegate(); Application::sharedApplication()->run(); } - /* else { ccDrawInit(); @@ -41,7 +40,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::sharedDirector()->setGLDefaultValues(); } - */ } } diff --git a/template/multi-platform-cpp/proj.android/jni/hellocpp/main.cpp b/template/multi-platform-cpp/proj.android/jni/hellocpp/main.cpp index e92f90d583..6895986ba0 100644 --- a/template/multi-platform-cpp/proj.android/jni/hellocpp/main.cpp +++ b/template/multi-platform-cpp/proj.android/jni/hellocpp/main.cpp @@ -30,7 +30,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi AppDelegate *pAppDelegate = new AppDelegate(); Application::sharedApplication()->run(); } - /* else { ccDrawInit(); @@ -41,7 +40,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::sharedDirector()->setGLDefaultValues(); } - */ } } From 1fcd6883f1befcee41b877017f1d1e32396c82c7 Mon Sep 17 00:00:00 2001 From: Jaroslaw Lewandowski Date: Tue, 9 Jul 2013 23:32:10 +0100 Subject: [PATCH 02/31] fixing Linux build --- cocos2dx/textures/CCTexture2D.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index e24d33f45e..20475d56cf 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -560,15 +560,15 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin #else - bool requestUnsupported = textDefinition->_shadow._shadowEnabled || textDefinition->_stroke._strokeEnabled; + bool requestUnsupported = textDefinition._shadow._shadowEnabled || textDefinition._stroke._strokeEnabled; CCAssert(requestUnsupported == false, "Currently shadow and stroke only supported on iOS and Android!"); do { - CCImage* pImage = new CCImage(); + Image* pImage = new Image(); CC_BREAK_IF(NULL == pImage); - bRet = pImage->initWithString(text, (int)textDefinition->_dimensions.width, (int)textDefinition->_dimensions.height, eAlign, textDefinition->_fontName.c_str(), (int)textDefinition->_fontSize); + bRet = pImage->initWithString(text, (int)textDefinition._dimensions.width, (int)textDefinition._dimensions.height, eAlign, textDefinition._fontName.c_str(), (int)textDefinition._fontSize); CC_BREAK_IF(!bRet); bRet = initWithImage(pImage); CC_SAFE_RELEASE(pImage); From 5b06824036003fd4ff4e16215a9947d102412bfe Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 16 Jul 2013 16:47:35 +0800 Subject: [PATCH 03/31] closed #2410: Formatting codes in Texture2D::initWithString. --- cocos2dx/textures/CCTexture2D.cpp | 171 +++++++++++++++--------------- 1 file changed, 85 insertions(+), 86 deletions(-) diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index da5c299ed4..fb36a4cd7e 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -460,10 +460,10 @@ bool Texture2D::initWithString(const char *text, const char *fontName, float fon bool Texture2D::initWithString(const char *text, const FontDefinition& textDefinition) { - #if CC_ENABLE_CACHE_TEXTURE_DATA - // cache the texture data - VolatileTexture::addStringTexture(this, text, textDefinition); - #endif +#if CC_ENABLE_CACHE_TEXTURE_DATA + // cache the texture data + VolatileTexture::addStringTexture(this, text, textDefinition); +#endif bool bRet = false; Image::ETextAlign eAlign; @@ -489,94 +489,93 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin return false; } - #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + + // handle shadow parameters + bool shadowEnabled = false; + float shadowDX = 0.0f; + float shadowDY = 0.0f; + float shadowBlur = 0.0f; + float shadowOpacity = 0.0f; - // handle shadow parameters - bool shadowEnabled = false; - float shadowDX = 0.0f; - float shadowDY = 0.0f; - float shadowBlur = 0.0f; - float shadowOpacity = 0.0f; - - if ( textDefinition._shadow._shadowEnabled ) - { - shadowEnabled = true; - shadowDX = textDefinition._shadow._shadowOffset.width; - shadowDY = textDefinition._shadow._shadowOffset.height; - shadowBlur = textDefinition._shadow._shadowBlur; - shadowOpacity = textDefinition._shadow._shadowOpacity; - } - - // handle stroke parameters - bool strokeEnabled = false; - float strokeColorR = 0.0f; - float strokeColorG = 0.0f; - float strokeColorB = 0.0f; - float strokeSize = 0.0f; - - if ( textDefinition._stroke._strokeEnabled ) - { - strokeEnabled = true; - strokeColorR = textDefinition._stroke._strokeColor.r / 255.0f; - strokeColorG = textDefinition._stroke._strokeColor.g / 255.0f; - strokeColorB = textDefinition._stroke._strokeColor.b / 255.0f; - strokeSize = textDefinition._stroke._strokeSize; - } - - Image* pImage = new Image(); - do - { - CC_BREAK_IF(NULL == pImage); - - bRet = pImage->initWithStringShadowStroke(text, - (int)textDefinition._dimensions.width, - (int)textDefinition._dimensions.height, - eAlign, - textDefinition._fontName.c_str(), - textDefinition._fontSize, - textDefinition._fontFillColor.r / 255.0f, - textDefinition._fontFillColor.g / 255.0f, - textDefinition._fontFillColor.b / 255.0f, - shadowEnabled, - shadowDX, - shadowDY, - shadowOpacity, - shadowBlur, - strokeEnabled, - strokeColorR, - strokeColorG, - strokeColorB, - strokeSize); - - - CC_BREAK_IF(!bRet); - bRet = initWithImage(pImage); - - } while (0); - - CC_SAFE_RELEASE(pImage); - - return bRet; + if ( textDefinition._shadow._shadowEnabled ) + { + shadowEnabled = true; + shadowDX = textDefinition._shadow._shadowOffset.width; + shadowDY = textDefinition._shadow._shadowOffset.height; + shadowBlur = textDefinition._shadow._shadowBlur; + shadowOpacity = textDefinition._shadow._shadowOpacity; + } + // handle stroke parameters + bool strokeEnabled = false; + float strokeColorR = 0.0f; + float strokeColorG = 0.0f; + float strokeColorB = 0.0f; + float strokeSize = 0.0f; - #else - bool requestUnsupported = textDefinition._shadow._shadowEnabled || textDefinition._stroke._strokeEnabled; + if ( textDefinition._stroke._strokeEnabled ) + { + strokeEnabled = true; + strokeColorR = textDefinition._stroke._strokeColor.r / 255.0f; + strokeColorG = textDefinition._stroke._strokeColor.g / 255.0f; + strokeColorB = textDefinition._stroke._strokeColor.b / 255.0f; + strokeSize = textDefinition._stroke._strokeSize; + } - CCAssert(requestUnsupported == false, "Currently shadow and stroke only supported on iOS and Android!"); - - do - { - Image* pImage = new Image(); - CC_BREAK_IF(NULL == pImage); - bRet = pImage->initWithString(text, (int)textDefinition._dimensions.width, (int)textDefinition._dimensions.height, eAlign, textDefinition._fontName.c_str(), (int)textDefinition._fontSize); - CC_BREAK_IF(!bRet); - bRet = initWithImage(pImage); - CC_SAFE_RELEASE(pImage); - } while (0); + Image* pImage = new Image(); + do + { + CC_BREAK_IF(NULL == pImage); + bRet = pImage->initWithStringShadowStroke(text, + (int)textDefinition._dimensions.width, + (int)textDefinition._dimensions.height, + eAlign, + textDefinition._fontName.c_str(), + textDefinition._fontSize, + textDefinition._fontFillColor.r / 255.0f, + textDefinition._fontFillColor.g / 255.0f, + textDefinition._fontFillColor.b / 255.0f, + shadowEnabled, + shadowDX, + shadowDY, + shadowOpacity, + shadowBlur, + strokeEnabled, + strokeColorR, + strokeColorG, + strokeColorB, + strokeSize); + + + CC_BREAK_IF(!bRet); + bRet = initWithImage(pImage); + + } while (0); - return bRet; - #endif + CC_SAFE_RELEASE(pImage); + + return bRet; + +#else + bool requestUnsupported = textDefinition._shadow._shadowEnabled || textDefinition._stroke._strokeEnabled; + + CCAssert(requestUnsupported == false, "Currently shadow and stroke only supported on iOS and Android!"); + + Image* pImage = new Image(); + do + { + CC_BREAK_IF(NULL == pImage); + bRet = pImage->initWithString(text, (int)textDefinition._dimensions.width, (int)textDefinition._dimensions.height, eAlign, textDefinition._fontName.c_str(), (int)textDefinition._fontSize); + CC_BREAK_IF(!bRet); + bRet = initWithImage(pImage); + } while (0); + + CC_SAFE_RELEASE(pImage); + + return bRet; +#endif } From 96c15efb665b81b4743eeb72b8fd65e39ec3a8f3 Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Fri, 12 Jul 2013 22:30:08 -0400 Subject: [PATCH 04/31] Add JSFunctionWrapper in preparation for bindings-generator changes. --- scripting/javascript/bindings/ScriptingCore.h | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/scripting/javascript/bindings/ScriptingCore.h b/scripting/javascript/bindings/ScriptingCore.h index 165562d590..115dfb72d7 100644 --- a/scripting/javascript/bindings/ScriptingCore.h +++ b/scripting/javascript/bindings/ScriptingCore.h @@ -310,6 +310,34 @@ private: JSStringWrapper &operator=(const JSStringWrapper &another); }; +// wraps a function and "this" object +class JSFunctionWrapper +{ + JSContext *_cx; + JSObject *_jsthis; + jsval _fval; +public: + JSFunctionWrapper(JSContext* cx, JSObject *jsthis, jsval fval) + : _cx(cx) + , _jsthis(jsthis) + , _fval(fval) + { + JS_AddNamedValueRoot(cx, &this->_fval, "JSFunctionWrapper"); + JS_AddNamedObjectRoot(cx, &this->_jsthis, "JSFunctionWrapper"); + } + ~JSFunctionWrapper() { + JS_RemoveValueRoot(this->_cx, &this->_fval); + JS_RemoveObjectRoot(this->_cx, &this->_jsthis); + } + JSBool invoke(unsigned int argc, jsval *argv, jsval &rval) { + return JS_CallFunctionValue(this->_cx, this->_jsthis, this->_fval, argc, argv, &rval); + } +private: + /* Copy and assignment are not supported. */ + JSFunctionWrapper(const JSFunctionWrapper &another); + JSFunctionWrapper &operator=(const JSFunctionWrapper &another); +}; + JSBool jsb_set_reserved_slot(JSObject *obj, uint32_t idx, jsval value); JSBool jsb_get_reserved_slot(JSObject *obj, uint32_t idx, jsval& ret); From 5d499d351d328d53fdb2d37c93c4587310f53340 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 16 Jul 2013 18:16:04 -0700 Subject: [PATCH 05/31] Some more changes to make the code more c++ friendly: - nodeToParentTransform -> getNodeToParentTransform() (the same for its friends) - Deprecates the old methods - adds 'consts' to those methods - boundingBox() -> getBoundingBox() - the new one is const - Deprecates the old method. - Adds overrides keywords in CCNodeRGBA and CCArmature - AffineMatrix are mutables --- cocos2dx/base_nodes/CCNode.cpp | 78 +++++++---- cocos2dx/base_nodes/CCNode.h | 132 ++++++++++-------- cocos2dx/sprite_nodes/CCSprite.cpp | 4 +- extensions/CCArmature/CCArmature.cpp | 6 +- extensions/CCArmature/CCArmature.h | 23 ++- .../CCArmature/display/CCDisplayManager.cpp | 2 +- extensions/CCArmature/display/CCSkin.cpp | 2 +- .../GUI/CCControlExtension/CCControl.cpp | 2 +- .../CCControlExtension/CCControlButton.cpp | 6 +- .../CCControlExtension/CCControlHuePicker.cpp | 6 +- .../CCControlSaturationBrightnessPicker.cpp | 12 +- .../CCControlExtension/CCControlSlider.cpp | 4 +- .../CCControlExtension/CCControlStepper.cpp | 2 +- extensions/GUI/CCScrollView/CCScrollView.cpp | 2 +- extensions/GUI/CCScrollView/CCTableView.cpp | 2 +- extensions/physics_nodes/CCPhysicsSprite.cpp | 4 +- extensions/physics_nodes/CCPhysicsSprite.h | 19 +-- .../Cpp/TestCpp/Classes/Box2DTest/Box2dTest.h | 2 +- .../ArmatureTest/ArmatureScene.cpp | 2 +- .../TestCpp/Classes/LabelTest/LabelTest.cpp | 2 +- .../TextureAtlasEncryptionTest.cpp | 4 +- 21 files changed, 180 insertions(+), 136 deletions(-) diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 2d2d776f74..da9f4aac03 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -102,7 +102,7 @@ Node::Node(void) _componentContainer = new ComponentContainer(this); } -Node::~Node(void) +Node::~Node() { CCLOGINFO( "cocos2d: deallocing: %p", this ); @@ -305,12 +305,12 @@ void Node::setPosition(float x, float y) setPosition(Point(x, y)); } -float Node::getPositionX(void) const +float Node::getPositionX() const { return _position.x; } -float Node::getPositionY(void) const +float Node::getPositionY() const { return _position.y; } @@ -331,7 +331,7 @@ Array* Node::getChildren() return _children; } -unsigned int Node::getChildrenCount(void) const +unsigned int Node::getChildrenCount() const { return _children ? _children->count() : 0; } @@ -513,12 +513,18 @@ void Node::setShaderProgram(GLProgram *pShaderProgram) _shaderProgram = pShaderProgram; } -Rect Node::boundingBox() +Rect Node::getBoundingBox() const { Rect rect = Rect(0, 0, _contentSize.width, _contentSize.height); - return RectApplyAffineTransform(rect, nodeToParentTransform()); + return RectApplyAffineTransform(rect, getNodeToParentTransform()); } +Rect Node::boundingBox() const +{ + return getBoundingBox(); +} + + Node * Node::create(void) { Node * pRet = new Node(); @@ -882,7 +888,7 @@ void Node::transform() kmMat4 transfrom4x4; // Convert 3x3 into 4x4 matrix - AffineTransform tmpAffine = this->nodeToParentTransform(); + AffineTransform tmpAffine = this->getNodeToParentTransform(); CGAffineToGL(&tmpAffine, transfrom4x4.mat); // Update Z vertex manually @@ -1149,7 +1155,7 @@ void Node::update(float fDelta) } } -AffineTransform Node::nodeToParentTransform(void) +AffineTransform Node::getNodeToParentTransform() const { if (_transformDirty) { @@ -1225,6 +1231,12 @@ AffineTransform Node::nodeToParentTransform(void) return _transform; } +// XXX deprecated +AffineTransform Node::nodeToParentTransform() const +{ + return getNodeToParentTransform(); +} + void Node::setAdditionalTransform(const AffineTransform& additionalTransform) { _additionalTransform = additionalTransform; @@ -1232,68 +1244,86 @@ void Node::setAdditionalTransform(const AffineTransform& additionalTransform) _additionalTransformDirty = true; } -AffineTransform Node::parentToNodeTransform(void) +AffineTransform Node::getParentToNodeTransform() const { if ( _inverseDirty ) { - _inverse = AffineTransformInvert(this->nodeToParentTransform()); + _inverse = AffineTransformInvert(this->getNodeToParentTransform()); _inverseDirty = false; } return _inverse; } -AffineTransform Node::nodeToWorldTransform() +// XXX deprecated +AffineTransform Node::parentToNodeTransform() const { - AffineTransform t = this->nodeToParentTransform(); + return getParentToNodeTransform(); +} + +AffineTransform Node::getNodeToWorldTransform() const +{ + AffineTransform t = this->getNodeToParentTransform(); for (Node *p = _parent; p != NULL; p = p->getParent()) - t = AffineTransformConcat(t, p->nodeToParentTransform()); + t = AffineTransformConcat(t, p->getNodeToParentTransform()); return t; } -AffineTransform Node::worldToNodeTransform(void) +// XXX deprecated +AffineTransform Node::nodeToWorldTransform() const { - return AffineTransformInvert(this->nodeToWorldTransform()); + return getNodeToWorldTransform(); } -Point Node::convertToNodeSpace(const Point& worldPoint) +AffineTransform Node::getWorldToNodeTransform() const { - Point ret = PointApplyAffineTransform(worldPoint, worldToNodeTransform()); + return AffineTransformInvert(this->getNodeToWorldTransform()); +} + +// XXX deprecated +AffineTransform Node::worldToNodeTransform() const +{ + return getWorldToNodeTransform(); +} + +Point Node::convertToNodeSpace(const Point& worldPoint) const +{ + Point ret = PointApplyAffineTransform(worldPoint, getWorldToNodeTransform()); return ret; } -Point Node::convertToWorldSpace(const Point& nodePoint) +Point Node::convertToWorldSpace(const Point& nodePoint) const { - Point ret = PointApplyAffineTransform(nodePoint, nodeToWorldTransform()); + Point ret = PointApplyAffineTransform(nodePoint, getNodeToWorldTransform()); return ret; } -Point Node::convertToNodeSpaceAR(const Point& worldPoint) +Point Node::convertToNodeSpaceAR(const Point& worldPoint) const { Point nodePoint = convertToNodeSpace(worldPoint); return nodePoint - _anchorPointInPoints; } -Point Node::convertToWorldSpaceAR(const Point& nodePoint) +Point Node::convertToWorldSpaceAR(const Point& nodePoint) const { Point pt = nodePoint + _anchorPointInPoints; return convertToWorldSpace(pt); } -Point Node::convertToWindowSpace(const Point& nodePoint) +Point Node::convertToWindowSpace(const Point& nodePoint) const { Point worldPoint = this->convertToWorldSpace(nodePoint); return Director::getInstance()->convertToUI(worldPoint); } // convenience methods which take a Touch instead of Point -Point Node::convertTouchToNodeSpace(Touch *touch) +Point Node::convertTouchToNodeSpace(Touch *touch) const { Point point = touch->getLocation(); return this->convertToNodeSpace(point); } -Point Node::convertTouchToNodeSpaceAR(Touch *touch) +Point Node::convertTouchToNodeSpaceAR(Touch *touch) const { Point point = touch->getLocation(); return this->convertToNodeSpaceAR(point); diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index b1a49b87a6..f78d09a23c 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -464,7 +464,7 @@ public: * * @param fRotationX The X rotation in degrees which performs a horizontal rotational skew. */ - virtual void setRotationX(float fRotaionX); + virtual void setRotationX(float rotaionX); /** * Gets the X rotation (angle) of the node in degrees which performs a horizontal rotation skew. * @@ -483,7 +483,7 @@ public: * * @param fRotationY The Y rotation in degrees. */ - virtual void setRotationY(float fRotationY); + virtual void setRotationY(float rotationY); /** * Gets the Y rotation (angle) of the node in degrees which performs a vertical rotational skew. * @@ -504,7 +504,7 @@ public: * * @param uOrderOfArrival The arrival order. */ - virtual void setOrderOfArrival(unsigned int uOrderOfArrival); + virtual void setOrderOfArrival(unsigned int orderOfArrival); /** * Returns the arrival order, indecates which children is added previously. * @@ -520,7 +520,7 @@ public: * * @param glServerState The state of OpenGL server side. */ - virtual void setGLServerState(ccGLServerState glServerState); + virtual void setGLServerState(ccGLServerState serverState); /** * Returns the state of OpenGL server side. * @@ -612,7 +612,7 @@ public: * * @return The amount of children. */ - unsigned int getChildrenCount(void) const; + unsigned int getChildrenCount() const; /** * Sets the parent node @@ -720,7 +720,7 @@ public: * * @param A Grid object that is used when applying effects */ - virtual void setGrid(GridBase *pGrid); + virtual void setGrid(GridBase *grid); /// @} end of Grid @@ -769,7 +769,7 @@ public: * * @param A interger that indentifies the node. */ - virtual void setTag(int nTag); + virtual void setTag(int tag); /** * Returns a custom user data pointer @@ -788,7 +788,7 @@ public: * * @param A custom user data pointer */ - virtual void setUserData(void *pUserData); + virtual void setUserData(void *userData); /** * Returns a user assigned Object @@ -808,7 +808,7 @@ public: * * @param A user assigned Object */ - virtual void setUserObject(Object *pUserObject); + virtual void setUserObject(Object *userObject); /// @} end of Tag & User Data @@ -832,7 +832,7 @@ public: * * @param The shader program which fetchs from ShaderCache. */ - virtual void setShaderProgram(GLProgram *pShaderProgram); + virtual void setShaderProgram(GLProgram *shaderProgram); /// @} end of Shader Program @@ -861,7 +861,7 @@ public: /** * Schedules for lua script. */ - void scheduleUpdateWithPriorityLua(int nHandler, int priority); + void scheduleUpdateWithPriorityLua(int handler, int priority); /// @} end Script Bindings @@ -903,7 +903,7 @@ public: /** * Stops all running actions and schedulers */ - virtual void cleanup(void); + virtual void cleanup(); /** * Override this method to draw your own node. @@ -915,12 +915,12 @@ public: * AND YOU SHOULD NOT DISABLE THEM AFTER DRAWING YOUR NODE * But if you enable any other GL state, you should disable it after drawing your node. */ - virtual void draw(void); + virtual void draw(); /** * Visits this node's children and draw them recursively. */ - virtual void visit(void); + virtual void visit(); /** @@ -932,7 +932,10 @@ public: * * @return A "local" axis aligned boudning box of the node. */ - Rect boundingBox(void); + virtual Rect getBoundingBox() const; + + /** @deprecated Use getBoundingBox instead */ + CC_DEPRECATED_ATTRIBUTE Rect boundingBox() const; /// @{ /// @name Actions @@ -965,7 +968,7 @@ public: /** * Stops and removes all actions from the running action list . */ - void stopAllActions(void); + void stopAllActions(); /** * Stops and removes an action from the running action list. @@ -1000,7 +1003,7 @@ public: * * @return The number of actions that are running plus the ones that are schedule to run */ - unsigned int numberOfRunningActions(void); + unsigned int numberOfRunningActions(); /// @} end of Actions @@ -1136,13 +1139,13 @@ public: /** * Performs OpenGL view-matrix transformation based on position, scale, rotation and other attributes. */ - void transform(void); + void transform(); /** * Performs OpenGL view-matrix transformation of it's ancestors. * Generally the ancestors are already transformed, but in certain cases (eg: attaching a FBO) * It's necessary to transform the ancestors again. */ - void transformAncestors(void); + void transformAncestors(); /** * Calls children's updateTransform() method recursively. * @@ -1150,29 +1153,41 @@ public: * As the result, you apply SpriteBatchNode's optimization on your customed Node. * e.g., batchNode->addChild(myCustomNode), while you can only addChild(sprite) before. */ - virtual void updateTransform(void); + virtual void updateTransform(); /** * Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates. * The matrix is in Pixels. */ - virtual AffineTransform nodeToParentTransform(void); + virtual AffineTransform getNodeToParentTransform() const; + + /** @deprecated use getNodeToParentTransform() instead */ + CC_DEPRECATED_ATTRIBUTE virtual AffineTransform nodeToParentTransform() const; /** * Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates. * The matrix is in Pixels. */ - virtual AffineTransform parentToNodeTransform(void); + virtual AffineTransform getParentToNodeTransform() const; + + /** @deprecated Use getParentToNodeTransform() instead */ + CC_DEPRECATED_ATTRIBUTE virtual AffineTransform parentToNodeTransform() const; /** * Returns the world affine transform matrix. The matrix is in Pixels. */ - virtual AffineTransform nodeToWorldTransform(void); + virtual AffineTransform getNodeToWorldTransform() const; + + /** @deprecated Use getNodeToWorldTransform() instead */ + CC_DEPRECATED_ATTRIBUTE virtual AffineTransform nodeToWorldTransform() const; /** * Returns the inverse world affine transform matrix. The matrix is in Pixels. */ - virtual AffineTransform worldToNodeTransform(void); + virtual AffineTransform getWorldToNodeTransform() const; + + /** @deprecated Use worldToNodeTransform() instead */ + CC_DEPRECATED_ATTRIBUTE virtual AffineTransform worldToNodeTransform() const; /// @} end of Transformations @@ -1183,39 +1198,39 @@ public: /** * Converts a Point to node (local) space coordinates. The result is in Points. */ - Point convertToNodeSpace(const Point& worldPoint); + Point convertToNodeSpace(const Point& worldPoint) const; /** * Converts a Point to world space coordinates. The result is in Points. */ - Point convertToWorldSpace(const Point& nodePoint); + Point convertToWorldSpace(const Point& nodePoint) const; /** * Converts a Point to node (local) space coordinates. The result is in Points. * treating the returned/received node point as anchor relative. */ - Point convertToNodeSpaceAR(const Point& worldPoint); + Point convertToNodeSpaceAR(const Point& worldPoint) const; /** * Converts a local Point to world space coordinates.The result is in Points. * treating the returned/received node point as anchor relative. */ - Point convertToWorldSpaceAR(const Point& nodePoint); + Point convertToWorldSpaceAR(const Point& nodePoint) const; /** * convenience methods which take a Touch instead of Point */ - Point convertTouchToNodeSpace(Touch * touch); + Point convertTouchToNodeSpace(Touch * touch) const; /** * converts a Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). */ - Point convertTouchToNodeSpaceAR(Touch * touch); + Point convertTouchToNodeSpaceAR(Touch * touch) const; /** * Sets the additional transform. * - * @note The additional transform will be concatenated at the end of nodeToParentTransform. + * @note The additional transform will be concatenated at the end of getNodeToParentTransform. * It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't). * @code // create a batchNode @@ -1236,7 +1251,7 @@ public: spriteA->setPosition(Point(200, 200)); // Gets the spriteA's transform. - AffineTransform t = spriteA->nodeToParentTransform(); + AffineTransform t = spriteA->getNodeToParentTransform(); // Sets the additional transform to spriteB, spriteB's postion will based on its pseudo parent i.e. spriteA. spriteB->setAdditionalTransform(t); @@ -1245,7 +1260,7 @@ public: spriteA->setScale(2); // Gets the spriteA's transform. - t = spriteA->nodeToParentTransform(); + t = spriteA->getNodeToParentTransform(); // Sets the additional transform to spriteB, spriteB's scale will based on its pseudo parent i.e. spriteA. spriteB->setAdditionalTransform(t); @@ -1254,7 +1269,7 @@ public: spriteA->setRotation(20); // Gets the spriteA's transform. - t = spriteA->nodeToParentTransform(); + t = spriteA->getNodeToParentTransform(); // Sets the additional transform to spriteB, spriteB's rotation will based on its pseudo parent i.e. spriteA. spriteB->setAdditionalTransform(t); @@ -1298,7 +1313,7 @@ private: void detachChild(Node *child, bool doCleanup); /// Convert cocos2d coordinates to UI windows coordinate. - Point convertToWindowSpace(const Point& nodePoint); + Point convertToWindowSpace(const Point& nodePoint) const; protected: float _rotationX; ///< rotation angle on x-axis @@ -1319,11 +1334,14 @@ protected: Size _contentSize; ///< untransformed size of the node - - AffineTransform _additionalTransform; ///< transform - AffineTransform _transform; ///< transform - AffineTransform _inverse; ///< transform - + // "cache" variables are allowed to be mutable + mutable AffineTransform _additionalTransform; ///< transform + mutable AffineTransform _transform; ///< transform + mutable AffineTransform _inverse; ///< inverse transform + mutable bool _additionalTransformDirty; ///< The flag to check whether the additional transform is dirty + mutable bool _transformDirty; ///< transform dirty flag + mutable bool _inverseDirty; ///< inverse transform dirty flag + Camera *_camera; ///< a camera GridBase *_grid; ///< a grid @@ -1350,9 +1368,6 @@ protected: bool _running; ///< is running - bool _transformDirty; ///< transform dirty flag - bool _inverseDirty; ///< transform dirty flag - bool _additionalTransformDirty; ///< The flag to check whether the additional transform is dirty bool _visible; ///< is this node visible bool _ignoreAnchorPointForPosition; ///< true if the Anchor Point will be (0,0) when you position the Node, false otherwise. @@ -1387,23 +1402,24 @@ public: virtual ~NodeRGBA(); virtual bool init(); + + // overrides + virtual GLubyte getOpacity() const override; + virtual GLubyte getDisplayedOpacity() const override; + virtual void setOpacity(GLubyte opacity) override; + virtual void updateDisplayedOpacity(GLubyte parentOpacity) override; + virtual bool isCascadeOpacityEnabled() const override; + virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override; - virtual GLubyte getOpacity() const; - virtual GLubyte getDisplayedOpacity() const; - virtual void setOpacity(GLubyte opacity); - virtual void updateDisplayedOpacity(GLubyte parentOpacity); - virtual bool isCascadeOpacityEnabled() const; - virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled); + virtual const Color3B& getColor(void) const override; + virtual const Color3B& getDisplayedColor() const override; + virtual void setColor(const Color3B& color) override; + virtual void updateDisplayedColor(const Color3B& parentColor) override; + virtual bool isCascadeColorEnabled() const override; + virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override; - virtual const Color3B& getColor(void) const; - virtual const Color3B& getDisplayedColor() const; - virtual void setColor(const Color3B& color); - virtual void updateDisplayedColor(const Color3B& parentColor); - virtual bool isCascadeColorEnabled() const; - virtual void setCascadeColorEnabled(bool cascadeColorEnabled); - - virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);}; - virtual bool isOpacityModifyRGB() const { return false; }; + virtual void setOpacityModifyRGB(bool bValue) override {CC_UNUSED_PARAM(bValue);}; + virtual bool isOpacityModifyRGB() const override { return false; }; protected: GLubyte _displayedOpacity; diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index 36f741e5e0..ced9de644f 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -465,12 +465,12 @@ void Sprite::updateTransform(void) if( ! _parent || _parent == _batchNode ) { - _transformToBatch = nodeToParentTransform(); + _transformToBatch = getNodeToParentTransform(); } else { CCAssert( dynamic_cast(_parent), "Logic error in Sprite. Parent must be a Sprite"); - _transformToBatch = AffineTransformConcat( nodeToParentTransform() , ((Sprite*)_parent)->_transformToBatch ); + _transformToBatch = AffineTransformConcat( getNodeToParentTransform() , ((Sprite*)_parent)->_transformToBatch ); } // diff --git a/extensions/CCArmature/CCArmature.cpp b/extensions/CCArmature/CCArmature.cpp index ef72e4b626..5a213fbbba 100644 --- a/extensions/CCArmature/CCArmature.cpp +++ b/extensions/CCArmature/CCArmature.cpp @@ -323,7 +323,7 @@ Dictionary *Armature::getBoneDic() return _boneDic; } -AffineTransform Armature::nodeToParentTransform() +AffineTransform Armature::getNodeToParentTransform() const { if (_transformDirty) { @@ -404,7 +404,7 @@ AffineTransform Armature::nodeToParentTransform() void Armature::updateOffsetPoint() { // Set contentsize and Calculate anchor point. - Rect rect = boundingBox(); + Rect rect = getBoundingBox(); setContentSize(rect.size); _offsetPoint = Point(-rect.origin.x, -rect.origin.y); setAnchorPoint(Point(_offsetPoint.x / rect.size.width, _offsetPoint.y / rect.size.height)); @@ -523,7 +523,7 @@ void Armature::visit() kmGLPopMatrix(); } -Rect Armature::boundingBox() +Rect Armature::getBoundingBox() const { float minx, miny, maxx, maxy = 0; diff --git a/extensions/CCArmature/CCArmature.h b/extensions/CCArmature/CCArmature.h index 08ba7f9ea1..0f3c2f4e41 100644 --- a/extensions/CCArmature/CCArmature.h +++ b/extensions/CCArmature/CCArmature.h @@ -54,7 +54,7 @@ public: public: Armature(); - ~Armature(void); + virtual ~Armature(void); /** * Init the empty armature @@ -101,27 +101,24 @@ public: * @return Armature's bone dictionary */ Dictionary *getBoneDic(); - - /** - * This boundingBox will calculate all bones' boundingBox every time - */ - virtual Rect boundingBox(); Bone *getBoneAtPoint(float x, float y); - virtual void visit(); - virtual void update(float dt); - virtual void draw(); - - virtual AffineTransform nodeToParentTransform(); /** * Set contentsize and Calculate anchor point. */ virtual void updateOffsetPoint(); - inline void setBlendFunc(const BlendFunc& blendFunc) { _blendFunc = blendFunc; } - inline const BlendFunc& getBlendFunc(void) const { return _blendFunc; } + // overrides + virtual void visit() override; + virtual void update(float dt) override; + virtual void draw() override; + virtual AffineTransform getNodeToParentTransform() const override; + /** This boundingBox will calculate all bones' boundingBox every time */ + virtual Rect getBoundingBox() const override; + inline void setBlendFunc(const BlendFunc& blendFunc) override { _blendFunc = blendFunc; } + inline const BlendFunc& getBlendFunc(void) const override { return _blendFunc; } protected: diff --git a/extensions/CCArmature/display/CCDisplayManager.cpp b/extensions/CCArmature/display/CCDisplayManager.cpp index cb940dedba..25121c56e8 100644 --- a/extensions/CCArmature/display/CCDisplayManager.cpp +++ b/extensions/CCArmature/display/CCDisplayManager.cpp @@ -303,7 +303,7 @@ Size DisplayManager::getContentSize() Rect DisplayManager::getBoundingBox() { CS_RETURN_IF(!_displayRenderNode) Rect(0, 0, 0, 0); - return _displayRenderNode->boundingBox(); + return _displayRenderNode->getBoundingBox(); } diff --git a/extensions/CCArmature/display/CCSkin.cpp b/extensions/CCArmature/display/CCSkin.cpp index 802637936f..a1555bdb14 100644 --- a/extensions/CCArmature/display/CCSkin.cpp +++ b/extensions/CCArmature/display/CCSkin.cpp @@ -71,7 +71,7 @@ void Skin::setSkinData(const BaseData &var) setRotation(CC_RADIANS_TO_DEGREES(_skinData.skewX)); setPosition(Point(_skinData.x, _skinData.y)); - _skinTransform = nodeToParentTransform(); + _skinTransform = getNodeToParentTransform(); } const BaseData &Skin::getSkinData() const diff --git a/extensions/GUI/CCControlExtension/CCControl.cpp b/extensions/GUI/CCControlExtension/CCControl.cpp index 5177029e4f..bcd4323185 100644 --- a/extensions/GUI/CCControlExtension/CCControl.cpp +++ b/extensions/GUI/CCControlExtension/CCControl.cpp @@ -260,7 +260,7 @@ bool Control::isTouchInside(Touch* touch) { Point touchLocation = touch->getLocation(); // Get the touch position touchLocation = this->getParent()->convertToNodeSpace(touchLocation); - Rect bBox=boundingBox(); + Rect bBox = getBoundingBox(); return bBox.containsPoint(touchLocation); } diff --git a/extensions/GUI/CCControlExtension/CCControlButton.cpp b/extensions/GUI/CCControlExtension/CCControlButton.cpp index 328008c8cc..e27a9d2ec3 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.cpp +++ b/extensions/GUI/CCControlExtension/CCControlButton.cpp @@ -568,7 +568,7 @@ void ControlButton::needsLayout() Size titleLabelSize; if (_titleLabel != NULL) { - titleLabelSize = _titleLabel->boundingBox().size; + titleLabelSize = _titleLabel->getBoundingBox().size; } // Adjust the background image if necessary @@ -603,12 +603,12 @@ void ControlButton::needsLayout() Rect rectTitle; if (_titleLabel != NULL) { - rectTitle = _titleLabel->boundingBox(); + rectTitle = _titleLabel->getBoundingBox(); } Rect rectBackground; if (_backgroundSprite != NULL) { - rectBackground = _backgroundSprite->boundingBox(); + rectBackground = _backgroundSprite->getBoundingBox(); } Rect maxRect = ControlUtils::RectUnion(rectTitle, rectBackground); diff --git a/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp b/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp index f171b1557d..59c297e468 100644 --- a/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp +++ b/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp @@ -67,7 +67,7 @@ bool ControlHuePicker::initWithTargetAndPos(Node* target, Point pos) this->setBackground(ControlUtils::addSpriteToTargetWithPosAndAnchor("huePickerBackground.png", target, pos, Point(0.0f, 0.0f))); this->setSlider(ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, Point(0.5f, 0.5f))); - _slider->setPosition(Point(pos.x, pos.y + _background->boundingBox().size.height * 0.5f)); + _slider->setPosition(Point(pos.x, pos.y + _background->getBoundingBox().size.height * 0.5f)); _startPos=pos; // Sets the default value @@ -96,7 +96,7 @@ void ControlHuePicker::setHuePercentage(float hueValueInPercent) _hue=_huePercentage*360.0f; // Clamp the position of the icon within the circle - Rect backgroundBox=_background->boundingBox(); + Rect backgroundBox=_background->getBoundingBox(); // Get the center point of the background image float centerX = _startPos.x + backgroundBox.size.width * 0.5f; @@ -129,7 +129,7 @@ void ControlHuePicker::updateSliderPosition(Point location) { // Clamp the position of the icon within the circle - Rect backgroundBox=_background->boundingBox(); + Rect backgroundBox=_background->getBoundingBox(); // Get the center point of the background image float centerX = _startPos.x + backgroundBox.size.width * 0.5f; diff --git a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp index 4f5668a500..5e99396b45 100644 --- a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp @@ -121,8 +121,8 @@ void ControlSaturationBrightnessPicker::updateSliderPosition(Point sliderPositio // Clamp the position of the icon within the circle // Get the center point of the bkgd image - float centerX = _startPos.x + _background->boundingBox().size.width*0.5f; - float centerY = _startPos.y + _background->boundingBox().size.height*0.5f; + float centerX = _startPos.x + _background->getBoundingBox().size.width*0.5f; + float centerY = _startPos.y + _background->getBoundingBox().size.height*0.5f; // Work out the distance difference between the location and center float dx = sliderPosition.x - centerX; @@ -133,7 +133,7 @@ void ControlSaturationBrightnessPicker::updateSliderPosition(Point sliderPositio float angle = atan2f(dy, dx); // Set the limit to the slider movement within the colour picker - float limit = _background->boundingBox().size.width*0.5f; + float limit = _background->getBoundingBox().size.width*0.5f; // Check distance doesn't exceed the bounds of the circle if (dist > limit) @@ -162,8 +162,8 @@ bool ControlSaturationBrightnessPicker::checkSliderPosition(Point location) // Clamp the position of the icon within the circle // get the center point of the bkgd image - float centerX = _startPos.x + _background->boundingBox().size.width*0.5f; - float centerY = _startPos.y + _background->boundingBox().size.height*0.5f; + float centerX = _startPos.x + _background->getBoundingBox().size.width*0.5f; + float centerY = _startPos.y + _background->getBoundingBox().size.height*0.5f; // work out the distance difference between the location and center float dx = location.x - centerX; @@ -171,7 +171,7 @@ bool ControlSaturationBrightnessPicker::checkSliderPosition(Point location) float dist = sqrtf(dx*dx+dy*dy); // check that the touch location is within the bounding rectangle before sending updates - if (dist <= _background->boundingBox().size.width*0.5f) + if (dist <= _background->getBoundingBox().size.width*0.5f) { updateSliderPosition(location); sendActionsForControlEvents(ControlEventValueChanged); diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.cpp b/extensions/GUI/CCControlExtension/CCControlSlider.cpp index 6a2e2b5a10..a867545998 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSlider.cpp @@ -91,7 +91,7 @@ ControlSlider* ControlSlider::create(Sprite * backgroundSprite, Sprite* pogressS this->setThumbSprite(thumbSprite); // Defines the content size - Rect maxRect = ControlUtils::RectUnion(backgroundSprite->boundingBox(), thumbSprite->boundingBox()); + Rect maxRect = ControlUtils::RectUnion(backgroundSprite->getBoundingBox(), thumbSprite->getBoundingBox()); setContentSize(Size(maxRect.size.width, maxRect.size.height)); @@ -179,7 +179,7 @@ bool ControlSlider::isTouchInside(Touch * touch) Point touchLocation = touch->getLocation(); touchLocation = this->getParent()->convertToNodeSpace(touchLocation); - Rect rect = this->boundingBox(); + Rect rect = this->getBoundingBox(); rect.size.width += _thumbSprite->getContentSize().width; rect.origin.x -= _thumbSprite->getContentSize().width / 2; diff --git a/extensions/GUI/CCControlExtension/CCControlStepper.cpp b/extensions/GUI/CCControlExtension/CCControlStepper.cpp index 9ce7be51ae..2e5f5562cc 100644 --- a/extensions/GUI/CCControlExtension/CCControlStepper.cpp +++ b/extensions/GUI/CCControlExtension/CCControlStepper.cpp @@ -108,7 +108,7 @@ bool ControlStepper::initWithMinusSpriteAndPlusSprite(Sprite *minusSprite, Sprit _plusSprite->addChild(_plusLabel); // Defines the content size - Rect maxRect = ControlUtils::RectUnion(_minusSprite->boundingBox(), _plusSprite->boundingBox()); + Rect maxRect = ControlUtils::RectUnion(_minusSprite->getBoundingBox(), _plusSprite->getBoundingBox()); this->setContentSize( Size(_minusSprite->getContentSize().width + _plusSprite->getContentSize().height, maxRect.size.height) ); return true; } diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index 9f03e0723c..35e3de78d0 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -145,7 +145,7 @@ bool ScrollView::isNodeVisible(Node* node) viewRect = Rect(-offset.x/scale, -offset.y/scale, size.width/scale, size.height/scale); - return viewRect.intersectsRect(node->boundingBox()); + return viewRect.intersectsRect(node->getBoundingBox()); } void ScrollView::pause(Object* sender) diff --git a/extensions/GUI/CCScrollView/CCTableView.cpp b/extensions/GUI/CCScrollView/CCTableView.cpp index 8e384e20a8..0637f99810 100644 --- a/extensions/GUI/CCScrollView/CCTableView.cpp +++ b/extensions/GUI/CCScrollView/CCTableView.cpp @@ -566,7 +566,7 @@ void TableView::ccTouchEnded(Touch *pTouch, Event *pEvent) } if (_touchedCell){ - Rect bb = this->boundingBox(); + Rect bb = this->getBoundingBox(); bb.origin = _parent->convertToWorldSpace(bb.origin); if (bb.containsPoint(pTouch->getLocation()) && _tableViewDelegate != NULL) diff --git a/extensions/physics_nodes/CCPhysicsSprite.cpp b/extensions/physics_nodes/CCPhysicsSprite.cpp index ee48bfb061..0d00a8c17b 100644 --- a/extensions/physics_nodes/CCPhysicsSprite.cpp +++ b/extensions/physics_nodes/CCPhysicsSprite.cpp @@ -148,7 +148,7 @@ PhysicsSprite* PhysicsSprite::create(const char *pszFileName, const Rect& rect) // this method will only get called if the sprite is batched. // return YES if the physic's values (angles, position ) changed. -// If you return NO, then nodeToParentTransform won't be called. +// If you return NO, then getNodeToParentTransform won't be called. bool PhysicsSprite::isDirty() const { return true; @@ -342,7 +342,7 @@ void PhysicsSprite::setRotation(float fRotation) } // returns the transform matrix according the Chipmunk Body values -AffineTransform PhysicsSprite::nodeToParentTransform() +AffineTransform PhysicsSprite::getNodeToParentTransform() const { // Although scale is not used by physics engines, it is calculated just in case // the sprite is animated (scaled up/down) using actions. diff --git a/extensions/physics_nodes/CCPhysicsSprite.h b/extensions/physics_nodes/CCPhysicsSprite.h index 7c209e5ea9..1cb7a6e9d9 100644 --- a/extensions/physics_nodes/CCPhysicsSprite.h +++ b/extensions/physics_nodes/CCPhysicsSprite.h @@ -96,15 +96,6 @@ public: bool isIgnoreBodyRotation() const; void setIgnoreBodyRotation(bool bIgnoreBodyRotation); - virtual const Point& getPosition() const; - virtual void getPosition(float* x, float* y) const; - virtual float getPositionX() const; - virtual float getPositionY() const; - virtual void setPosition(const Point &position); - virtual float getRotation() const; - virtual void setRotation(float fRotation); - virtual AffineTransform nodeToParentTransform(); - // // Chipmunk specific // @@ -122,6 +113,16 @@ public: float getPTMRatio() const; void setPTMRatio(float fPTMRatio); + // overrides + virtual const Point& getPosition() const override; + virtual void getPosition(float* x, float* y) const override; + virtual float getPositionX() const override; + virtual float getPositionY() const override; + virtual void setPosition(const Point &position) override; + virtual float getRotation() const override; + virtual void setRotation(float fRotation) override; + virtual AffineTransform getNodeToParentTransform() const override; + protected: const Point& getPosFromPhysics() const; }; diff --git a/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.h b/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.h index 48304fa48e..36df7d8154 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.h +++ b/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.h @@ -11,7 +11,7 @@ public: PhysicsSprite(); void setPhysicsBody(b2Body * body); virtual bool isDirty(void); - virtual AffineTransform nodeToParentTransform(void); + virtual AffineTransform getNodeToParentTransform(void) const; private: b2Body* _body; // strong ref }; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp index b5f3f93267..998c9bbb73 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp @@ -579,7 +579,7 @@ void TestBoundingBox::draw() { CC_NODE_DRAW_SETUP(); - rect = RectApplyAffineTransform(armature->boundingBox(), armature->nodeToParentTransform()); + rect = RectApplyAffineTransform(armature->getBoundingBox(), armature->getNodeToParentTransform()); ccDrawColor4B(100, 100, 100, 255); ccDrawRect(rect.origin, Point(rect.getMaxX(), rect.getMaxY())); diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp index 89c0a02e94..dc6eb71df0 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp @@ -1276,7 +1276,7 @@ void BitmapFontMultiLineAlignment::ccTouchesBegan(cocos2d::Set *pTouches, cocos2 Touch *touch = (Touch *)pTouches->anyObject(); Point location = touch->getLocationInView(); - if (this->_arrowsShouldRetain->boundingBox().containsPoint(location)) + if (this->_arrowsShouldRetain->getBoundingBox().containsPoint(location)) { _drag = true; this->_arrowsBarShouldRetain->setVisible(true); diff --git a/samples/Cpp/TestCpp/Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp b/samples/Cpp/TestCpp/Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp index 3d08544f9c..cf9e4d72cc 100644 --- a/samples/Cpp/TestCpp/Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp @@ -39,7 +39,7 @@ void TextureAtlasEncryptionDemo::onEnter() this->addChild(nonencryptedSprite); LabelTTF* nonencryptedSpriteLabel = LabelTTF::create("non-encrypted", "Arial", 28); - nonencryptedSpriteLabel->setPosition(Point(s.width * 0.25f, nonencryptedSprite->boundingBox().getMinY() - nonencryptedSprite->getContentSize().height/2)); + nonencryptedSpriteLabel->setPosition(Point(s.width * 0.25f, nonencryptedSprite->getBoundingBox().getMinY() - nonencryptedSprite->getContentSize().height/2)); this->addChild(nonencryptedSpriteLabel, 1); // Load the encrypted atlas @@ -66,7 +66,7 @@ void TextureAtlasEncryptionDemo::onEnter() this->addChild(encryptedSprite); LabelTTF* encryptedSpriteLabel = LabelTTF::create("encrypted", "Arial", 28); - encryptedSpriteLabel->setPosition(Point(s.width * 0.75f, encryptedSprite->boundingBox().getMinY() - encryptedSpriteLabel->getContentSize().height/2)); + encryptedSpriteLabel->setPosition(Point(s.width * 0.75f, encryptedSprite->getBoundingBox().getMinY() - encryptedSpriteLabel->getContentSize().height/2)); this->addChild(encryptedSpriteLabel, 1); } From 0f1ac9983f214492b2dececcc82c8c6a13ff2901 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 17 Jul 2013 10:15:25 +0800 Subject: [PATCH 06/31] issue #2377:Modify some tolua_*_open functions place and Modify Websocket,OpenGl,Scrollview handlers operation. --- samples/Lua/TestLua/Classes/AppDelegate.cpp | 18 -- .../lua/cocos2dx_support/CCLuaEngine.cpp | 58 +++++ scripting/lua/cocos2dx_support/CCLuaEngine.h | 3 + scripting/lua/cocos2dx_support/CCLuaStack.cpp | 15 ++ .../LuaOpengl.cpp.REMOVED.git-id | 2 +- scripting/lua/cocos2dx_support/LuaOpengl.h | 6 + .../cocos2dx_support/LuaScriptHandlerMgr.cpp | 179 +++++++++++++- .../cocos2dx_support/LuaScriptHandlerMgr.h | 19 ++ .../lua/cocos2dx_support/LuaScrollView.cpp | 158 +++---------- .../lua/cocos2dx_support/LuaScrollView.h | 15 ++ .../lua/cocos2dx_support/Lua_web_socket.cpp | 221 +++++------------- .../lua/cocos2dx_support/Lua_web_socket.h | 19 ++ 12 files changed, 390 insertions(+), 323 deletions(-) diff --git a/samples/Lua/TestLua/Classes/AppDelegate.cpp b/samples/Lua/TestLua/Classes/AppDelegate.cpp index bfcfeffab4..e1644cee70 100644 --- a/samples/Lua/TestLua/Classes/AppDelegate.cpp +++ b/samples/Lua/TestLua/Classes/AppDelegate.cpp @@ -3,13 +3,6 @@ #include "AppDelegate.h" #include "CCLuaEngine.h" #include "SimpleAudioEngine.h" -#include "Lua_extensions_CCB.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) -#include "Lua_web_socket.h" -#endif -#include "LuaOpengl.h" -#include "LuaScrollView.h" -#include "LuaScriptHandlerMgr.h" using namespace CocosDenshion; @@ -57,16 +50,6 @@ bool AppDelegate::applicationDidFinishLaunching() LuaEngine* pEngine = LuaEngine::defaultEngine(); ScriptEngineManager::sharedManager()->setScriptEngine(pEngine); - LuaStack *pStack = pEngine->getLuaStack(); - lua_State *tolua_s = pStack->getLuaState(); - tolua_extensions_ccb_open(tolua_s); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) - tolua_web_socket_open(tolua_s); -#endif - tolua_opengl_open(tolua_s); - tolua_scroll_view_open(tolua_s); - tolua_script_handler_mgr_open(tolua_s); - std::vector searchPaths = pFileUtils->getSearchPaths(); searchPaths.push_back("cocosbuilderRes"); @@ -76,7 +59,6 @@ bool AppDelegate::applicationDidFinishLaunching() #endif FileUtils::getInstance()->setSearchPaths(searchPaths); - pEngine->extendLuaObject(); pEngine->executeScriptFile("luaScript/controller.lua"); return true; diff --git a/scripting/lua/cocos2dx_support/CCLuaEngine.cpp b/scripting/lua/cocos2dx_support/CCLuaEngine.cpp index f40c296704..8a55027563 100644 --- a/scripting/lua/cocos2dx_support/CCLuaEngine.cpp +++ b/scripting/lua/cocos2dx_support/CCLuaEngine.cpp @@ -53,6 +53,7 @@ bool LuaEngine::init(void) { _stack = LuaStack::create(); _stack->retain(); + extendLuaObject(); return true; } @@ -565,6 +566,9 @@ void LuaEngine::extendLuaObject() extendMenuItem(lua_S); extendLayer(lua_S); extendControl(lua_S); + extendWebsocket(lua_S); + extendGLNode(lua_S); + extendScrollView(lua_S); _stack->clean(); } @@ -652,4 +656,58 @@ void LuaEngine::extendControl(lua_State* lua_S) lua_rawset(lua_S,-3); } } + +void LuaEngine::extendWebsocket(lua_State* lua_S) +{ + if (NULL == lua_S) + return; + + lua_pushstring(lua_S,"WebSocket"); + lua_rawget(lua_S,LUA_REGISTRYINDEX); + if (lua_istable(lua_S,-1)) + { + lua_pushstring(lua_S,"registerScriptHandler"); + lua_pushcfunction(lua_S,tolua_Cocos2d_WebSocket_registerScriptHandler00); + lua_rawset(lua_S,-3); + lua_pushstring(lua_S,"unregisterScriptHandler"); + lua_pushcfunction(lua_S,tolua_Cocos2d_WebSocket_unregisterScriptHandler00); + lua_rawset(lua_S,-3); + } +} + +void LuaEngine::extendGLNode(lua_State* lua_S) +{ + if (NULL == lua_S) + return; + + lua_pushstring(lua_S,"GLNode"); + lua_rawget(lua_S,LUA_REGISTRYINDEX); + if (lua_istable(lua_S,-1)) + { + lua_pushstring(lua_S,"registerScriptDrawHandler"); + lua_pushcfunction(lua_S,tolua_Cocos2d_GLNode_registerScriptDrawHandler00); + lua_rawset(lua_S,-3); + lua_pushstring(lua_S,"unregisterScriptDrawHandler"); + lua_pushcfunction(lua_S,tolua_Cocos2d_GLNode_unregisterScriptDrawHandler00); + lua_rawset(lua_S,-3); + } +} + +void LuaEngine::extendScrollView(lua_State* lua_S) +{ + if (NULL == lua_S) + return; + + lua_pushstring(lua_S,"CCScrollView"); + lua_rawget(lua_S,LUA_REGISTRYINDEX); + if (lua_istable(lua_S,-1)) + { + lua_pushstring(lua_S,"registerScriptHandler"); + lua_pushcfunction(lua_S,tolua_Cocos2d_ScrollView_registerScriptHandler00); + lua_rawset(lua_S,-3); + lua_pushstring(lua_S,"unregisterScriptHandler"); + lua_pushcfunction(lua_S,tolua_Cocos2d_ScrollView_unregisterScriptHandler00); + lua_rawset(lua_S,-3); + } +} NS_CC_END diff --git a/scripting/lua/cocos2dx_support/CCLuaEngine.h b/scripting/lua/cocos2dx_support/CCLuaEngine.h index 4fedd35233..6cb8b651e2 100644 --- a/scripting/lua/cocos2dx_support/CCLuaEngine.h +++ b/scripting/lua/cocos2dx_support/CCLuaEngine.h @@ -135,6 +135,9 @@ private: void extendMenuItem(lua_State* lua_S); void extendLayer(lua_State* lua_S); void extendControl(lua_State* lua_S); + void extendWebsocket(lua_State* lua_S); + void extendGLNode(lua_State* lua_S); + void extendScrollView(lua_State* lua_S); private: LuaEngine(void) : _stack(NULL) diff --git a/scripting/lua/cocos2dx_support/CCLuaStack.cpp b/scripting/lua/cocos2dx_support/CCLuaStack.cpp index d4623730f2..657904ec10 100644 --- a/scripting/lua/cocos2dx_support/CCLuaStack.cpp +++ b/scripting/lua/cocos2dx_support/CCLuaStack.cpp @@ -39,6 +39,14 @@ extern "C" { #include "platform/ios/CCLuaObjcBridge.h" #endif +#include "Lua_extensions_CCB.h" +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) +#include "Lua_web_socket.h" +#endif +#include "LuaOpengl.h" +#include "LuaScrollView.h" +#include "LuaScriptHandlerMgr.h" + namespace { int lua_print(lua_State * luastate) { @@ -118,6 +126,13 @@ bool LuaStack::init(void) #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) LuaObjcBridge::luaopen_luaoc(_state); #endif + tolua_extensions_ccb_open(_state); +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) + tolua_web_socket_open(_state); +#endif + tolua_opengl_open(_state); + tolua_scroll_view_open(_state); + tolua_script_handler_mgr_open(_state); // add cocos2dx loader addLuaLoader(cocos2dx_lua_loader); diff --git a/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id index c2c49c47a7..c2f47e866a 100644 --- a/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id @@ -1 +1 @@ -9fac9e19f8a57d40eb90b02c0be6e9f8e20e0d22 \ No newline at end of file +31f6e535b10b0e282216d54533c9cae806c34d8e \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/LuaOpengl.h b/scripting/lua/cocos2dx_support/LuaOpengl.h index 68b8d94018..605d66c320 100644 --- a/scripting/lua/cocos2dx_support/LuaOpengl.h +++ b/scripting/lua/cocos2dx_support/LuaOpengl.h @@ -9,6 +9,12 @@ extern "C" { } #endif +#include "base_nodes/CCNode.h" +class GLNode:public cocos2d::Node +{ + virtual void draw(); +}; + TOLUA_API int tolua_opengl_open(lua_State* tolua_S); diff --git a/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp b/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp index 44fae6f12a..8bd237f9fb 100644 --- a/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp +++ b/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp @@ -14,6 +14,9 @@ extern "C" { #include "CCLuaStack.h" #include "CCLuaValue.h" #include "CCLuaEngine.h" +#include "Lua_web_socket.h" +#include "LuaOpengl.h" +#include "LuaScrollView.h" using namespace cocos2d; using namespace cocos2d::extension; @@ -467,7 +470,7 @@ int tolua_Cocos2d_registerControlEventHandler00(lua_State* tolua_S) { Control* control = (Control*) tolua_tousertype(tolua_S,1,0); LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); - int controlevent = ((ControlEvent) (int) tolua_tonumber(tolua_S,3,0)); + ControlEvent controlevent = (ControlEvent)tolua_tonumber(tolua_S,3,0); for (int i = 0; i < kControlEventTotalNumber; i++) { if ((controlevent & (1 << i))) @@ -499,8 +502,16 @@ int tolua_Cocos2d_unregisterControlEventHandler00(lua_State* tolua_S) #endif { Control* control = (Control*) tolua_tousertype(tolua_S,1,0); - int handlerEvent = (int)tolua_tonumber(tolua_S,2,0); - ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)control,handlerEvent); + ControlEvent controlevent = (ControlEvent)tolua_tonumber(tolua_S,2,0); + for (int i = 0; i < kControlEventTotalNumber; i++) + { + if ((controlevent & (1 << i))) + { + int handlerevent = ScriptHandlerMgr::kControlTouchDownHandler + i; + ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)control, handlerevent); + break; + } + } } return 0; #ifndef TOLUA_RELEASE @@ -510,6 +521,161 @@ tolua_lerror: #endif } +int tolua_Cocos2d_WebSocket_registerScriptHandler00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"WebSocket",0,&tolua_err) || + !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + LuaWebSocket* self = (LuaWebSocket*) tolua_tousertype(tolua_S,1,0); + if (NULL != self ) { + int handler = ( toluafix_ref_function(tolua_S,2,0)); + ScriptHandlerMgr::HandlerEventType handlerType = (ScriptHandlerMgr::HandlerEventType)((int)tolua_tonumber(tolua_S,3,0) + ScriptHandlerMgr::kWebSocketScriptHandlerOpen); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, handlerType); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); + return 0; +#endif +} + +int tolua_Cocos2d_WebSocket_unregisterScriptHandler00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"WebSocket",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + LuaWebSocket* self = (LuaWebSocket*) tolua_tousertype(tolua_S,1,0); + if (NULL != self ) { + ScriptHandlerMgr::HandlerEventType handlerType = (ScriptHandlerMgr::HandlerEventType)((int)tolua_tonumber(tolua_S,2,0) + ScriptHandlerMgr::kWebSocketScriptHandlerOpen); + + ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, handlerType); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err); + return 0; +#endif +} + +int tolua_Cocos2d_GLNode_registerScriptDrawHandler00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"GLNode",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err)) + goto tolua_lerror; + else +#endif + { + GLNode* glNode = (GLNode*) tolua_tousertype(tolua_S,1,0); + LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)glNode, handler, ScriptHandlerMgr::kGLNodeDrawHandler); + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'registerScriptDrawHandler'.",&tolua_err); + return 0; +#endif +} + + +int tolua_Cocos2d_GLNode_unregisterScriptDrawHandler00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"GLNode",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err)) + goto tolua_lerror; + else +#endif + { + GLNode* glNode = (GLNode*)tolua_tousertype(tolua_S,1,0); + ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)glNode,ScriptHandlerMgr::kGLNodeDrawHandler); + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'unregisterScriptDrawHandler'.",&tolua_err); + return 0; +#endif +} + +int tolua_Cocos2d_ScrollView_registerScriptHandler00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCScrollView",0,&tolua_err) || + !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + LuaScrollView* self = (LuaScrollView*) tolua_tousertype(tolua_S,1,0); + LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); + ScriptHandlerMgr::HandlerEventType handlerType = (ScriptHandlerMgr::HandlerEventType) ((int)tolua_tonumber(tolua_S,3,0) + ScriptHandlerMgr::kScrollViewScrollHandler); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, handlerType); + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); + return 0; +#endif +} + +int tolua_Cocos2d_ScrollView_unregisterScriptHandler00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCScrollView",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + LuaScrollView* self = (LuaScrollView*) tolua_tousertype(tolua_S,1,0); + ScriptHandlerMgr::HandlerEventType handlerType = (ScriptHandlerMgr::HandlerEventType) ((int)tolua_tonumber(tolua_S,2,0) + ScriptHandlerMgr::kScrollViewScrollHandler); + ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, handlerType); + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err); + return 0; +#endif +} + + static void tolua_reg_script_handler_mgr_type(lua_State* tolua_S) { tolua_usertype(tolua_S, "CCCallFunc"); @@ -603,6 +769,13 @@ TOLUA_API int tolua_script_handler_mgr_open(lua_State* tolua_S) tolua_constant(tolua_S,"kControlTouchUpOutsideHandler",ScriptHandlerMgr::kControlTouchUpOutsideHandler); tolua_constant(tolua_S,"kControlTouchCancelHandler",ScriptHandlerMgr::kControlTouchCancelHandler); tolua_constant(tolua_S,"kControlValueChangedHandler",ScriptHandlerMgr::kControlValueChangedHandler); + tolua_constant(tolua_S,"kWebSocketScriptHandlerOpen",ScriptHandlerMgr::kWebSocketScriptHandlerOpen); + tolua_constant(tolua_S,"kWebSocketScriptHandlerMessage",ScriptHandlerMgr::kWebSocketScriptHandlerMessage); + tolua_constant(tolua_S,"kWebSocketScriptHandlerClose",ScriptHandlerMgr::kWebSocketScriptHandlerClose); + tolua_constant(tolua_S,"kWebSocketScriptHandlerError",ScriptHandlerMgr::kWebSocketScriptHandlerError); + tolua_constant(tolua_S,"kGLNodeDrawHandler",ScriptHandlerMgr::kGLNodeDrawHandler); + tolua_constant(tolua_S,"kScrollViewScrollHandler",ScriptHandlerMgr::kScrollViewScrollHandler); + tolua_constant(tolua_S,"kScrollViewZoomHandler",ScriptHandlerMgr::kScrollViewZoomHandler); tolua_function(tolua_S, "getInstance", tolua_Cocos2d_ScriptHandlerMgr_getInstance00); tolua_endmodule(tolua_S); tolua_endmodule(tolua_S); diff --git a/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.h b/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.h index a64d96d221..0a173bdc26 100644 --- a/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.h +++ b/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.h @@ -90,6 +90,16 @@ public: kControlTouchUpOutsideHandler, kControlTouchCancelHandler, kControlValueChangedHandler, + + kWebSocketScriptHandlerOpen, + kWebSocketScriptHandlerMessage, + kWebSocketScriptHandlerClose, + kWebSocketScriptHandlerError, + + kGLNodeDrawHandler, + + kScrollViewScrollHandler, + kScrollViewZoomHandler, }; @@ -119,6 +129,15 @@ TOLUA_API int tolua_Cocos2d_unregisterScriptAccelerateHandler00(lua_State* tolua TOLUA_API int tolua_Cocos2d_registerControlEventHandler00(lua_State* tolua_S); TOLUA_API int tolua_Cocos2d_unregisterControlEventHandler00(lua_State* tolua_S); +TOLUA_API int tolua_Cocos2d_WebSocket_registerScriptHandler00(lua_State* tolua_S); +TOLUA_API int tolua_Cocos2d_WebSocket_unregisterScriptHandler00(lua_State* tolua_S); + +TOLUA_API int tolua_Cocos2d_GLNode_registerScriptDrawHandler00(lua_State* tolua_S); +TOLUA_API int tolua_Cocos2d_GLNode_unregisterScriptDrawHandler00(lua_State* tolua_S); + +TOLUA_API int tolua_Cocos2d_ScrollView_registerScriptHandler00(lua_State* tolua_S); +TOLUA_API int tolua_Cocos2d_ScrollView_unregisterScriptHandler00(lua_State* tolua_S); + TOLUA_API int tolua_script_handler_mgr_open(lua_State* tolua_S); #endif //__LUA_SCRIPT_HANDLER_MGR_H__ diff --git a/scripting/lua/cocos2dx_support/LuaScrollView.cpp b/scripting/lua/cocos2dx_support/LuaScrollView.cpp index 1ae1fd96fc..8e93e36567 100644 --- a/scripting/lua/cocos2dx_support/LuaScrollView.cpp +++ b/scripting/lua/cocos2dx_support/LuaScrollView.cpp @@ -14,87 +14,47 @@ extern "C" { #include "CCLuaStack.h" #include "CCLuaValue.h" #include "CCLuaEngine.h" +#include "LuaScriptHandlerMgr.h" using namespace cocos2d; using namespace cocos2d::extension; -class LuaScrollView:public ScrollView,public ScrollViewDelegate + +LuaScrollView::~LuaScrollView() { -public: - virtual ~LuaScrollView() - { - unregisterScriptHandler(LuaScrollView::kScrollViewScriptScroll); - unregisterScriptHandler(LuaScrollView::kScrollViewScriptZoom); - } + +} - virtual void scrollViewDidScroll(ScrollView* view) +void LuaScrollView::scrollViewDidScroll(ScrollView* view) +{ + LuaScrollView* luaView = dynamic_cast(view); + if (NULL != luaView) { - LuaScrollView* luaView = dynamic_cast(view); - if (NULL != luaView) + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)luaView, ScriptHandlerMgr::kScrollViewScrollHandler); + if (0 != handler) { - int nHandler = luaView->getScriptHandler(LuaScrollView::kScrollViewScriptScroll); - if (0 != nHandler) - { - CommonScriptData data(nHandler,""); - ScriptEvent event(kCommonEvent,(void*)&data); - ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event); - } + CommonScriptData data(handler,""); + ScriptEvent event(kCommonEvent,(void*)&data); + ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event); } } +} - virtual void scrollViewDidZoom(ScrollView* view) +void LuaScrollView::scrollViewDidZoom(ScrollView* view) +{ + LuaScrollView* luaView = dynamic_cast(view); + if (NULL != luaView) { - LuaScrollView* luaView = dynamic_cast(view); - if (NULL != luaView) + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)luaView, ScriptHandlerMgr::kScrollViewZoomHandler); + if (0 != handler) { - int nHandler = luaView->getScriptHandler(LuaScrollView::kScrollViewScriptZoom); - if (0 != nHandler) - { - CommonScriptData data(nHandler,""); - ScriptEvent event(kCommonEvent,(void*)&data); - ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event); - } + CommonScriptData data(handler,""); + ScriptEvent event(kCommonEvent,(void*)&data); + ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event); } } - - void initLuaScrollView() - { - _mapScriptHandler.clear(); - } - - enum ScrollViewScriptHandlerType - { - kScrollViewScriptScroll = 0, - kScrollViewScriptZoom, - }; - - void registerScriptHandler(int nFunID,ScrollViewScriptHandlerType scriptHandlerType) - { - unregisterScriptHandler(scriptHandlerType); - _mapScriptHandler[scriptHandlerType] = nFunID; - } - - void unregisterScriptHandler(ScrollViewScriptHandlerType scriptHandlerType) - { - std::map::iterator Iter = _mapScriptHandler.find(scriptHandlerType); - - if (_mapScriptHandler.end() != Iter) - { - _mapScriptHandler.erase(Iter); - } - } - - int getScriptHandler(ScrollViewScriptHandlerType scriptHandlerType) - { - std::map::iterator Iter = _mapScriptHandler.find(scriptHandlerType); - - if (_mapScriptHandler.end() != Iter) - return Iter->second; - return 0; - } -private: - std::map _mapScriptHandler; -}; +} + #ifdef __cplusplus static int tolua_collect_ScrollView (lua_State* tolua_S) @@ -223,7 +183,6 @@ static int tolua_Cocos2d_ScrollView_create00(lua_State* tolua_S) LuaScrollView* tolua_ret = new LuaScrollView(); if (NULL != tolua_ret && tolua_ret->initWithViewSize(size,container) ) { - tolua_ret->initLuaScrollView(); tolua_ret->autorelease(); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; @@ -260,7 +219,6 @@ static int tolua_Cocos2d_ScrollView_create01(lua_State* tolua_S) LuaScrollView* tolua_ret = new LuaScrollView(); if (NULL != tolua_ret && tolua_ret->init() ) { - tolua_ret->initLuaScrollView(); tolua_ret->autorelease(); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; @@ -1597,68 +1555,6 @@ tolua_lerror: } #endif //#ifndef TOLUA_DISABLE -/* method: registerScriptHandler of class ScrollView */ -#ifndef TOLUA_DISABLE_tolua_Cocos2d_ScrollView_registerScriptHandler00 -static int tolua_Cocos2d_ScrollView_registerScriptHandler00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"CCScrollView",0,&tolua_err) || - !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || - !tolua_isnumber(tolua_S,3,0,&tolua_err) || - !tolua_isnoobj(tolua_S,4,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - LuaScrollView* self = (LuaScrollView*) tolua_tousertype(tolua_S,1,0); - if (NULL != self ) { - int nFunID = ( toluafix_ref_function(tolua_S,2,0)); - LuaScrollView::ScrollViewScriptHandlerType handlerType = ((LuaScrollView::ScrollViewScriptHandlerType) (int) tolua_tonumber(tolua_S,3,0)); - self->registerScriptHandler(nFunID, handlerType); - } - } - return 0; -#ifndef TOLUA_RELEASE -tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: unregisterScriptHandler of class ScrollView */ -#ifndef TOLUA_DISABLE_tolua_Cocos2d_ScrollView_unregisterScriptHandler00 -static int tolua_Cocos2d_ScrollView_unregisterScriptHandler00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"CCScrollView",0,&tolua_err) || - !tolua_isnumber(tolua_S,2,0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - LuaScrollView* self = (LuaScrollView*) tolua_tousertype(tolua_S,1,0); - if (NULL != self ) { - LuaScrollView::ScrollViewScriptHandlerType handlerType = ((LuaScrollView::ScrollViewScriptHandlerType) (int) tolua_tonumber(tolua_S,2,0)); - self->unregisterScriptHandler(handlerType); - } - } - return 0; -#ifndef TOLUA_RELEASE -tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - TOLUA_API int tolua_scroll_view_open(lua_State* tolua_S) { @@ -1723,8 +1619,6 @@ TOLUA_API int tolua_scroll_view_open(lua_State* tolua_S) tolua_function(tolua_S,"setZoomScale",tolua_Cocos2d_ScrollView_setZoomScale00); tolua_function(tolua_S,"setZoomScale",tolua_Cocos2d_ScrollView_setZoomScale01); tolua_function(tolua_S, "setDelegate", tolua_Cocos2d_ScrollView_setDelegate00); - tolua_function(tolua_S, "registerScriptHandler", tolua_Cocos2d_ScrollView_registerScriptHandler00); - tolua_function(tolua_S, "unregisterScriptHandler", tolua_Cocos2d_ScrollView_unregisterScriptHandler00); tolua_endmodule(tolua_S); tolua_endmodule(tolua_S); return 1; diff --git a/scripting/lua/cocos2dx_support/LuaScrollView.h b/scripting/lua/cocos2dx_support/LuaScrollView.h index bf8f9c0ff4..e1de54c746 100644 --- a/scripting/lua/cocos2dx_support/LuaScrollView.h +++ b/scripting/lua/cocos2dx_support/LuaScrollView.h @@ -8,6 +8,21 @@ extern "C" { #ifdef __cplusplus } #endif +#include "GUI/CCScrollView/CCScrollView.h" + +class LuaScrollView:public cocos2d::extension::ScrollView,public cocos2d::extension::ScrollViewDelegate +{ +public: + virtual ~LuaScrollView(); + virtual void scrollViewDidScroll(ScrollView* view); + virtual void scrollViewDidZoom(ScrollView* view); + enum ScrollViewScriptHandlerType + { + kScrollViewScriptScroll = 0, + kScrollViewScriptZoom, + }; + +}; TOLUA_API int tolua_scroll_view_open(lua_State* tolua_S); diff --git a/scripting/lua/cocos2dx_support/Lua_web_socket.cpp b/scripting/lua/cocos2dx_support/Lua_web_socket.cpp index b94f3a5b17..ec512183f3 100644 --- a/scripting/lua/cocos2dx_support/Lua_web_socket.cpp +++ b/scripting/lua/cocos2dx_support/Lua_web_socket.cpp @@ -10,10 +10,10 @@ extern "C" { #include #include "Lua_web_socket.h" #include "cocos2d.h" -#include "WebSocket.h" #include "CCLuaStack.h" #include "CCLuaValue.h" #include "CCLuaEngine.h" +#include "LuaScriptHandlerMgr.h" using namespace cocos2d; using namespace cocos2d::extension; @@ -52,131 +52,77 @@ static int SendBinaryMessageToLua(int nHandler,const unsigned char* pTable,int n return nRet; } -class LuaWebSocket: public WebSocket,public WebSocket::Delegate + + +LuaWebSocket::~LuaWebSocket() { -public: - virtual ~LuaWebSocket() - { - this->unregisterScriptHandler(kWebSocketScriptHandlerOpen); - this->unregisterScriptHandler(kWebSocketScriptHandlerMessage); - this->unregisterScriptHandler(kWebSocketScriptHandlerClose); - this->unregisterScriptHandler(kWebSocketScriptHandlerError); - } - /* - * @brief delegate event enum,for lua register handler - */ - enum WebSocketScriptHandlerType - { - kWebSocketScriptHandlerOpen = 0, - kWebSocketScriptHandlerMessage, - kWebSocketScriptHandlerClose, - kWebSocketScriptHandlerError, - }; - /** - * @brief Add Handler of DelegateEvent - */ - void registerScriptHandler(int nFunID,WebSocketScriptHandlerType scriptHandlerType) - { - this->unregisterScriptHandler(scriptHandlerType); - _mapScriptHandler[scriptHandlerType] = nFunID; - } - /** - * @brief Remove Handler of DelegateEvent - */ - void unregisterScriptHandler(WebSocketScriptHandlerType scriptHandlerType) - { - std::map::iterator Iter = _mapScriptHandler.find(scriptHandlerType); - - if (_mapScriptHandler.end() != Iter) - { - _mapScriptHandler.erase(Iter); + ScriptHandlerMgr::getInstance()->removeObjectAllHandlers((void*)this); +} + +void LuaWebSocket::onOpen(WebSocket* ws) +{ + LuaWebSocket* luaWs = dynamic_cast(ws); + if (NULL != luaWs) { + int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::kWebSocketScriptHandlerOpen); + if (0 != nHandler) { + CommonScriptData data(nHandler,""); + ScriptEvent event(kCommonEvent,(void*)&data); + ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event); } } - /** - * @brief Get Handler By DelegateEvent Type - */ - int getScriptHandler(WebSocketScriptHandlerType scriptHandlerType) - { - std::map::iterator Iter = _mapScriptHandler.find(scriptHandlerType); - - if (_mapScriptHandler.end() != Iter) - return Iter->second; - - return 0; - } +} - void InitScriptHandleMap() - { - _mapScriptHandler.clear(); - } - - virtual void onOpen(WebSocket* ws) - { - LuaWebSocket* luaWs = dynamic_cast(ws); - if (NULL != luaWs) { - int nHandler = luaWs->getScriptHandler(LuaWebSocket::kWebSocketScriptHandlerOpen); +void LuaWebSocket::onMessage(WebSocket* ws, const WebSocket::Data& data) +{ + LuaWebSocket* luaWs = dynamic_cast(ws); + if (NULL != luaWs) { + if (data.isBinary) { + int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::kWebSocketScriptHandlerMessage); if (0 != nHandler) { - CommonScriptData data(nHandler,""); - ScriptEvent event(kCommonEvent,(void*)&data); - ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event); + SendBinaryMessageToLua(nHandler, (const unsigned char*)data.bytes, data.len); } } - } - - virtual void onMessage(WebSocket* ws, const WebSocket::Data& data) - { - LuaWebSocket* luaWs = dynamic_cast(ws); - if (NULL != luaWs) { - if (data.isBinary) { - int nHandler = luaWs->getScriptHandler(LuaWebSocket::kWebSocketScriptHandlerMessage); - if (0 != nHandler) { - SendBinaryMessageToLua(nHandler, (const unsigned char*)data.bytes, data.len); - } - } - else{ + else{ - int nHandler = luaWs->getScriptHandler(LuaWebSocket::kWebSocketScriptHandlerMessage); - if (0 != nHandler) { + int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::kWebSocketScriptHandlerMessage); + if (0 != nHandler) { CommonScriptData commonData(nHandler,data.bytes); ScriptEvent event(kCommonEvent,(void*)&commonData); ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event); - } } } } +} - virtual void onClose(WebSocket* ws) - { - LuaWebSocket* luaWs = dynamic_cast(ws); - if (NULL != luaWs) { - int nHandler = luaWs->getScriptHandler(LuaWebSocket::kWebSocketScriptHandlerClose); - if (0 != nHandler) - { - CommonScriptData data(nHandler,""); - ScriptEvent event(kCommonEvent,(void*)&data); - ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event); - } +void LuaWebSocket::onClose(WebSocket* ws) +{ + LuaWebSocket* luaWs = dynamic_cast(ws); + if (NULL != luaWs) { + int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::kWebSocketScriptHandlerClose); + if (0 != nHandler) + { + CommonScriptData data(nHandler,""); + ScriptEvent event(kCommonEvent,(void*)&data); + ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event); } } +} - virtual void onError(WebSocket* ws, const WebSocket::ErrorCode& error) - { - LuaWebSocket* luaWs = dynamic_cast(ws); - if (NULL != luaWs) { - int nHandler = luaWs->getScriptHandler(LuaWebSocket::kWebSocketScriptHandlerError); - if (0 != nHandler) - { - CommonScriptData data(nHandler,""); - ScriptEvent event(kCommonEvent,(void*)&data); - ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event); - } +void LuaWebSocket::onError(WebSocket* ws, const WebSocket::ErrorCode& error) +{ + LuaWebSocket* luaWs = dynamic_cast(ws); + if (NULL != luaWs) { + int nHandler = 0;//luaWs->getScriptHandler(LuaWebSocket::kWebSocketScriptHandlerError); + if (0 != nHandler) + { + CommonScriptData data(nHandler,""); + ScriptEvent event(kCommonEvent,(void*)&data); + ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event); } } +} + - -private: - std::map _mapScriptHandler; -}; #ifdef __cplusplus static int tolua_collect_WebSocket (lua_State* tolua_S) @@ -388,68 +334,6 @@ tolua_lerror: } #endif //#ifndef TOLUA_DISABLE -/* method: addHandlerOfDelegateEvent of class WebSocket */ -#ifndef TOLUA_DISABLE_tolua_Cocos2d_WebSocket_registerScriptHandler00 -static int tolua_Cocos2d_WebSocket_registerScriptHandler00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"WebSocket",0,&tolua_err) || - !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || - !tolua_isnumber(tolua_S,3,0,&tolua_err) || - !tolua_isnoobj(tolua_S,4,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - LuaWebSocket* self = (LuaWebSocket*) tolua_tousertype(tolua_S,1,0); - if (NULL != self ) { - int nFunID = ( toluafix_ref_function(tolua_S,2,0)); - LuaWebSocket::WebSocketScriptHandlerType handlerType = ((LuaWebSocket::WebSocketScriptHandlerType) (int) tolua_tonumber(tolua_S,3,0)); - self->registerScriptHandler(nFunID, handlerType); - } - } - return 0; -#ifndef TOLUA_RELEASE -tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: removeHandlerOfDelegateEvent of class WebSocket */ -#ifndef TOLUA_DISABLE_tolua_Cocos2d_WebSocket_unregisterScriptHandler00 -static int tolua_Cocos2d_WebSocket_unregisterScriptHandler00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"WebSocket",0,&tolua_err) || - !tolua_isnumber(tolua_S,2,0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - LuaWebSocket* self = (LuaWebSocket*) tolua_tousertype(tolua_S,1,0); - if (NULL != self ) { - LuaWebSocket::WebSocketScriptHandlerType handlerType = ((LuaWebSocket::WebSocketScriptHandlerType) (int) tolua_tonumber(tolua_S,2,0)); - self->unregisterScriptHandler(handlerType); - } - } - return 0; -#ifndef TOLUA_RELEASE -tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - /* method: sendBinaryMsg of class WebSocket */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_WebSocket_sendBinaryMsg00 static int tolua_Cocos2d_WebSocket_sendBinaryMsg00(lua_State* tolua_S) @@ -503,6 +387,7 @@ TOLUA_API int tolua_web_socket_open(lua_State* tolua_S){ tolua_constant(tolua_S,"kWebSocketScriptHandlerMessage",LuaWebSocket::kWebSocketScriptHandlerMessage); tolua_constant(tolua_S,"kWebSocketScriptHandlerClose",LuaWebSocket::kWebSocketScriptHandlerClose); tolua_constant(tolua_S,"kWebSocketScriptHandlerError",LuaWebSocket::kWebSocketScriptHandlerError); + #ifdef __cplusplus tolua_cclass(tolua_S,"WebSocket","WebSocket","",tolua_collect_WebSocket); #else @@ -515,8 +400,6 @@ TOLUA_API int tolua_web_socket_open(lua_State* tolua_S){ tolua_function(tolua_S, "getReadyState", tolua_Cocos2d_WebSocket_getReadyState00); tolua_function(tolua_S, "sendTextMsg", tolua_Cocos2d_WebSocket_sendTextMsg00); tolua_function(tolua_S, "close", tolua_Cocos2d_WebSocket_close00); - tolua_function(tolua_S, "registerScriptHandler", tolua_Cocos2d_WebSocket_registerScriptHandler00); - tolua_function(tolua_S, "unregisterScriptHandler", tolua_Cocos2d_WebSocket_unregisterScriptHandler00); tolua_function(tolua_S, "sendBinaryMsg", tolua_Cocos2d_WebSocket_sendBinaryMsg00); tolua_endmodule(tolua_S); tolua_endmodule(tolua_S); diff --git a/scripting/lua/cocos2dx_support/Lua_web_socket.h b/scripting/lua/cocos2dx_support/Lua_web_socket.h index f2a260e98e..679416508e 100644 --- a/scripting/lua/cocos2dx_support/Lua_web_socket.h +++ b/scripting/lua/cocos2dx_support/Lua_web_socket.h @@ -8,6 +8,25 @@ extern "C" { #ifdef __cplusplus } #endif +#include "WebSocket.h" + +class LuaWebSocket: public cocos2d::extension::WebSocket,public cocos2d::extension::WebSocket::Delegate +{ +public: + virtual ~LuaWebSocket(); + virtual void onOpen(WebSocket* ws); + virtual void onMessage(WebSocket* ws, const WebSocket::Data& data); + virtual void onClose(WebSocket* ws); + virtual void onError(WebSocket* ws, const WebSocket::ErrorCode& error); + + enum WebSocketScriptHandlerType + { + kWebSocketScriptHandlerOpen, + kWebSocketScriptHandlerMessage, + kWebSocketScriptHandlerClose, + kWebSocketScriptHandlerError, + }; +}; TOLUA_API int tolua_web_socket_open(lua_State* tolua_S); From 56419b9e90d0e32677e6276141fcb65d5a04b166 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 17 Jul 2013 12:53:30 +0800 Subject: [PATCH 07/31] issue #2410: [Android] Adding listener for CCDrawNode when application resume from background. Reset the order of reloading shaders and textures in main.cpp. --- cocos2dx/draw_nodes/CCDrawNode.cpp | 31 ++++++++++++++----- cocos2dx/draw_nodes/CCDrawNode.h | 4 +++ .../particle_nodes/CCParticleSystemQuad.cpp | 4 +-- cocos2dx/shaders/CCGLProgram.cpp | 2 +- cocos2dx/shaders/ccGLStateCache.cpp | 4 +++ cocos2dx/textures/CCTextureAtlas.cpp | 4 +-- .../proj.android/jni/hellocpp/main.cpp | 3 +- .../proj.android/jni/hellocpp/main.cpp | 3 +- .../proj.android/jni/hellocpp/main.cpp | 3 +- .../proj.android/jni/hellocpp/main.cpp | 3 +- .../proj.android/jni/hellocpp/main.cpp | 3 +- .../proj.android/jni/hellocpp/main.cpp | 3 +- .../TestCpp/proj.android/jni/testcpp/main.cpp | 3 +- .../proj.android/jni/cocosdragonjs/main.cpp | 3 +- .../proj.android/jni/crystalcraze/main.cpp | 3 +- .../proj.android/jni/moonwarriors/main.cpp | 3 +- .../proj.android/jni/testjavascript/main.cpp | 3 +- .../jni/watermelonwithme/main.cpp | 3 +- .../proj.android/jni/hellolua/main.cpp | 3 +- .../TestLua/proj.android/jni/testlua/main.cpp | 3 +- .../proj.android/jni/hellocpp/main.cpp | 3 +- .../proj.android/jni/hellojavascript/main.cpp | 3 +- .../proj.android/jni/hellolua/main.cpp | 3 +- 23 files changed, 51 insertions(+), 49 deletions(-) diff --git a/cocos2dx/draw_nodes/CCDrawNode.cpp b/cocos2dx/draw_nodes/CCDrawNode.cpp index 50a99ad086..ab715e48ac 100644 --- a/cocos2dx/draw_nodes/CCDrawNode.cpp +++ b/cocos2dx/draw_nodes/CCDrawNode.cpp @@ -23,6 +23,8 @@ #include "CCDrawNode.h" #include "shaders/CCShaderCache.h" #include "CCGL.h" +#include "support/CCNotificationCenter.h" +#include "CCEventType.h" NS_CC_BEGIN @@ -118,6 +120,8 @@ DrawNode::~DrawNode() ccGLBindVAO(0); _vao = 0; #endif + + NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); } DrawNode* DrawNode::create() @@ -157,18 +161,17 @@ bool DrawNode::init() glGenVertexArrays(1, &_vao); ccGLBindVAO(_vao); #endif - + glGenBuffers(1, &_vbo); glBindBuffer(GL_ARRAY_BUFFER, _vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)* _bufferCapacity, _buffer, GL_STREAM_DRAW); - glEnableVertexAttribArray(kVertexAttrib_Position); + ccGLEnableVertexAttribs( kVertexAttribFlag_PosColorTex ); + glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices)); - glEnableVertexAttribArray(kVertexAttrib_Color); glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); - glEnableVertexAttribArray(kVertexAttrib_TexCoords); glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -181,6 +184,12 @@ bool DrawNode::init() _dirty = true; + // Need to listen the event only when not use batchnode, because it will use VBO + NotificationCenter::getInstance()->addObserver(this, + callfuncO_selector(DrawNode::listenBackToForeground), + EVNET_COME_TO_FOREGROUND, + NULL); + return true; } @@ -196,6 +205,7 @@ void DrawNode::render() ccGLBindVAO(_vao); #else ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex); + glBindBuffer(GL_ARRAY_BUFFER, _vbo); // vertex glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices)); @@ -216,11 +226,9 @@ void DrawNode::render() void DrawNode::draw() { + CC_NODE_DRAW_SETUP(); ccGLBlendFunc(_blendFunc.src, _blendFunc.dst); - - getShaderProgram()->use(); - getShaderProgram()->setUniformsForBuiltins(); - + render(); } @@ -440,4 +448,11 @@ void DrawNode::setBlendFunc(const BlendFunc &blendFunc) _blendFunc = blendFunc; } +/** listen the event that coming to foreground on Android + */ +void DrawNode::listenBackToForeground(Object *obj) +{ + init(); +} + NS_CC_END diff --git a/cocos2dx/draw_nodes/CCDrawNode.h b/cocos2dx/draw_nodes/CCDrawNode.h index 3c74e56e5e..70bebf186d 100644 --- a/cocos2dx/draw_nodes/CCDrawNode.h +++ b/cocos2dx/draw_nodes/CCDrawNode.h @@ -79,6 +79,10 @@ public: DrawNode(); + /** listen the event that coming to foreground on Android + */ + void listenBackToForeground(Object *obj); + private: void ensureCapacity(unsigned int count); void render(); diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp index 9503ab8d63..1a9345401f 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp @@ -483,16 +483,14 @@ void ParticleSystemQuad::setupVBOandVAO() glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _totalParticles, _quads, GL_DYNAMIC_DRAW); + ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex); // vertices - glEnableVertexAttribArray(kVertexAttrib_Position); glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); // colors - glEnableVertexAttribArray(kVertexAttrib_Color); glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); // tex coords - glEnableVertexAttribArray(kVertexAttrib_TexCoords); glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); diff --git a/cocos2dx/shaders/CCGLProgram.cpp b/cocos2dx/shaders/CCGLProgram.cpp index a525687e31..1a44724e29 100644 --- a/cocos2dx/shaders/CCGLProgram.cpp +++ b/cocos2dx/shaders/CCGLProgram.cpp @@ -241,7 +241,7 @@ bool GLProgram::link() _vertShader = _fragShader = 0; -#if DEBUG +#if COCOS2D_DEBUG glGetProgramiv(_program, GL_LINK_STATUS, &status); if (status == GL_FALSE) diff --git a/cocos2dx/shaders/ccGLStateCache.cpp b/cocos2dx/shaders/ccGLStateCache.cpp index 74a83097a7..549719f652 100644 --- a/cocos2dx/shaders/ccGLStateCache.cpp +++ b/cocos2dx/shaders/ccGLStateCache.cpp @@ -76,7 +76,11 @@ void ccGLInvalidateStateCache( void ) s_eBlendingSource = -1; s_eBlendingDest = -1; s_eGLServerState = 0; +#if CC_TEXTURE_ATLAS_USE_VAO + s_uVAO = 0; #endif + +#endif // CC_ENABLE_GL_STATE_CACHE } void ccGLDeleteProgram( GLuint program ) diff --git a/cocos2dx/textures/CCTextureAtlas.cpp b/cocos2dx/textures/CCTextureAtlas.cpp index 222532a96a..59e3486a12 100644 --- a/cocos2dx/textures/CCTextureAtlas.cpp +++ b/cocos2dx/textures/CCTextureAtlas.cpp @@ -255,16 +255,14 @@ void TextureAtlas::setupVBOandVAO() glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _capacity, _quads, GL_DYNAMIC_DRAW); + ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex); // vertices - glEnableVertexAttribArray(kVertexAttrib_Position); glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); // colors - glEnableVertexAttribArray(kVertexAttrib_Color); glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); // tex coords - glEnableVertexAttribArray(kVertexAttrib_TexCoords); glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); diff --git a/plugin/samples/HelloAnalytics-JS/proj.android/jni/hellocpp/main.cpp b/plugin/samples/HelloAnalytics-JS/proj.android/jni/hellocpp/main.cpp index d602be8273..26a98e22fe 100644 --- a/plugin/samples/HelloAnalytics-JS/proj.android/jni/hellocpp/main.cpp +++ b/plugin/samples/HelloAnalytics-JS/proj.android/jni/hellocpp/main.cpp @@ -34,10 +34,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); ccGLInvalidateStateCache(); - ShaderCache::getInstance()->reloadDefaultShaders(); + ccDrawInit(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/plugin/samples/HelloIAP-JS/proj.android/jni/hellocpp/main.cpp b/plugin/samples/HelloIAP-JS/proj.android/jni/hellocpp/main.cpp index d602be8273..26a98e22fe 100644 --- a/plugin/samples/HelloIAP-JS/proj.android/jni/hellocpp/main.cpp +++ b/plugin/samples/HelloIAP-JS/proj.android/jni/hellocpp/main.cpp @@ -34,10 +34,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); ccGLInvalidateStateCache(); - ShaderCache::getInstance()->reloadDefaultShaders(); + ccDrawInit(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/plugin/samples/HelloPlugins/proj.android/jni/hellocpp/main.cpp b/plugin/samples/HelloPlugins/proj.android/jni/hellocpp/main.cpp index 8c0ced20a8..5a68d26107 100644 --- a/plugin/samples/HelloPlugins/proj.android/jni/hellocpp/main.cpp +++ b/plugin/samples/HelloPlugins/proj.android/jni/hellocpp/main.cpp @@ -33,10 +33,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); ccGLInvalidateStateCache(); - ShaderCache::getInstance()->reloadDefaultShaders(); + ccDrawInit(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Cpp/AssetsManagerTest/proj.android/jni/hellocpp/main.cpp b/samples/Cpp/AssetsManagerTest/proj.android/jni/hellocpp/main.cpp index 4c4ff0ded1..ac6f58ba07 100644 --- a/samples/Cpp/AssetsManagerTest/proj.android/jni/hellocpp/main.cpp +++ b/samples/Cpp/AssetsManagerTest/proj.android/jni/hellocpp/main.cpp @@ -30,10 +30,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); ccGLInvalidateStateCache(); - ShaderCache::getInstance()->reloadDefaultShaders(); + ccDrawInit(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Cpp/HelloCpp/proj.android/jni/hellocpp/main.cpp b/samples/Cpp/HelloCpp/proj.android/jni/hellocpp/main.cpp index 47292fa901..7d495c10a1 100644 --- a/samples/Cpp/HelloCpp/proj.android/jni/hellocpp/main.cpp +++ b/samples/Cpp/HelloCpp/proj.android/jni/hellocpp/main.cpp @@ -32,10 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); ccGLInvalidateStateCache(); - ShaderCache::getInstance()->reloadDefaultShaders(); + ccDrawInit(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Cpp/SimpleGame/proj.android/jni/hellocpp/main.cpp b/samples/Cpp/SimpleGame/proj.android/jni/hellocpp/main.cpp index a48824a8ac..e8639bcc2d 100644 --- a/samples/Cpp/SimpleGame/proj.android/jni/hellocpp/main.cpp +++ b/samples/Cpp/SimpleGame/proj.android/jni/hellocpp/main.cpp @@ -32,10 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); ccGLInvalidateStateCache(); - ShaderCache::getInstance()->reloadDefaultShaders(); + ccDrawInit(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Cpp/TestCpp/proj.android/jni/testcpp/main.cpp b/samples/Cpp/TestCpp/proj.android/jni/testcpp/main.cpp index 112914f998..e503aab97c 100644 --- a/samples/Cpp/TestCpp/proj.android/jni/testcpp/main.cpp +++ b/samples/Cpp/TestCpp/proj.android/jni/testcpp/main.cpp @@ -32,10 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); ccGLInvalidateStateCache(); - ShaderCache::getInstance()->reloadDefaultShaders(); + ccDrawInit(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Javascript/CocosDragonJS/proj.android/jni/cocosdragonjs/main.cpp b/samples/Javascript/CocosDragonJS/proj.android/jni/cocosdragonjs/main.cpp index 61ccd4a230..1f5171ccb1 100644 --- a/samples/Javascript/CocosDragonJS/proj.android/jni/cocosdragonjs/main.cpp +++ b/samples/Javascript/CocosDragonJS/proj.android/jni/cocosdragonjs/main.cpp @@ -32,10 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); ccGLInvalidateStateCache(); - ShaderCache::getInstance()->reloadDefaultShaders(); + ccDrawInit(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Javascript/CrystalCraze/proj.android/jni/crystalcraze/main.cpp b/samples/Javascript/CrystalCraze/proj.android/jni/crystalcraze/main.cpp index 61ccd4a230..1f5171ccb1 100644 --- a/samples/Javascript/CrystalCraze/proj.android/jni/crystalcraze/main.cpp +++ b/samples/Javascript/CrystalCraze/proj.android/jni/crystalcraze/main.cpp @@ -32,10 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); ccGLInvalidateStateCache(); - ShaderCache::getInstance()->reloadDefaultShaders(); + ccDrawInit(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Javascript/MoonWarriors/proj.android/jni/moonwarriors/main.cpp b/samples/Javascript/MoonWarriors/proj.android/jni/moonwarriors/main.cpp index 61ccd4a230..1f5171ccb1 100644 --- a/samples/Javascript/MoonWarriors/proj.android/jni/moonwarriors/main.cpp +++ b/samples/Javascript/MoonWarriors/proj.android/jni/moonwarriors/main.cpp @@ -32,10 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); ccGLInvalidateStateCache(); - ShaderCache::getInstance()->reloadDefaultShaders(); + ccDrawInit(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Javascript/TestJavascript/proj.android/jni/testjavascript/main.cpp b/samples/Javascript/TestJavascript/proj.android/jni/testjavascript/main.cpp index 61ccd4a230..1f5171ccb1 100644 --- a/samples/Javascript/TestJavascript/proj.android/jni/testjavascript/main.cpp +++ b/samples/Javascript/TestJavascript/proj.android/jni/testjavascript/main.cpp @@ -32,10 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); ccGLInvalidateStateCache(); - ShaderCache::getInstance()->reloadDefaultShaders(); + ccDrawInit(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Javascript/WatermelonWithMe/proj.android/jni/watermelonwithme/main.cpp b/samples/Javascript/WatermelonWithMe/proj.android/jni/watermelonwithme/main.cpp index 61ccd4a230..1f5171ccb1 100644 --- a/samples/Javascript/WatermelonWithMe/proj.android/jni/watermelonwithme/main.cpp +++ b/samples/Javascript/WatermelonWithMe/proj.android/jni/watermelonwithme/main.cpp @@ -32,10 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); ccGLInvalidateStateCache(); - ShaderCache::getInstance()->reloadDefaultShaders(); + ccDrawInit(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Lua/HelloLua/proj.android/jni/hellolua/main.cpp b/samples/Lua/HelloLua/proj.android/jni/hellolua/main.cpp index 3abc83ff7c..51516c9603 100644 --- a/samples/Lua/HelloLua/proj.android/jni/hellolua/main.cpp +++ b/samples/Lua/HelloLua/proj.android/jni/hellolua/main.cpp @@ -31,10 +31,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); ccGLInvalidateStateCache(); - ShaderCache::getInstance()->reloadDefaultShaders(); + ccDrawInit(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Lua/TestLua/proj.android/jni/testlua/main.cpp b/samples/Lua/TestLua/proj.android/jni/testlua/main.cpp index 54c7a4b8c8..e503aab97c 100644 --- a/samples/Lua/TestLua/proj.android/jni/testlua/main.cpp +++ b/samples/Lua/TestLua/proj.android/jni/testlua/main.cpp @@ -32,10 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); ccGLInvalidateStateCache(); - ShaderCache::getInstance()->reloadDefaultShaders(); + ccDrawInit(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/template/multi-platform-cpp/proj.android/jni/hellocpp/main.cpp b/template/multi-platform-cpp/proj.android/jni/hellocpp/main.cpp index 112914f998..e503aab97c 100644 --- a/template/multi-platform-cpp/proj.android/jni/hellocpp/main.cpp +++ b/template/multi-platform-cpp/proj.android/jni/hellocpp/main.cpp @@ -32,10 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); ccGLInvalidateStateCache(); - ShaderCache::getInstance()->reloadDefaultShaders(); + ccDrawInit(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/template/multi-platform-js/proj.android/jni/hellojavascript/main.cpp b/template/multi-platform-js/proj.android/jni/hellojavascript/main.cpp index 61ccd4a230..1f5171ccb1 100644 --- a/template/multi-platform-js/proj.android/jni/hellojavascript/main.cpp +++ b/template/multi-platform-js/proj.android/jni/hellojavascript/main.cpp @@ -32,10 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); ccGLInvalidateStateCache(); - ShaderCache::getInstance()->reloadDefaultShaders(); + ccDrawInit(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/template/multi-platform-lua/proj.android/jni/hellolua/main.cpp b/template/multi-platform-lua/proj.android/jni/hellolua/main.cpp index 54c7a4b8c8..e503aab97c 100644 --- a/template/multi-platform-lua/proj.android/jni/hellolua/main.cpp +++ b/template/multi-platform-lua/proj.android/jni/hellolua/main.cpp @@ -32,10 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); ccGLInvalidateStateCache(); - ShaderCache::getInstance()->reloadDefaultShaders(); + ccDrawInit(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); From 7b51599cbdaeec42bceb6b8265b0e4e8493db4e3 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 17 Jul 2013 12:55:27 +0800 Subject: [PATCH 08/31] closed #2410: Fixing a bug that loading a wrong texture in ShaderCache::loadDefaultShaders. This could fix DrawNode displays nothing when resume. --- cocos2dx/shaders/CCShaderCache.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2dx/shaders/CCShaderCache.cpp b/cocos2dx/shaders/CCShaderCache.cpp index e2129a94a7..1fe685885e 100644 --- a/cocos2dx/shaders/CCShaderCache.cpp +++ b/cocos2dx/shaders/CCShaderCache.cpp @@ -219,7 +219,7 @@ void ShaderCache::reloadDefaultShaders() // p = programForKey(kShader_PositionLengthTexureColor); p->reset(); - loadDefaultShader(p, kShaderType_Position_uColor); + loadDefaultShader(p, kShaderType_PositionLengthTexureColor); } void ShaderCache::loadDefaultShader(GLProgram *p, int type) @@ -297,7 +297,7 @@ void ShaderCache::loadDefaultShader(GLProgram *p, int type) GLProgram* ShaderCache::programForKey(const char* key) { - return (GLProgram*)_programs->objectForKey(key); + return static_cast(_programs->objectForKey(key)); } void ShaderCache::addProgram(GLProgram* program, const char* key) From 3018f5b3d79b3848446ac489b6a216b168ce60fb Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 17 Jul 2013 13:43:27 +0800 Subject: [PATCH 09/31] issue #2377:Adjust some function places. --- scripting/lua/cocos2dx_support/CCLuaEngine.h | 12 +++++------- scripting/lua/cocos2dx_support/Lua_web_socket.h | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/scripting/lua/cocos2dx_support/CCLuaEngine.h b/scripting/lua/cocos2dx_support/CCLuaEngine.h index 6cb8b651e2..beacf42d49 100644 --- a/scripting/lua/cocos2dx_support/CCLuaEngine.h +++ b/scripting/lua/cocos2dx_support/CCLuaEngine.h @@ -121,6 +121,11 @@ public: virtual int sendEvent(ScriptEvent* message); void extendLuaObject(); private: + LuaEngine(void) + : _stack(NULL) + { + } + bool init(void); int handleNodeEvent(void* data); int handleMenuClickedEvent(void* data); int handleNotificationEvent(void* data); @@ -139,13 +144,6 @@ private: void extendGLNode(lua_State* lua_S); void extendScrollView(lua_State* lua_S); private: - LuaEngine(void) - : _stack(NULL) - { - } - - bool init(void); - static LuaEngine* _defaultEngine; LuaStack *_stack; }; diff --git a/scripting/lua/cocos2dx_support/Lua_web_socket.h b/scripting/lua/cocos2dx_support/Lua_web_socket.h index 679416508e..adfcc41c50 100644 --- a/scripting/lua/cocos2dx_support/Lua_web_socket.h +++ b/scripting/lua/cocos2dx_support/Lua_web_socket.h @@ -8,7 +8,7 @@ extern "C" { #ifdef __cplusplus } #endif -#include "WebSocket.h" +#include "network/WebSocket.h" class LuaWebSocket: public cocos2d::extension::WebSocket,public cocos2d::extension::WebSocket::Delegate { From 209392085c2f7f40cc49640c2a5f9e997c784c50 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 17 Jul 2013 13:53:16 +0800 Subject: [PATCH 10/31] issue #2410: Reverting some changes about VAO. And adding CC_ENABLE_CACHE_TEXTURE_DATA to 'EVNET_COME_TO_FOREGROUND' in DrawNode. --- cocos2dx/draw_nodes/CCDrawNode.cpp | 4 ++++ cocos2dx/particle_nodes/CCParticleSystemQuad.cpp | 11 ++++++++--- cocos2dx/textures/CCTextureAtlas.cpp | 10 ++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/cocos2dx/draw_nodes/CCDrawNode.cpp b/cocos2dx/draw_nodes/CCDrawNode.cpp index ab715e48ac..9fa3b3f8a5 100644 --- a/cocos2dx/draw_nodes/CCDrawNode.cpp +++ b/cocos2dx/draw_nodes/CCDrawNode.cpp @@ -121,7 +121,9 @@ DrawNode::~DrawNode() _vao = 0; #endif +#if CC_ENABLE_CACHE_TEXTURE_DATA NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); +#endif } DrawNode* DrawNode::create() @@ -184,11 +186,13 @@ bool DrawNode::init() _dirty = true; +#if CC_ENABLE_CACHE_TEXTURE_DATA // Need to listen the event only when not use batchnode, because it will use VBO NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(DrawNode::listenBackToForeground), EVNET_COME_TO_FOREGROUND, NULL); +#endif return true; } diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp index 1a9345401f..9d52604b88 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp @@ -65,13 +65,14 @@ bool ParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles) setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); - +#if CC_ENABLE_CACHE_TEXTURE_DATA // Need to listen the event only when not use batchnode, because it will use VBO NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(ParticleSystemQuad::listenBackToForeground), EVNET_COME_TO_FOREGROUND, NULL); - +#endif + return true; } return false; @@ -100,7 +101,9 @@ ParticleSystemQuad::~ParticleSystemQuad() #endif } +#if CC_ENABLE_CACHE_TEXTURE_DATA NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); +#endif } // implementation ParticleSystemQuad @@ -483,14 +486,16 @@ void ParticleSystemQuad::setupVBOandVAO() glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _totalParticles, _quads, GL_DYNAMIC_DRAW); - ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex); // vertices + glEnableVertexAttribArray(kVertexAttrib_Position); glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); // colors + glEnableVertexAttribArray(kVertexAttrib_Color); glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); // tex coords + glEnableVertexAttribArray(kVertexAttrib_TexCoords); glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); diff --git a/cocos2dx/textures/CCTextureAtlas.cpp b/cocos2dx/textures/CCTextureAtlas.cpp index 59e3486a12..bd0ada0de9 100644 --- a/cocos2dx/textures/CCTextureAtlas.cpp +++ b/cocos2dx/textures/CCTextureAtlas.cpp @@ -66,7 +66,9 @@ TextureAtlas::~TextureAtlas() #endif CC_SAFE_RELEASE(_texture); +#if CC_ENABLE_CACHE_TEXTURE_DATA NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); +#endif } unsigned int TextureAtlas::getTotalQuads() const @@ -176,12 +178,14 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, unsigned int capacity) memset( _quads, 0, _capacity * sizeof(V3F_C4B_T2F_Quad) ); memset( _indices, 0, _capacity * 6 * sizeof(GLushort) ); +#if CC_ENABLE_CACHE_TEXTURE_DATA // listen the event when app go to background NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(TextureAtlas::listenBackToForeground), EVNET_COME_TO_FOREGROUND, NULL); - +#endif + this->setupIndices(); #if CC_TEXTURE_ATLAS_USE_VAO @@ -255,14 +259,16 @@ void TextureAtlas::setupVBOandVAO() glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _capacity, _quads, GL_DYNAMIC_DRAW); - ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex); // vertices + glEnableVertexAttribArray(kVertexAttrib_Position); glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); // colors + glEnableVertexAttribArray(kVertexAttrib_Color); glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); // tex coords + glEnableVertexAttribArray(kVertexAttrib_TexCoords); glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); From cd136e6330c5c15ec8b0674bd301aca210d52bd2 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 17 Jul 2013 13:55:31 +0800 Subject: [PATCH 11/31] issue #2410: [Reverting] Don't use 'ccGLEnableVertexAttribs' when using VAO, use 'glEnableVertexAttribArray' instead. --- cocos2dx/draw_nodes/CCDrawNode.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cocos2dx/draw_nodes/CCDrawNode.cpp b/cocos2dx/draw_nodes/CCDrawNode.cpp index 9fa3b3f8a5..75bcd4345b 100644 --- a/cocos2dx/draw_nodes/CCDrawNode.cpp +++ b/cocos2dx/draw_nodes/CCDrawNode.cpp @@ -163,17 +163,18 @@ bool DrawNode::init() glGenVertexArrays(1, &_vao); ccGLBindVAO(_vao); #endif - + glGenBuffers(1, &_vbo); glBindBuffer(GL_ARRAY_BUFFER, _vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)* _bufferCapacity, _buffer, GL_STREAM_DRAW); - ccGLEnableVertexAttribs( kVertexAttribFlag_PosColorTex ); - + glEnableVertexAttribArray(kVertexAttrib_Position); glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices)); + glEnableVertexAttribArray(kVertexAttrib_Color); glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); + glEnableVertexAttribArray(kVertexAttrib_TexCoords); glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); glBindBuffer(GL_ARRAY_BUFFER, 0); From 7e107a884169ec4a3cd87a02d9b4196aae2ead45 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 17 Jul 2013 14:26:10 +0800 Subject: [PATCH 12/31] Update AUTHORS [ci skip] --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 9dfe6db5ac..410d8ab60c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -443,6 +443,7 @@ Developers: Explicitly initialising CCAcceleration structure. Add support to save/retrieve CCData into/from CCUserDefault. Text Shadows fix + Solving 'black screen' on android. MarcelBloemendaal Adding secureTextEntry property to CCTextFieldTTF. From 53ace33d26446744eb5e559b4e019b09c2abf25b Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 17 Jul 2013 14:32:10 +0800 Subject: [PATCH 13/31] issue #2407: Adds more readability to the class internals for 'ParallaxNode'. --- .../tilemap_parallax_nodes/CCParallaxNode.cpp | 5 ++-- .../tilemap_parallax_nodes/CCParallaxNode.h | 24 +++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.cpp b/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.cpp index ec24fd74d8..c8d6d82186 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.cpp @@ -72,14 +72,15 @@ ParallaxNode * ParallaxNode::create() return pRet; } -void ParallaxNode::addChild(Node * child, unsigned int zOrder, int tag) +void ParallaxNode::addChild(Node * child, int zOrder, int tag) { CC_UNUSED_PARAM(zOrder); CC_UNUSED_PARAM(child); CC_UNUSED_PARAM(tag); CCAssert(0,"ParallaxNode: use addChild:z:parallaxRatio:positionOffset instead"); } -void ParallaxNode::addChild(Node *child, unsigned int z, const Point& ratio, const Point& offset) + +void ParallaxNode::addChild(Node *child, int z, const Point& ratio, const Point& offset) { CCAssert( child != NULL, "Argument must be non-nil"); PointObject *obj = PointObject::pointWithPoint(ratio, offset); diff --git a/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h b/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h index 1366bdcd4f..75fb982684 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h +++ b/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h @@ -45,10 +45,10 @@ The children will be moved faster / slower than the parent according the the par */ class CC_DLL ParallaxNode : public Node { - /** array that holds the offset / ratio of the children */ - CC_SYNTHESIZE(struct _ccArray *, _parallaxArray, ParallaxArray) - public: + // Create a Parallax node + static ParallaxNode * create(); + /** Adds a child to the container with a z-order, a parallax ratio and a position offset It returns self, so you can chain several addChilds. @since v0.8 @@ -56,17 +56,21 @@ public: ParallaxNode(); virtual ~ParallaxNode(); - static ParallaxNode * create(); - virtual void addChild(Node * child, unsigned int z, const Point& parallaxRatio, const Point& positionOffset); - // super methods - virtual void addChild(Node * child, unsigned int zOrder, int tag); - virtual void removeChild(Node* child, bool cleanup); - virtual void removeAllChildrenWithCleanup(bool cleanup); - virtual void visit(void); + virtual void addChild(Node * child, int z, const Point& parallaxRatio, const Point& positionOffset); + + // + // Overrides + // + virtual void addChild(Node * child, int zOrder, int tag) override; + virtual void removeChild(Node* child, bool cleanup) override; + virtual void removeAllChildrenWithCleanup(bool cleanup) override; + virtual void visit(void) override; private: Point absolutePosition(); protected: Point _lastPosition; + /** array that holds the offset / ratio of the children */ + CC_SYNTHESIZE(struct _ccArray *, _parallaxArray, ParallaxArray) }; // end of tilemap_parallax_nodes group From b6fda7bf7ceee23088ea360a7de2ccf7c35ada9b Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 17 Jul 2013 14:32:38 +0800 Subject: [PATCH 14/31] issue #2407: Removing unused codes in Box2dTest.h --- samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.h b/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.h index 48304fa48e..d9b2edb6cd 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.h +++ b/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.h @@ -5,17 +5,6 @@ #include "Box2D/Box2D.h" #include "../testBasic.h" -class PhysicsSprite : public Sprite -{ -public: - PhysicsSprite(); - void setPhysicsBody(b2Body * body); - virtual bool isDirty(void); - virtual AffineTransform nodeToParentTransform(void); -private: - b2Body* _body; // strong ref -}; - class Box2DTestLayer : public Layer { Texture2D* _spriteTexture; // weak ref From c31e8a8afccfe7038db52300f32dec124db559fe Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 17 Jul 2013 14:33:15 +0800 Subject: [PATCH 15/31] issue #2407: Updating SpriteTest.cpp, Don't hide virtual override function. --- .../TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id index b47473e929..2e0ea9daa3 100644 --- a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -31da76f078d1058b703cd45135e59ad906994e9b \ No newline at end of file +963dd3732308b99e5251cb07db6e2260d3574e29 \ No newline at end of file From 7e4e34d9924cf5912e3b5290473df661d7d764f5 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 17 Jul 2013 14:36:10 +0800 Subject: [PATCH 16/31] [ci skip]Update cocos2dx.ini, don't genergate bindings for DrawNode::listenBackToForeground. --- tools/tojs/cocos2dx.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index b14151893b..85b0435fc6 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -43,7 +43,7 @@ skip = Node::[^setPosition$ getGrid setGLServerState description getUserObject . ParticleBatchNode::[getBlendFunc setBlendFunc], LayerColor::[getBlendFunc setBlendFunc], ParticleSystem::[getBlendFunc setBlendFunc], - DrawNode::[getBlendFunc setBlendFunc drawPolygon], + DrawNode::[getBlendFunc setBlendFunc drawPolygon listenBackToForeground], Director::[getAccelerometer (g|s)et.*Dispatcher getOpenGLView getProjection getClassTypeInfo], Layer.*::[didAccelerate (g|s)etBlendFunc keyPressed keyReleased], Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns], From c9f0f09dacec4475941b69ae6d8b6bac6f62f60e Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 17 Jul 2013 14:44:28 +0800 Subject: [PATCH 17/31] issue #2377:Del CallFunc and CallFuncN handler operation and Modify LuaWebScoket linux config --- cocos2dx/actions/CCActionInstant.cpp | 53 ++----------------- cocos2dx/actions/CCActionInstant.h | 13 ----- .../lua/cocos2dx_support/Lua_web_socket.cpp | 5 ++ .../lua/cocos2dx_support/Lua_web_socket.h | 6 ++- 4 files changed, 13 insertions(+), 64 deletions(-) diff --git a/cocos2dx/actions/CCActionInstant.cpp b/cocos2dx/actions/CCActionInstant.cpp index 13eb9fe037..21eaefe38d 100644 --- a/cocos2dx/actions/CCActionInstant.cpp +++ b/cocos2dx/actions/CCActionInstant.cpp @@ -339,20 +339,6 @@ CallFunc * CallFunc::create(Object* pSelectorTarget, SEL_CallFunc selector) return NULL; } -CallFunc * CallFunc::create(int nHandler) -{ - CallFunc *pRet = new CallFunc(); - - if (pRet) { - pRet->_scriptHandler = nHandler; - pRet->autorelease(); - } - else{ - CC_SAFE_DELETE(pRet); - } - return pRet; -} - bool CallFunc::initWithFunction(const std::function &func) { _function = func; @@ -376,10 +362,6 @@ bool CallFunc::initWithTarget(Object* pSelectorTarget) { CallFunc::~CallFunc(void) { - if (_scriptHandler) - { - cocos2d::ScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptHandler(_scriptHandler); - } CC_SAFE_RELEASE(_selectorTarget); } @@ -394,10 +376,6 @@ CallFunc * CallFunc::clone() const else if( _function ){ a->initWithFunction(_function); } - else if (_scriptHandler > 0 ) { - a->_scriptHandler = cocos2d::ScriptEngineManager::sharedManager()->getScriptEngine()->reallocateScriptHandler(_scriptHandler); - } - a->autorelease(); return a; @@ -417,13 +395,9 @@ void CallFunc::update(float time) { void CallFunc::execute() { if (_callFunc) { (_selectorTarget->*_callFunc)(); - } else if( _function ) - _function(); - if (0 != _scriptHandler) { - BasicScriptData data((void*)this); - ScriptEvent event(kCallFuncEvent,(void*)&data); - ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event); - } + } else if( _function ){ + _function(); + } } // @@ -458,21 +432,6 @@ CallFuncN * CallFuncN::create(Object* pSelectorTarget, SEL_CallFuncN selector) return NULL; } -CallFuncN * CallFuncN::create(int nHandler) -{ - CallFuncN *pRet = new CallFuncN(); - - if (pRet) { - pRet->_scriptHandler = nHandler; - pRet->autorelease(); - } - else{ - CC_SAFE_DELETE(pRet); - } - return pRet; -} - - void CallFuncN::execute() { if (_callFuncN) { (_selectorTarget->*_callFuncN)(_target); @@ -480,12 +439,6 @@ void CallFuncN::execute() { else if (_functionN) { _functionN(_target); } - if (0 != _scriptHandler) - { - BasicScriptData data((void*)this,(void*)_target); - ScriptEvent event(kCallFuncEvent,(void*)&data); - ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event); - } } bool CallFuncN::initWithFunction(const std::function &func) diff --git a/cocos2dx/actions/CCActionInstant.h b/cocos2dx/actions/CCActionInstant.h index 98984ef6b9..9e2f66e73c 100644 --- a/cocos2dx/actions/CCActionInstant.h +++ b/cocos2dx/actions/CCActionInstant.h @@ -236,13 +236,9 @@ public: */ CC_DEPRECATED_ATTRIBUTE static CallFunc * create(Object* pSelectorTarget, SEL_CallFunc selector); - /** creates the action with the handler script function */ - static CallFunc * create(int nHandler); - public: CallFunc() : _selectorTarget(NULL) - , _scriptHandler(0) , _callFunc(NULL) , _function(nullptr) { @@ -276,9 +272,6 @@ public: _selectorTarget = pSel; } } - - inline int getScriptHandler() const { return _scriptHandler; }; - // // Overrides // @@ -290,8 +283,6 @@ protected: /** Target that will be called */ Object* _selectorTarget; - int _scriptHandler; - union { SEL_CallFunc _callFunc; @@ -320,10 +311,6 @@ public: @deprecated Use the std::function API instead. */ CC_DEPRECATED_ATTRIBUTE static CallFuncN * create(Object* pSelectorTarget, SEL_CallFuncN selector); - - /** creates the action with the handler script function */ - static CallFuncN * create(int nHandler); - public: CallFuncN():_functionN(nullptr){} diff --git a/scripting/lua/cocos2dx_support/Lua_web_socket.cpp b/scripting/lua/cocos2dx_support/Lua_web_socket.cpp index ec512183f3..06ff048c60 100644 --- a/scripting/lua/cocos2dx_support/Lua_web_socket.cpp +++ b/scripting/lua/cocos2dx_support/Lua_web_socket.cpp @@ -1,3 +1,6 @@ + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) + #ifdef __cplusplus extern "C" { #endif @@ -405,3 +408,5 @@ TOLUA_API int tolua_web_socket_open(lua_State* tolua_S){ tolua_endmodule(tolua_S); return 1; } + +#endif//(CC_TARGET_PLATFORM == CC_PLATFORM_IOS ... diff --git a/scripting/lua/cocos2dx_support/Lua_web_socket.h b/scripting/lua/cocos2dx_support/Lua_web_socket.h index adfcc41c50..b51b84b1da 100644 --- a/scripting/lua/cocos2dx_support/Lua_web_socket.h +++ b/scripting/lua/cocos2dx_support/Lua_web_socket.h @@ -1,6 +1,8 @@ #ifndef __LUA_WEB_SOCKET_H__ #define __LUA_WEB_SOCKET_H__ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) + #ifdef __cplusplus extern "C" { #endif @@ -8,8 +10,8 @@ extern "C" { #ifdef __cplusplus } #endif -#include "network/WebSocket.h" +#include "network/WebSocket.h" class LuaWebSocket: public cocos2d::extension::WebSocket,public cocos2d::extension::WebSocket::Delegate { public: @@ -30,4 +32,6 @@ public: TOLUA_API int tolua_web_socket_open(lua_State* tolua_S); +#endif //(CC_TARGET_PLATFORM == CC_PLATFORM_IOS ... + #endif //__LUA_WEB_SOCKET_H__ From 8cc8d56ed25c6106613cad7238b9c5f7ea4aa5c5 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 17 Jul 2013 06:53:49 +0000 Subject: [PATCH 18/31] [AUTO] : updating submodule reference to latest autogenerated bindings --- scripting/javascript/bindings/generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripting/javascript/bindings/generated b/scripting/javascript/bindings/generated index 6f8b3fcb81..0882041bad 160000 --- a/scripting/javascript/bindings/generated +++ b/scripting/javascript/bindings/generated @@ -1 +1 @@ -Subproject commit 6f8b3fcb81a96054903ab7361354a288f837b1a6 +Subproject commit 0882041badcc8b1c6441a40e7e180590f4eb8e3d From f4edc7a9226405b348e948cd101d4e7d57bc97cf Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 17 Jul 2013 16:25:13 +0800 Subject: [PATCH 19/31] closed #2413: Warning fixes for overload virtual functions. --- .../project.pbxproj.REMOVED.git-id | 2 +- cocos2dx/actions/CCActionGrid.h | 2 +- cocos2dx/actions/CCActionGrid3D.h | 2 +- cocos2dx/actions/CCActionInstant.h | 10 +++++----- cocos2dx/actions/CCActionInterval.h | 6 +++--- cocos2dx/actions/CCActionTiledGrid.h | 14 +++++++------- cocos2dx/layers_scenes_transitions_nodes/CCLayer.h | 8 ++++---- .../layers_scenes_transitions_nodes/CCTransition.h | 8 ++++---- .../CCTransitionPageTurn.h | 2 +- cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h | 2 +- cocos2dx/touch_dispatcher/CCTouchHandler.h | 4 ++-- .../TestCpp/Classes/ActionsTest/ActionsTest.cpp | 4 ++-- .../Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h | 2 +- .../EffectsAdvancedTest/EffectsAdvancedTest.cpp | 2 +- .../project.pbxproj.REMOVED.git-id | 2 +- 15 files changed, 35 insertions(+), 35 deletions(-) diff --git a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 7e2a12a92c..3b81da810d 100644 --- a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -1ab0fd6fdad74af8ce054c089d8571a05a7a04d8 \ No newline at end of file +62276b5bbca4f4c7b09fa6f3eab9d01aaa7a8372 \ No newline at end of file diff --git a/cocos2dx/actions/CCActionGrid.h b/cocos2dx/actions/CCActionGrid.h index f42d43dfd8..cb58b954b6 100644 --- a/cocos2dx/actions/CCActionGrid.h +++ b/cocos2dx/actions/CCActionGrid.h @@ -52,7 +52,7 @@ public: virtual void startWithTarget(Node *pTarget); /** initializes the action with size and duration */ - virtual bool initWithDuration(float duration, const Size& gridSize); + bool initWithDuration(float duration, const Size& gridSize); /** returns the grid */ virtual GridBase* getGrid(void); diff --git a/cocos2dx/actions/CCActionGrid3D.h b/cocos2dx/actions/CCActionGrid3D.h index 20cf8c3638..dc355c79c8 100644 --- a/cocos2dx/actions/CCActionGrid3D.h +++ b/cocos2dx/actions/CCActionGrid3D.h @@ -68,7 +68,7 @@ class CC_DLL FlipX3D : public Grid3DAction { public: /** initializes the action with duration */ - virtual bool initWithDuration(float duration); + bool initWithDuration(float duration); virtual bool initWithSize(const Size& gridSize, float duration); /** returns a new clone of the action */ diff --git a/cocos2dx/actions/CCActionInstant.h b/cocos2dx/actions/CCActionInstant.h index 98984ef6b9..0d0b662c16 100644 --- a/cocos2dx/actions/CCActionInstant.h +++ b/cocos2dx/actions/CCActionInstant.h @@ -250,14 +250,14 @@ public: virtual ~CallFunc(); /** initializes the action with the callback - typedef void (Object::*SEL_CallFunc)(); + @deprecated Use the std::function API instead. */ - virtual bool initWithTarget(Object* pSelectorTarget); + CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Object* pSelectorTarget); /** initializes the action with the std::function */ - virtual bool initWithFunction(const std::function& func); + bool initWithFunction(const std::function& func); /** executes the callback */ virtual void execute(); @@ -329,14 +329,14 @@ public: /** initializes the action with the std::function */ - virtual bool initWithFunction(const std::function& func); + bool initWithFunction(const std::function& func); /** initializes the action with the callback typedef void (Object::*SEL_CallFuncN)(Node*); @deprecated Use the std::function API instead. */ - CC_DEPRECATED_ATTRIBUTE virtual bool initWithTarget(Object* pSelectorTarget, SEL_CallFuncN selector); + CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Object* pSelectorTarget, SEL_CallFuncN selector); virtual long getClassTypeInfo() { static const long id = cocos2d::getHashCodeByString(typeid(cocos2d::CallFunc).name()); diff --git a/cocos2dx/actions/CCActionInterval.h b/cocos2dx/actions/CCActionInterval.h index f32d617f86..623fa0604c 100644 --- a/cocos2dx/actions/CCActionInterval.h +++ b/cocos2dx/actions/CCActionInterval.h @@ -266,7 +266,7 @@ public: /** initializes the action */ bool initWithDuration(float fDuration, float fDeltaAngle); - virtual bool initWithDuration(float fDuration, float fDeltaAngleX, float fDeltaAngleY); + bool initWithDuration(float fDuration, float fDeltaAngleX, float fDeltaAngleY); // // Overrides @@ -378,7 +378,7 @@ public: static SkewTo* create(float t, float sx, float sy); SkewTo(); - virtual bool initWithDuration(float t, float sx, float sy); + bool initWithDuration(float t, float sx, float sy); // // Overrides @@ -408,7 +408,7 @@ public: /** creates the action */ static SkewBy* create(float t, float deltaSkewX, float deltaSkewY); - virtual bool initWithDuration(float t, float sx, float sy); + bool initWithDuration(float t, float sx, float sy); // // Overrides diff --git a/cocos2dx/actions/CCActionTiledGrid.h b/cocos2dx/actions/CCActionTiledGrid.h index 543f3de110..d6bdcf8998 100644 --- a/cocos2dx/actions/CCActionTiledGrid.h +++ b/cocos2dx/actions/CCActionTiledGrid.h @@ -39,7 +39,7 @@ class CC_DLL ShakyTiles3D : public TiledGrid3DAction { public: /** initializes the action with a range, whether or not to shake Z vertices, a grid size, and duration */ - virtual bool initWithDuration(float duration, const Size& gridSize, int nRange, bool bShakeZ); + bool initWithDuration(float duration, const Size& gridSize, int nRange, bool bShakeZ); /** returns a new clone of the action */ virtual ShakyTiles3D* clone() const; @@ -61,7 +61,7 @@ class CC_DLL ShatteredTiles3D : public TiledGrid3DAction { public: /** initializes the action with a range, whether or not to shatter Z vertices, a grid size and duration */ - virtual bool initWithDuration(float duration, const Size& gridSize, int nRange, bool bShatterZ); + bool initWithDuration(float duration, const Size& gridSize, int nRange, bool bShatterZ); /** returns a new clone of the action */ virtual ShatteredTiles3D* clone() const; @@ -87,7 +87,7 @@ class CC_DLL ShuffleTiles : public TiledGrid3DAction public: ~ShuffleTiles(void); /** initializes the action with a random seed, the grid size and the duration */ - virtual bool initWithDuration(float duration, const Size& gridSize, unsigned int seed); + bool initWithDuration(float duration, const Size& gridSize, unsigned int seed); void shuffle(unsigned int *pArray, unsigned int nLen); Size getDelta(const Size& pos) const; void placeTile(const Point& pos, Tile *t); @@ -189,7 +189,7 @@ class CC_DLL TurnOffTiles : public TiledGrid3DAction public: ~TurnOffTiles(void); /** initializes the action with a random seed, the grid size and the duration */ - virtual bool initWithDuration(float duration, const Size& gridSize, unsigned int seed); + bool initWithDuration(float duration, const Size& gridSize, unsigned int seed); void shuffle(unsigned int *pArray, unsigned int nLen); void turnOnTile(const Point& pos); void turnOffTile(const Point& pos); @@ -226,7 +226,7 @@ public: inline void setAmplitudeRate(float fAmplitudeRate) { _amplitudeRate = fAmplitudeRate; } /** initializes the action with a number of waves, the waves amplitude, the grid size and the duration */ - virtual bool initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude); + bool initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude); /** returns a new clone of the action */ virtual WavesTiles3D* clone() const; @@ -279,7 +279,7 @@ class CC_DLL SplitRows : public TiledGrid3DAction { public : /** initializes the action with the number of rows to split and the duration */ - virtual bool initWithDuration(float duration, unsigned int nRows); + bool initWithDuration(float duration, unsigned int nRows); /** returns a new clone of the action */ virtual SplitRows* clone() const; @@ -301,7 +301,7 @@ class CC_DLL SplitCols : public TiledGrid3DAction { public: /** initializes the action with the number of columns to split and the duration */ - virtual bool initWithDuration(float duration, unsigned int nCols); + bool initWithDuration(float duration, unsigned int nCols); /** returns a new clone of the action */ virtual SplitCols* clone() const; diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index 182d73c050..fa27d05baf 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -237,9 +237,9 @@ public: virtual bool init(); /** initializes a Layer with color, width and height in Points */ - virtual bool initWithColor(const Color4B& color, GLfloat width, GLfloat height); + bool initWithColor(const Color4B& color, GLfloat width, GLfloat height); /** initializes a Layer with color. Width and height are the window size. */ - virtual bool initWithColor(const Color4B& color); + bool initWithColor(const Color4B& color); /** change width in Points*/ void changeWidth(GLfloat w); @@ -300,10 +300,10 @@ public: virtual bool init(); /** Initializes the Layer with a gradient between start and end. */ - virtual bool initWithColor(const Color4B& start, const Color4B& end); + bool initWithColor(const Color4B& start, const Color4B& end); /** Initializes the Layer with a gradient between start and end in the direction of v. */ - virtual bool initWithColor(const Color4B& start, const Color4B& end, const Point& v); + bool initWithColor(const Color4B& start, const Color4B& end, const Point& v); /** Whether or not the interpolation will be compressed in order to display all the colors of the gradient both in canonical and non canonical vectors Default: YES diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h index b8f75d46ac..cdc318c8d7 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h @@ -88,7 +88,7 @@ public: virtual ~TransitionScene(); /** initializes a transition with duration and incoming scene */ - virtual bool initWithDuration(float t,Scene* scene); + bool initWithDuration(float t,Scene* scene); /** called after the transition finishes */ void finish(void); @@ -131,7 +131,7 @@ public: virtual ~TransitionSceneOriented(); /** initializes a transition with duration and incoming scene */ - virtual bool initWithDuration(float t,Scene* scene,tOrientation orientation); + bool initWithDuration(float t,Scene* scene,tOrientation orientation); protected: tOrientation _orientation; @@ -468,12 +468,12 @@ public: virtual ~TransitionFade(); /** initializes the transition with a duration and with an RGB color */ - virtual bool initWithDuration(float t, Scene*scene ,const Color3B& color); + bool initWithDuration(float t, Scene*scene ,const Color3B& color); // // Overrides // - virtual bool initWithDuration(float t,Scene* scene); + bool initWithDuration(float t,Scene* scene); virtual void onEnter(); virtual void onExit(); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h index 1aebc5367c..88aa87c387 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h @@ -64,7 +64,7 @@ public: * If back is true then the effect is reversed to appear as if the incoming * scene is being turned from left over the outgoing scene. */ - virtual bool initWithDuration(float t,Scene* scene,bool backwards); + bool initWithDuration(float t,Scene* scene,bool backwards); ActionInterval* actionWithSize(const Size& vector); diff --git a/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h b/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h index 75fb982684..53cddeaf9d 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h +++ b/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h @@ -56,7 +56,7 @@ public: ParallaxNode(); virtual ~ParallaxNode(); - virtual void addChild(Node * child, int z, const Point& parallaxRatio, const Point& positionOffset); + void addChild(Node * child, int z, const Point& parallaxRatio, const Point& positionOffset); // // Overrides diff --git a/cocos2dx/touch_dispatcher/CCTouchHandler.h b/cocos2dx/touch_dispatcher/CCTouchHandler.h index a1dd77f219..6068c6e692 100644 --- a/cocos2dx/touch_dispatcher/CCTouchHandler.h +++ b/cocos2dx/touch_dispatcher/CCTouchHandler.h @@ -60,7 +60,7 @@ public: void setEnalbedSelectors(int nValue); /** initializes a TouchHandler with a delegate and a priority */ - virtual bool initWithDelegate(TouchDelegate *pDelegate, int nPriority); + bool initWithDelegate(TouchDelegate *pDelegate, int nPriority); public: /** allocates a TouchHandler with a delegate and a priority */ @@ -79,7 +79,7 @@ class CC_DLL StandardTouchHandler : public TouchHandler { public: /** initializes a TouchHandler with a delegate and a priority */ - virtual bool initWithDelegate(TouchDelegate *pDelegate, int nPriority); + bool initWithDelegate(TouchDelegate *pDelegate, int nPriority); public: /** allocates a TouchHandler with a delegate and a priority */ diff --git a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp index 0a0eccf9f9..3e2cf0e2d0 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp @@ -836,7 +836,7 @@ void ActionCallFuncND::onEnter() auto action = Sequence::create( MoveBy::create(2.0f, Point(200,0)), - CallFuncN::create( CC_CALLBACK_1(ActionCallFuncND::removeFromParentAndCleanup, this, true)), + CallFuncN::create( CC_CALLBACK_1(ActionCallFuncND::doRemoveFromParentAndCleanup, this, true)), NULL); _grossini->runAction(action); @@ -852,7 +852,7 @@ std::string ActionCallFuncND::subtitle() return "simulates CallFuncND with std::bind()"; } -void ActionCallFuncND::removeFromParentAndCleanup(Node* pSender, bool cleanup) +void ActionCallFuncND::doRemoveFromParentAndCleanup(Node* pSender, bool cleanup) { _grossini->removeFromParentAndCleanup(cleanup); } diff --git a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h index 1e70ea8fed..737e1f5502 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h +++ b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h @@ -249,7 +249,7 @@ public: virtual void onEnter(); virtual std::string title(); virtual std::string subtitle(); - void removeFromParentAndCleanup(Node* pSender, bool cleanup); + void doRemoveFromParentAndCleanup(Node* pSender, bool cleanup); }; class ActionCallFuncO : public ActionsDemo diff --git a/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp b/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp index 55ecfe63db..ae70564183 100644 --- a/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp +++ b/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp @@ -132,7 +132,7 @@ public: _lens3D->setPosition(var); } - virtual const Point& getPosition() + virtual const Point& getPosition() const { return _lens3D->getPosition(); } diff --git a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id index 1f88181731..a25441c987 100644 --- a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -4d44263fa75a5a31d1d0b09aad082e691f1391d2 \ No newline at end of file +4a829fc84c7a38d95e536c8a26b4822bff188701 \ No newline at end of file From 844734189642af70c84edc722c808c333a0f0bd8 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 17 Jul 2013 16:40:31 +0800 Subject: [PATCH 20/31] issue #2377: Modify LuaWebScoket linux compile error --- scripting/lua/cocos2dx_support/CCLuaEngine.cpp | 2 ++ scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp | 2 ++ scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.h | 2 ++ 3 files changed, 6 insertions(+) diff --git a/scripting/lua/cocos2dx_support/CCLuaEngine.cpp b/scripting/lua/cocos2dx_support/CCLuaEngine.cpp index 8a55027563..3a9fae18b8 100644 --- a/scripting/lua/cocos2dx_support/CCLuaEngine.cpp +++ b/scripting/lua/cocos2dx_support/CCLuaEngine.cpp @@ -659,6 +659,7 @@ void LuaEngine::extendControl(lua_State* lua_S) void LuaEngine::extendWebsocket(lua_State* lua_S) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) if (NULL == lua_S) return; @@ -673,6 +674,7 @@ void LuaEngine::extendWebsocket(lua_State* lua_S) lua_pushcfunction(lua_S,tolua_Cocos2d_WebSocket_unregisterScriptHandler00); lua_rawset(lua_S,-3); } +#endif } void LuaEngine::extendGLNode(lua_State* lua_S) diff --git a/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp b/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp index 8bd237f9fb..aeb7aca9c8 100644 --- a/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp +++ b/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp @@ -521,6 +521,7 @@ tolua_lerror: #endif } +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) int tolua_Cocos2d_WebSocket_registerScriptHandler00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE @@ -577,6 +578,7 @@ tolua_lerror: return 0; #endif } +#endif int tolua_Cocos2d_GLNode_registerScriptDrawHandler00(lua_State* tolua_S) { diff --git a/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.h b/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.h index 0a173bdc26..c66d5e03ea 100644 --- a/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.h +++ b/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.h @@ -129,8 +129,10 @@ TOLUA_API int tolua_Cocos2d_unregisterScriptAccelerateHandler00(lua_State* tolua TOLUA_API int tolua_Cocos2d_registerControlEventHandler00(lua_State* tolua_S); TOLUA_API int tolua_Cocos2d_unregisterControlEventHandler00(lua_State* tolua_S); +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) TOLUA_API int tolua_Cocos2d_WebSocket_registerScriptHandler00(lua_State* tolua_S); TOLUA_API int tolua_Cocos2d_WebSocket_unregisterScriptHandler00(lua_State* tolua_S); +#endif TOLUA_API int tolua_Cocos2d_GLNode_registerScriptDrawHandler00(lua_State* tolua_S); TOLUA_API int tolua_Cocos2d_GLNode_unregisterScriptDrawHandler00(lua_State* tolua_S); From a9eea0a8875bbd70e346726fd8de7167b6511b46 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 17 Jul 2013 17:38:03 +0800 Subject: [PATCH 21/31] issue #2407: Updating jsb_deprecated.js and cocos2dx.ini. --- .../javascript/bindings/js/jsb_deprecated.js | 20 +++++++++++++++++++ tools/tojs/cocos2dx.ini | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/scripting/javascript/bindings/js/jsb_deprecated.js b/scripting/javascript/bindings/js/jsb_deprecated.js index 10fe20cd43..058c13cdc4 100644 --- a/scripting/javascript/bindings/js/jsb_deprecated.js +++ b/scripting/javascript/bindings/js/jsb_deprecated.js @@ -25,4 +25,24 @@ var cc = cc || {}; return cc.Animation.prototype.clone.apply(this, arguments); }; + cc.Node.prototype.nodeToWorldTransform = function() { + logW("cc.Node.nodeToWorldTransform", "cc.Node.getNodeToWorldTransform"); + return cc.Node.prototype.getNodeToWorldTransform.apply(this, arguments); + }; + + cc.Node.prototype.nodeToParentTransform = function() { + logW("cc.Node.nodeToParentTransform", "cc.Node.getNodeToParentTransform"); + return cc.Node.prototype.getNodeToParentTransform.apply(this, arguments); + }; + + cc.Node.prototype.worldToNodeTransform = function() { + logW("cc.Node.worldToNodeTransform", "cc.Node.getWorldToNodeTransform"); + return cc.Node.prototype.getWorldToNodeTransform.apply(this, arguments); + }; + + cc.Node.prototype.parentToNodeTransform = function() { + logW("cc.Node.parentToNodeTransform", "cc.Node.getParentToNodeTransform"); + return cc.Node.prototype.getParentToNodeTransform.apply(this, arguments); + }; + })(); diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index 85b0435fc6..aa049283ce 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -113,7 +113,7 @@ rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames sp LayerGradient::[initWithColor=init], LayerColor::[initWithColor=init], GLProgram::[fragmentShaderLog=getFragmentShaderLog initWithVertexShaderByteArray=initWithString initWithVertexShaderFilename=init programLog=getProgramLog setUniformLocationWith1i=setUniformLocationI32 vertexShaderLog=getVertexShaderLog], - Node::[boundingBox=getBoundingBox removeFromParentAndCleanup=removeFromParent removeAllChildrenWithCleanup=removeAllChildren], + Node::[removeFromParentAndCleanup=removeFromParent removeAllChildrenWithCleanup=removeAllChildren], LabelAtlas::[create=_create], TMXLayer::[tileAt=getTileAt tileGIDAt=getTileGIDAt propertyNamed=getProperty positionAt=getPositionAt], TileMapAtlas::[tileAt=getTileAt], From e8777b87226a9f4d8709600dedffdd4f8a4de300 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 17 Jul 2013 09:46:49 +0000 Subject: [PATCH 22/31] [AUTO] : updating submodule reference to latest autogenerated bindings --- scripting/javascript/bindings/generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripting/javascript/bindings/generated b/scripting/javascript/bindings/generated index 0882041bad..45f4ad294f 160000 --- a/scripting/javascript/bindings/generated +++ b/scripting/javascript/bindings/generated @@ -1 +1 @@ -Subproject commit 0882041badcc8b1c6441a40e7e180590f4eb8e3d +Subproject commit 45f4ad294f5936f93e4982210740ff65f74c08e8 From d58a7fcce248d7923aa614933d0c78f75b25b5a5 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 17 Jul 2013 18:09:49 +0800 Subject: [PATCH 23/31] closed #2414: Bindings-generator could bind std::function argument now. --- tools/bindings-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bindings-generator b/tools/bindings-generator index 6612820da6..69bd274bd5 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 6612820da6286ffb45ddaec16b75f1624624b88c +Subproject commit 69bd274bd551d22e198afa5fca782fb520dcfad7 From 9c36d3072e3b0409a570376da81c2906c881f0a1 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 17 Jul 2013 18:12:43 +0800 Subject: [PATCH 24/31] Update AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 410d8ab60c..4073bd5ef7 100644 --- a/AUTHORS +++ b/AUTHORS @@ -528,6 +528,7 @@ Developers: Sam Gross (colesbury) Ignoring formatting specifiers in JavaScript log messages. + Make bindings-generator supports to bind std::function argument. James Munro (jdmunro) Added JSB support for ccpDistanceSQ. From 2523e7746b06277f8225c642eae97917825b0607 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 17 Jul 2013 10:21:56 +0000 Subject: [PATCH 25/31] [AUTO] : updating submodule reference to latest autogenerated bindings --- scripting/javascript/bindings/generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripting/javascript/bindings/generated b/scripting/javascript/bindings/generated index 45f4ad294f..8445d4412d 160000 --- a/scripting/javascript/bindings/generated +++ b/scripting/javascript/bindings/generated @@ -1 +1 @@ -Subproject commit 45f4ad294f5936f93e4982210740ff65f74c08e8 +Subproject commit 8445d4412d1548a509f42976ce9e96d5ac6f49a3 From 469e13607a65a6bfb101e22975bf839928018042 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 18 Jul 2013 13:38:23 +0800 Subject: [PATCH 26/31] issue #2404: Marking CC prefix class as deprecated. --- cocos2dx/include/CCDeprecated.h | 461 +++++++++++++++++++++++++++++++- cocos2dx/include/cocos2d.h | 5 +- 2 files changed, 461 insertions(+), 5 deletions(-) diff --git a/cocos2dx/include/CCDeprecated.h b/cocos2dx/include/CCDeprecated.h index 92e691e888..1543c3abcb 100644 --- a/cocos2dx/include/CCDeprecated.h +++ b/cocos2dx/include/CCDeprecated.h @@ -32,7 +32,6 @@ #include "cocoa/CCGeometry.h" #include "ccTypes.h" - NS_CC_BEGIN /** @@ -391,13 +390,13 @@ CC_DEPRECATED_ATTRIBUTE inline Rect CCRectMake(float x, float y, float width, fl } -CC_DEPRECATED_ATTRIBUTE const Point PointZero = Point::ZERO; +CC_DEPRECATED_ATTRIBUTE const Point CCPointZero = Point::ZERO; /* The "zero" size -- equivalent to Size(0, 0). */ -CC_DEPRECATED_ATTRIBUTE const Size SizeZero = Size::ZERO; +CC_DEPRECATED_ATTRIBUTE const Size CCSizeZero = Size::ZERO; /* The "zero" rectangle -- equivalent to Rect(0, 0, 0, 0). */ -CC_DEPRECATED_ATTRIBUTE const Rect RectZero = Rect::ZERO; +CC_DEPRECATED_ATTRIBUTE const Rect CCRectZero = Rect::ZERO; CC_DEPRECATED_ATTRIBUTE const Color3B ccWHITE = Color3B::WHITE; @@ -454,6 +453,460 @@ CC_DEPRECATED_ATTRIBUTE static inline bool ccc4FEqual(Color4F a, Color4F b) return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a; } +CC_DEPRECATED_ATTRIBUTE static inline Vertex2F vertex2(const float x, const float y) +{ + Vertex2F c(x, y); + return c; +} + +CC_DEPRECATED_ATTRIBUTE static inline Vertex3F vertex3(const float x, const float y, const float z) +{ + Vertex3F c(x, y, z); + return c; +} + +CC_DEPRECATED_ATTRIBUTE static inline Tex2F tex2(const float u, const float v) +{ + Tex2F t(u , v); + return t; +} + +#define CCAffineTransformMake AffineTransformMake +#define CCPointApplyAffineTransform PointApplyAffineTransform +#define CCSizeApplyAffineTransform SizeApplyAffineTransform + +CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformMakeIdentity() +{ + return AffineTransformMakeIdentity(); +} + +CC_DEPRECATED_ATTRIBUTE static inline Rect CCRectApplyAffineTransform(const Rect& rect, const AffineTransform& anAffineTransform) +{ + return RectApplyAffineTransform(rect, anAffineTransform); +} + +CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformTranslate(const AffineTransform& t, float tx, float ty) +{ + return AffineTransformTranslate(t, tx, ty); +} + +CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformRotate(const AffineTransform& aTransform, float anAngle) +{ + return AffineTransformRotate(aTransform, anAngle); +} + +CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformScale(const AffineTransform& t, float sx, float sy) +{ + return AffineTransformScale(t, sx, sy); +} + +CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformConcat(const AffineTransform& t1, const AffineTransform& t2) +{ + return AffineTransformConcat(t1, t2); +} + +CC_DEPRECATED_ATTRIBUTE static inline bool CCAffineTransformEqualToTransform(const AffineTransform& t1, const AffineTransform& t2) +{ + return AffineTransformEqualToTransform(t1, t2); +} + +CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformInvert(const AffineTransform& t) +{ + return AffineTransformInvert(t); +} + +#define CCAffineTransformIdentity AffineTransformIdentity + + +// CC prefix compatibility +CC_DEPRECATED_ATTRIBUTE typedef Object CCObject; +CC_DEPRECATED_ATTRIBUTE typedef Event CCEvent; +CC_DEPRECATED_ATTRIBUTE typedef Integer CCInteger; +CC_DEPRECATED_ATTRIBUTE typedef String CCString; +CC_DEPRECATED_ATTRIBUTE typedef Bool CCBool; +CC_DEPRECATED_ATTRIBUTE typedef Float CCFloat; +CC_DEPRECATED_ATTRIBUTE typedef Double CCDouble; +CC_DEPRECATED_ATTRIBUTE typedef Data CCData; +CC_DEPRECATED_ATTRIBUTE typedef Set CCSet; +CC_DEPRECATED_ATTRIBUTE typedef Array CCArray; +CC_DEPRECATED_ATTRIBUTE typedef Dictionary CCDictionary; +CC_DEPRECATED_ATTRIBUTE typedef DataVisitor CCDataVisitor; +CC_DEPRECATED_ATTRIBUTE typedef PrettyPrinter CCPrettyPrinter; +CC_DEPRECATED_ATTRIBUTE typedef Acceleration CCAcceleration; +CC_DEPRECATED_ATTRIBUTE typedef TextureAtlas CCTextureAtlas; +CC_DEPRECATED_ATTRIBUTE typedef Configuration CCConfiguration; +CC_DEPRECATED_ATTRIBUTE typedef PointArray CCPointArray; +CC_DEPRECATED_ATTRIBUTE typedef SetIterator CCSetIterator; +CC_DEPRECATED_ATTRIBUTE typedef RemoveSelf CCRemoveSelf; +CC_DEPRECATED_ATTRIBUTE typedef IMEDelegate CCIMEDelegate; +CC_DEPRECATED_ATTRIBUTE typedef IMEKeyboardNotificationInfo CCIMEKeyboardNotificationInfo; +CC_DEPRECATED_ATTRIBUTE typedef TextFieldDelegate CCTextFieldDelegate; +CC_DEPRECATED_ATTRIBUTE typedef TextFieldTTF CCTextFieldTTF; +CC_DEPRECATED_ATTRIBUTE typedef NotificationCenter CCNotificationCenter; +CC_DEPRECATED_ATTRIBUTE typedef TargetedTouchDelegate CCTargetedTouchDelegate; +CC_DEPRECATED_ATTRIBUTE typedef StandardTouchDelegate CCStandardTouchDelegate; +CC_DEPRECATED_ATTRIBUTE typedef TouchDelegate CCTouchDelegate; +CC_DEPRECATED_ATTRIBUTE typedef Image CCImage; +CC_DEPRECATED_ATTRIBUTE typedef UserDefault CCUserDefault; + +CC_DEPRECATED_ATTRIBUTE typedef Action CCAction; +CC_DEPRECATED_ATTRIBUTE typedef FiniteTimeAction CCFiniteTimeAction; +CC_DEPRECATED_ATTRIBUTE typedef Speed CCSpeed; +CC_DEPRECATED_ATTRIBUTE typedef Follow CCFollow; +CC_DEPRECATED_ATTRIBUTE typedef GLProgram CCGLProgram; +CC_DEPRECATED_ATTRIBUTE typedef Touch CCTouch; +CC_DEPRECATED_ATTRIBUTE typedef Set CCSet; +CC_DEPRECATED_ATTRIBUTE typedef Texture2D CCTexture2D; +CC_DEPRECATED_ATTRIBUTE typedef Node CCNode; +CC_DEPRECATED_ATTRIBUTE typedef NodeRGBA CCNodeRGBA; +CC_DEPRECATED_ATTRIBUTE typedef RGBAProtocol CCRGBAProtocol; +CC_DEPRECATED_ATTRIBUTE typedef SpriteFrame CCSpriteFrame; +CC_DEPRECATED_ATTRIBUTE typedef AnimationFrame CCAnimationFrame; +CC_DEPRECATED_ATTRIBUTE typedef Animation CCAnimation; +CC_DEPRECATED_ATTRIBUTE typedef ActionInterval CCActionInterval; +CC_DEPRECATED_ATTRIBUTE typedef Sequence CCSequence; +CC_DEPRECATED_ATTRIBUTE typedef Repeat CCRepeat; +CC_DEPRECATED_ATTRIBUTE typedef RepeatForever CCRepeatForever; +CC_DEPRECATED_ATTRIBUTE typedef Spawn CCSpawn; +CC_DEPRECATED_ATTRIBUTE typedef RotateTo CCRotateTo; +CC_DEPRECATED_ATTRIBUTE typedef RotateBy CCRotateBy; +CC_DEPRECATED_ATTRIBUTE typedef MoveBy CCMoveBy; +CC_DEPRECATED_ATTRIBUTE typedef MoveTo CCMoveTo; +CC_DEPRECATED_ATTRIBUTE typedef SkewTo CCSkewTo; +CC_DEPRECATED_ATTRIBUTE typedef SkewBy CCSkewBy; +CC_DEPRECATED_ATTRIBUTE typedef JumpBy CCJumpBy; +CC_DEPRECATED_ATTRIBUTE typedef JumpTo CCJumpTo; +CC_DEPRECATED_ATTRIBUTE typedef BezierBy CCBezierBy; +CC_DEPRECATED_ATTRIBUTE typedef BezierTo CCBezierTo; +CC_DEPRECATED_ATTRIBUTE typedef ScaleTo CCScaleTo; +CC_DEPRECATED_ATTRIBUTE typedef ScaleBy CCScaleBy; +CC_DEPRECATED_ATTRIBUTE typedef Blink CCBlink; +CC_DEPRECATED_ATTRIBUTE typedef FadeIn CCFadeIn; +CC_DEPRECATED_ATTRIBUTE typedef FadeOut CCFadeOut; +CC_DEPRECATED_ATTRIBUTE typedef FadeTo CCFadeTo; +CC_DEPRECATED_ATTRIBUTE typedef TintTo CCTintTo; +CC_DEPRECATED_ATTRIBUTE typedef TintBy CCTintBy; +CC_DEPRECATED_ATTRIBUTE typedef DelayTime CCDelayTime; +CC_DEPRECATED_ATTRIBUTE typedef Animate CCAnimate; +CC_DEPRECATED_ATTRIBUTE typedef TargetedAction CCTargetedAction; +CC_DEPRECATED_ATTRIBUTE typedef ActionCamera CCActionCamera; +CC_DEPRECATED_ATTRIBUTE typedef OrbitCamera CCOrbitCamera; +CC_DEPRECATED_ATTRIBUTE typedef ActionManager CCActionManager; +CC_DEPRECATED_ATTRIBUTE typedef ActionEase CCActionEase; +CC_DEPRECATED_ATTRIBUTE typedef EaseRateAction CCEaseRateAction; +CC_DEPRECATED_ATTRIBUTE typedef EaseIn CCEaseIn; +CC_DEPRECATED_ATTRIBUTE typedef EaseOut CCEaseOut; +CC_DEPRECATED_ATTRIBUTE typedef EaseInOut CCEaseInOut; +CC_DEPRECATED_ATTRIBUTE typedef EaseExponentialIn CCEaseExponentialIn; +CC_DEPRECATED_ATTRIBUTE typedef EaseExponentialOut CCEaseExponentialOut; +CC_DEPRECATED_ATTRIBUTE typedef EaseExponentialInOut CCEaseExponentialInOut; +CC_DEPRECATED_ATTRIBUTE typedef EaseSineIn CCEaseSineIn; +CC_DEPRECATED_ATTRIBUTE typedef EaseSineOut CCEaseSineOut; +CC_DEPRECATED_ATTRIBUTE typedef EaseSineInOut CCEaseSineInOut; +CC_DEPRECATED_ATTRIBUTE typedef EaseElastic CCEaseElastic; +CC_DEPRECATED_ATTRIBUTE typedef EaseElasticIn CCEaseElasticIn; +CC_DEPRECATED_ATTRIBUTE typedef EaseElasticOut CCEaseElasticOut; +CC_DEPRECATED_ATTRIBUTE typedef EaseElasticInOut CCEaseElasticInOut; +CC_DEPRECATED_ATTRIBUTE typedef EaseBounce CCEaseBounce; +CC_DEPRECATED_ATTRIBUTE typedef EaseBounceIn CCEaseBounceIn; +CC_DEPRECATED_ATTRIBUTE typedef EaseBounceOut CCEaseBounceOut; +CC_DEPRECATED_ATTRIBUTE typedef EaseBounceInOut CCEaseBounceInOut; +CC_DEPRECATED_ATTRIBUTE typedef EaseBackIn CCEaseBackIn; +CC_DEPRECATED_ATTRIBUTE typedef EaseBackOut CCEaseBackOut; +CC_DEPRECATED_ATTRIBUTE typedef EaseBackInOut CCEaseBackInOut; +CC_DEPRECATED_ATTRIBUTE typedef ActionInstant CCActionInstant; +CC_DEPRECATED_ATTRIBUTE typedef Show CCShow; +CC_DEPRECATED_ATTRIBUTE typedef Hide CCHide; +CC_DEPRECATED_ATTRIBUTE typedef ToggleVisibility CCToggleVisibility; +CC_DEPRECATED_ATTRIBUTE typedef FlipX CCFlipX; +CC_DEPRECATED_ATTRIBUTE typedef FlipY CCFlipY; +CC_DEPRECATED_ATTRIBUTE typedef Place CCPlace; +CC_DEPRECATED_ATTRIBUTE typedef CallFunc CCCallFunc; +CC_DEPRECATED_ATTRIBUTE typedef GridAction CCGridAction; +CC_DEPRECATED_ATTRIBUTE typedef Grid3DAction CCGrid3DAction; +CC_DEPRECATED_ATTRIBUTE typedef TiledGrid3DAction CCTiledGrid3DAction; +CC_DEPRECATED_ATTRIBUTE typedef StopGrid CCStopGrid; +CC_DEPRECATED_ATTRIBUTE typedef ReuseGrid CCReuseGrid; +CC_DEPRECATED_ATTRIBUTE typedef Waves3D CCWaves3D; +CC_DEPRECATED_ATTRIBUTE typedef FlipX3D CCFlipX3D; +CC_DEPRECATED_ATTRIBUTE typedef FlipY3D CCFlipY3D; +CC_DEPRECATED_ATTRIBUTE typedef Lens3D CCLens3D; +CC_DEPRECATED_ATTRIBUTE typedef Ripple3D CCRipple3D; +CC_DEPRECATED_ATTRIBUTE typedef Shaky3D CCShaky3D; +CC_DEPRECATED_ATTRIBUTE typedef Liquid CCLiquid; +CC_DEPRECATED_ATTRIBUTE typedef Waves CCWaves; +CC_DEPRECATED_ATTRIBUTE typedef Twirl CCTwirl; +CC_DEPRECATED_ATTRIBUTE typedef PageTurn3D CCPageTurn3D; +CC_DEPRECATED_ATTRIBUTE typedef ProgressTo CCProgressTo; +CC_DEPRECATED_ATTRIBUTE typedef ProgressFromTo CCProgressFromTo; +CC_DEPRECATED_ATTRIBUTE typedef ShakyTiles3D CCShakyTiles3D; +CC_DEPRECATED_ATTRIBUTE typedef ShatteredTiles3D CCShatteredTiles3D; +CC_DEPRECATED_ATTRIBUTE typedef ShuffleTiles CCShuffleTiles; +CC_DEPRECATED_ATTRIBUTE typedef FadeOutTRTiles CCFadeOutTRTiles; +CC_DEPRECATED_ATTRIBUTE typedef FadeOutBLTiles CCFadeOutBLTiles; +CC_DEPRECATED_ATTRIBUTE typedef FadeOutUpTiles CCFadeOutUpTiles; +CC_DEPRECATED_ATTRIBUTE typedef FadeOutDownTiles CCFadeOutDownTiles; +CC_DEPRECATED_ATTRIBUTE typedef TurnOffTiles CCTurnOffTiles; +CC_DEPRECATED_ATTRIBUTE typedef WavesTiles3D CCWavesTiles3D; +CC_DEPRECATED_ATTRIBUTE typedef JumpTiles3D CCJumpTiles3D; +CC_DEPRECATED_ATTRIBUTE typedef SplitRows CCSplitRows; +CC_DEPRECATED_ATTRIBUTE typedef SplitCols CCSplitCols; +CC_DEPRECATED_ATTRIBUTE typedef ActionTween CCActionTween; +CC_DEPRECATED_ATTRIBUTE typedef CardinalSplineTo CCCardinalSplineTo; +CC_DEPRECATED_ATTRIBUTE typedef CardinalSplineBy CCCardinalSplineBy; +CC_DEPRECATED_ATTRIBUTE typedef CatmullRomTo CCCatmullRomTo; +CC_DEPRECATED_ATTRIBUTE typedef CatmullRomBy CCCatmullRomBy; +CC_DEPRECATED_ATTRIBUTE typedef AtlasNode CCAtlasNode; +CC_DEPRECATED_ATTRIBUTE typedef TextureProtocol CCTextureProtocol; +CC_DEPRECATED_ATTRIBUTE typedef BlendProtocol CCBlendProtocol; +CC_DEPRECATED_ATTRIBUTE typedef DrawNode CCDrawNode; +CC_DEPRECATED_ATTRIBUTE typedef Camera CCCamera; +CC_DEPRECATED_ATTRIBUTE typedef LabelAtlas CCLabelAtlas; +CC_DEPRECATED_ATTRIBUTE typedef LabelProtocol CCLabelProtocol; +CC_DEPRECATED_ATTRIBUTE typedef Director CCDirector; +CC_DEPRECATED_ATTRIBUTE typedef GridBase CCGridBase; +CC_DEPRECATED_ATTRIBUTE typedef Grid3D CCGrid3D; +CC_DEPRECATED_ATTRIBUTE typedef TiledGrid3D CCTiledGrid3D; +CC_DEPRECATED_ATTRIBUTE typedef Sprite CCSprite; +CC_DEPRECATED_ATTRIBUTE typedef LabelTTF CCLabelTTF; +CC_DEPRECATED_ATTRIBUTE typedef SpriteBatchNode CCSpriteBatchNode; +CC_DEPRECATED_ATTRIBUTE typedef LabelBMFont CCLabelBMFont; +CC_DEPRECATED_ATTRIBUTE typedef Layer CCLayer; +CC_DEPRECATED_ATTRIBUTE typedef TouchDelegate CCTouchDelegate; +CC_DEPRECATED_ATTRIBUTE typedef KeypadDelegate CCKeypadDelegate; +CC_DEPRECATED_ATTRIBUTE typedef LayerRGBA CCLayerRGBA; +CC_DEPRECATED_ATTRIBUTE typedef LayerColor CCLayerColor; +CC_DEPRECATED_ATTRIBUTE typedef LayerGradient CCLayerGradient; +CC_DEPRECATED_ATTRIBUTE typedef LayerMultiplex CCLayerMultiplex; +CC_DEPRECATED_ATTRIBUTE typedef Scene CCScene; +CC_DEPRECATED_ATTRIBUTE typedef TransitionEaseScene CCTransitionEaseScene; +CC_DEPRECATED_ATTRIBUTE typedef TransitionScene CCTransitionScene; +CC_DEPRECATED_ATTRIBUTE typedef TransitionSceneOriented CCTransitionSceneOriented; +CC_DEPRECATED_ATTRIBUTE typedef TransitionRotoZoom CCTransitionRotoZoom; +CC_DEPRECATED_ATTRIBUTE typedef TransitionJumpZoom CCTransitionJumpZoom; +CC_DEPRECATED_ATTRIBUTE typedef TransitionMoveInL CCTransitionMoveInL; +CC_DEPRECATED_ATTRIBUTE typedef TransitionMoveInR CCTransitionMoveInR; +CC_DEPRECATED_ATTRIBUTE typedef TransitionMoveInT CCTransitionMoveInT; +CC_DEPRECATED_ATTRIBUTE typedef TransitionMoveInB CCTransitionMoveInB; +CC_DEPRECATED_ATTRIBUTE typedef TransitionSlideInL CCTransitionSlideInL; +CC_DEPRECATED_ATTRIBUTE typedef TransitionSlideInR CCTransitionSlideInR; +CC_DEPRECATED_ATTRIBUTE typedef TransitionSlideInB CCTransitionSlideInB; +CC_DEPRECATED_ATTRIBUTE typedef TransitionSlideInT CCTransitionSlideInT; +CC_DEPRECATED_ATTRIBUTE typedef TransitionShrinkGrow CCTransitionShrinkGrow; +CC_DEPRECATED_ATTRIBUTE typedef TransitionFlipX CCTransitionFlipX; +CC_DEPRECATED_ATTRIBUTE typedef TransitionFlipY CCTransitionFlipY; +CC_DEPRECATED_ATTRIBUTE typedef TransitionFlipAngular CCTransitionFlipAngular; +CC_DEPRECATED_ATTRIBUTE typedef TransitionZoomFlipX CCTransitionZoomFlipX; +CC_DEPRECATED_ATTRIBUTE typedef TransitionZoomFlipY CCTransitionZoomFlipY; +CC_DEPRECATED_ATTRIBUTE typedef TransitionZoomFlipAngular CCTransitionZoomFlipAngular; +CC_DEPRECATED_ATTRIBUTE typedef TransitionFade CCTransitionFade; +CC_DEPRECATED_ATTRIBUTE typedef TransitionCrossFade CCTransitionCrossFade; +CC_DEPRECATED_ATTRIBUTE typedef TransitionTurnOffTiles CCTransitionTurnOffTiles; +CC_DEPRECATED_ATTRIBUTE typedef TransitionSplitCols CCTransitionSplitCols; +CC_DEPRECATED_ATTRIBUTE typedef TransitionSplitRows CCTransitionSplitRows; +CC_DEPRECATED_ATTRIBUTE typedef TransitionFadeTR CCTransitionFadeTR; +CC_DEPRECATED_ATTRIBUTE typedef TransitionFadeBL CCTransitionFadeBL; +CC_DEPRECATED_ATTRIBUTE typedef TransitionFadeUp CCTransitionFadeUp; +CC_DEPRECATED_ATTRIBUTE typedef TransitionFadeDown CCTransitionFadeDown; +CC_DEPRECATED_ATTRIBUTE typedef TransitionPageTurn CCTransitionPageTurn; +CC_DEPRECATED_ATTRIBUTE typedef TransitionProgress CCTransitionProgress; +CC_DEPRECATED_ATTRIBUTE typedef TransitionProgressRadialCCW CCTransitionProgressRadialCCW; +CC_DEPRECATED_ATTRIBUTE typedef TransitionProgressRadialCW CCTransitionProgressRadialCW; +CC_DEPRECATED_ATTRIBUTE typedef TransitionProgressHorizontal CCTransitionProgressHorizontal; +CC_DEPRECATED_ATTRIBUTE typedef TransitionProgressVertical CCTransitionProgressVertical; +CC_DEPRECATED_ATTRIBUTE typedef TransitionProgressInOut CCTransitionProgressInOut; +CC_DEPRECATED_ATTRIBUTE typedef TransitionProgressOutIn CCTransitionProgressOutIn; +CC_DEPRECATED_ATTRIBUTE typedef MenuItem CCMenuItem; +CC_DEPRECATED_ATTRIBUTE typedef MenuItemLabel CCMenuItemLabel; +CC_DEPRECATED_ATTRIBUTE typedef MenuItemAtlasFont CCMenuItemAtlasFont; +CC_DEPRECATED_ATTRIBUTE typedef MenuItemFont CCMenuItemFont; +CC_DEPRECATED_ATTRIBUTE typedef MenuItemSprite CCMenuItemSprite; +CC_DEPRECATED_ATTRIBUTE typedef MenuItemImage CCMenuItemImage; +CC_DEPRECATED_ATTRIBUTE typedef MenuItemToggle CCMenuItemToggle; +CC_DEPRECATED_ATTRIBUTE typedef Menu CCMenu; +CC_DEPRECATED_ATTRIBUTE typedef ClippingNode CCClippingNode; +CC_DEPRECATED_ATTRIBUTE typedef MotionStreak CCMotionStreak; +CC_DEPRECATED_ATTRIBUTE typedef ProgressTimer CCProgressTimer; +CC_DEPRECATED_ATTRIBUTE typedef RenderTexture CCRenderTexture; +CC_DEPRECATED_ATTRIBUTE typedef ParticleBatchNode CCParticleBatchNode; +CC_DEPRECATED_ATTRIBUTE typedef ParticleSystem CCParticleSystem; +CC_DEPRECATED_ATTRIBUTE typedef ParticleSystemQuad CCParticleSystemQuad; +CC_DEPRECATED_ATTRIBUTE typedef ParticleFire CCParticleFire; +CC_DEPRECATED_ATTRIBUTE typedef ParticleFireworks CCParticleFireworks; +CC_DEPRECATED_ATTRIBUTE typedef ParticleSun CCParticleSun; +CC_DEPRECATED_ATTRIBUTE typedef ParticleGalaxy CCParticleGalaxy; +CC_DEPRECATED_ATTRIBUTE typedef ParticleFlower CCParticleFlower; +CC_DEPRECATED_ATTRIBUTE typedef ParticleMeteor CCParticleMeteor; +CC_DEPRECATED_ATTRIBUTE typedef ParticleSpiral CCParticleSpiral; +CC_DEPRECATED_ATTRIBUTE typedef ParticleExplosion CCParticleExplosion; +CC_DEPRECATED_ATTRIBUTE typedef ParticleSmoke CCParticleSmoke; +CC_DEPRECATED_ATTRIBUTE typedef ParticleSnow CCParticleSnow; +CC_DEPRECATED_ATTRIBUTE typedef ParticleRain CCParticleRain; +CC_DEPRECATED_ATTRIBUTE typedef FileUtils CCFileUtils; +CC_DEPRECATED_ATTRIBUTE typedef Application CCApplication; +CC_DEPRECATED_ATTRIBUTE typedef ShaderCache CCShaderCache; +CC_DEPRECATED_ATTRIBUTE typedef AnimationCache CCAnimationCache; +CC_DEPRECATED_ATTRIBUTE typedef SpriteFrameCache CCSpriteFrameCache; +CC_DEPRECATED_ATTRIBUTE typedef TextureCache CCTextureCache; +CC_DEPRECATED_ATTRIBUTE typedef ParallaxNode CCParallaxNode; +CC_DEPRECATED_ATTRIBUTE typedef TMXObjectGroup CCTMXObjectGroup; +CC_DEPRECATED_ATTRIBUTE typedef TMXLayerInfo CCTMXLayerInfo; +CC_DEPRECATED_ATTRIBUTE typedef TMXTilesetInfo CCTMXTilesetInfo; +CC_DEPRECATED_ATTRIBUTE typedef TMXMapInfo CCTMXMapInfo; +CC_DEPRECATED_ATTRIBUTE typedef TMXLayer CCTMXLayer; +CC_DEPRECATED_ATTRIBUTE typedef TMXTiledMap CCTMXTiledMap; +CC_DEPRECATED_ATTRIBUTE typedef TileMapAtlas CCTileMapAtlas; +CC_DEPRECATED_ATTRIBUTE typedef Timer CCTimer; +CC_DEPRECATED_ATTRIBUTE typedef Scheduler CCScheduler; +CC_DEPRECATED_ATTRIBUTE typedef EGLView CCEGLView; + +CC_DEPRECATED_ATTRIBUTE typedef AffineTransform CCAffineTransform; +CC_DEPRECATED_ATTRIBUTE typedef Point CCPoint; +CC_DEPRECATED_ATTRIBUTE typedef Size CCSize; +CC_DEPRECATED_ATTRIBUTE typedef Rect CCRect; +CC_DEPRECATED_ATTRIBUTE typedef Color3B ccColor3B; +CC_DEPRECATED_ATTRIBUTE typedef Color4F ccColor4F; +CC_DEPRECATED_ATTRIBUTE typedef Color4B ccColor4B; +CC_DEPRECATED_ATTRIBUTE typedef Vertex2F ccVertex2F; +CC_DEPRECATED_ATTRIBUTE typedef Vertex3F ccVertex3F; +CC_DEPRECATED_ATTRIBUTE typedef Tex2F ccTex2F; +CC_DEPRECATED_ATTRIBUTE typedef PointSprite ccPointSprite; +CC_DEPRECATED_ATTRIBUTE typedef Quad2 ccQuad2; +CC_DEPRECATED_ATTRIBUTE typedef Quad3 ccQuad3; +CC_DEPRECATED_ATTRIBUTE typedef V2F_C4B_T2F ccV2F_C4B_T2F; +CC_DEPRECATED_ATTRIBUTE typedef V2F_C4F_T2F ccV2F_C4F_T2F; +CC_DEPRECATED_ATTRIBUTE typedef V3F_C4B_T2F ccV3F_C4B_T2F; +CC_DEPRECATED_ATTRIBUTE typedef V2F_C4B_T2F_Triangle ccV2F_C4B_T2F_Triangle; +CC_DEPRECATED_ATTRIBUTE typedef V2F_C4B_T2F_Quad ccV2F_C4B_T2F_Quad; +CC_DEPRECATED_ATTRIBUTE typedef V3F_C4B_T2F_Quad ccV3F_C4B_T2F_Quad; +CC_DEPRECATED_ATTRIBUTE typedef V2F_C4F_T2F_Quad ccV2F_C4F_T2F_Quad; +CC_DEPRECATED_ATTRIBUTE typedef BlendFunc ccBlendFunc; +CC_DEPRECATED_ATTRIBUTE typedef T2F_Quad ccT2F_Quad; +CC_DEPRECATED_ATTRIBUTE typedef AnimationFrameData ccAnimationFrameData; +CC_DEPRECATED_ATTRIBUTE typedef FontShadow ccFontShadow; +CC_DEPRECATED_ATTRIBUTE typedef FontStroke ccFontStroke; +CC_DEPRECATED_ATTRIBUTE typedef FontDefinition ccFontDefinition; + +CC_DEPRECATED_ATTRIBUTE typedef VerticalTextAlignment CCVerticalTextAlignment; +CC_DEPRECATED_ATTRIBUTE typedef TextAlignment CCTextAlignment; +CC_DEPRECATED_ATTRIBUTE typedef ProgressTimerType CCProgressTimerType; + +CC_DEPRECATED_ATTRIBUTE typedef void* CCZone; + +#define kCCVertexAttrib_Position kVertexAttrib_Position +#define kCCVertexAttrib_Color kVertexAttrib_Color +#define kCCVertexAttrib_TexCoords kVertexAttrib_TexCoords +#define kCCVertexAttrib_MAX kVertexAttrib_MAX + +#define kCCUniformPMatrix kUniformPMatrix +#define kCCUniformMVMatrix kUniformMVMatrix +#define kCCUniformMVPMatrix kUniformMVPMatrix +#define kCCUniformTime kUniformTime +#define kCCUniformSinTime kUniformSinTime +#define kCCUniformCosTime kUniformCosTime +#define kCCUniformRandom01 kUniformRandom01 +#define kCCUniformSampler kUniformSampler +#define kCCUniform_MAX kUniform_MAX + + +#define kCCShader_PositionTextureColor kShader_PositionTextureColor +#define kCCShader_PositionTextureColorAlphaTest kShader_PositionTextureColorAlphaTest +#define kCCShader_PositionColor kShader_PositionColor +#define kCCShader_PositionTexture kShader_PositionTexture +#define kCCShader_PositionTexture_uColor kShader_PositionTexture_uColor +#define kCCShader_PositionTextureA8Color kShader_PositionTextureA8Color +#define kCCShader_Position_uColor kShader_Position_uColor +#define kCCShader_PositionLengthTexureColor kShader_PositionLengthTexureColor + +// uniform names +#define kCCUniformPMatrix_s kUniformPMatrix_s +#define kCCUniformMVMatrix_s kUniformMVMatrix_s +#define kCCUniformMVPMatrix_s kUniformMVPMatrix_s +#define kCCUniformTime_s kUniformTime_s +#define kCCUniformSinTime_s kUniformSinTime_s +#define kCCUniformCosTime_s kUniformCosTime_s +#define kCCUniformRandom01_s kUniformRandom01_s +#define kCCUniformSampler_s kUniformSampler_s +#define kCCUniformAlphaTestValue kUniformAlphaTestValue + +// Attribute names +#define kCCAttributeNameColor kAttributeNameColor +#define kCCAttributeNamePosition kAttributeNamePosition +#define kCCAttributeNameTexCoord kAttributeNameTexCoord + +#define kCCVertexAttribFlag_None kVertexAttribFlag_None +#define kCCVertexAttribFlag_Position kVertexAttribFlag_Position +#define kCCVertexAttribFlag_Color kVertexAttribFlag_Color +#define kCCVertexAttribFlag_TexCoords kVertexAttribFlag_TexCoords +#define kCCVertexAttribFlag_PosColorTex kVertexAttribFlag_PosColorTex + +#define kCCProgressTimerTypeRadial kProgressTimerTypeRadial +#define kCCProgressTimerTypeBar kProgressTimerTypeBar + +#define kCCDirectorProjection2D kDirectorProjection2D +#define kCCDirectorProjection3D kDirectorProjection3D +#define kCCDirectorProjectionCustom kDirectorProjectionCustom +#define kCCDirectorProjectionDefault kDirectorProjectionDefault + +#define kCCVerticalTextAlignmentTop kVerticalTextAlignmentTop +#define kCCVerticalTextAlignmentCenter kVerticalTextAlignmentCenter +#define kCCVerticalTextAlignmentBottom kVerticalTextAlignmentBottom + +#define kCCTextAlignmentLeft kTextAlignmentLeft +#define kCCTextAlignmentCenter kTextAlignmentCenter +#define kCCTextAlignmentRight kTextAlignmentRight + + +#define kCCTexture2DPixelFormat_RGBA8888 kTexture2DPixelFormat_RGBA8888 +#define kCCTexture2DPixelFormat_RGB888 kTexture2DPixelFormat_RGB888 +#define kCCTexture2DPixelFormat_RGB565 kTexture2DPixelFormat_RGB565 +#define kCCTexture2DPixelFormat_A8 kTexture2DPixelFormat_A8 +#define kCCTexture2DPixelFormat_I8 kTexture2DPixelFormat_I8 +#define kCCTexture2DPixelFormat_AI88 kTexture2DPixelFormat_AI88 +#define kCCTexture2DPixelFormat_RGBA4444 kTexture2DPixelFormat_RGBA4444 +#define kCCTexture2DPixelFormat_RGB5A1 kTexture2DPixelFormat_RGB5A1 +#define kCCTexture2DPixelFormat_PVRTC4 kTexture2DPixelFormat_PVRTC4 +#define kCCTexture2DPixelFormat_PVRTC2 kTexture2DPixelFormat_PVRTC2 +#define kCCTexture2DPixelFormat_Default kTexture2DPixelFormat_Default + +#define kCCLabelAutomaticWidth kLabelAutomaticWidth + +#define kCCParticleDurationInfinity kParticleDurationInfinity +#define kCCParticleStartSizeEqualToEndSize kParticleStartSizeEqualToEndSize +#define kCCParticleStartRadiusEqualToEndRadius kParticleStartRadiusEqualToEndRadius + +#define kCCParticleModeGravity kParticleModeGravity +#define kCCParticleModeRadius kParticleModeRadius +#define kCCPositionTypeFree kPositionTypeFree +#define kCCPositionTypeRelative kPositionTypeRelative +#define kCCPositionTypeGrouped kPositionTypeGrouped + +#define kCCBlendFuncDisable kBlendFuncDisable + +#define kCCMenuHandlerPriority kMenuHandlerPriority +#define kCCMenuStateWaiting kMenuStateWaiting +#define kCCMenuStateTrackingTouch kMenuStateTrackingTouch + +#define kCCTouchesOneByOne kTouchesOneByOne +#define kCCTouchesAllAtOnce kTouchesAllAtOnce + +#define kCCImageFormatPNG kImageFormatPNG +#define kCCImageFormatJPEG kImageFormatJPEG + +#define kCCTransitionOrientationLeftOver kTransitionOrientationLeftOver +#define kCCTransitionOrientationRightOver kTransitionOrientationRightOver +#define kCCTransitionOrientationUpOver kTransitionOrientationUpOver +#define kCCTransitionOrientationDownOver kTransitionOrientationDownOver + +#define kCCPrioritySystem kPrioritySystem +#define kCCPriorityNonSystemMin kPriorityNonSystemMin + +#define kCCTMXTileHorizontalFlag kTMXTileHorizontalFlag +#define kCCTMXTileVerticalFlag kTMXTileVerticalFlag +#define kCCTMXTileDiagonalFlag kTMXTileDiagonalFlag +#define kCCFlipedAll kFlipedAll +#define kCCFlippedMask kFlippedMask + // end of data_structures group /// @} diff --git a/cocos2dx/include/cocos2d.h b/cocos2dx/include/cocos2d.h index 67c003d0ff..e6842caa73 100755 --- a/cocos2dx/include/cocos2d.h +++ b/cocos2dx/include/cocos2d.h @@ -85,7 +85,7 @@ THE SOFTWARE. #include "ccConfig.h" #include "ccMacros.h" #include "ccTypes.h" -#include "CCDeprecated.h" + // kazmath #include "kazmath/include/kazmath/kazmath.h" @@ -276,6 +276,9 @@ THE SOFTWARE. #include "support/component/CCComponent.h" #include "support/component/CCComponentContainer.h" +// Deprecated include +#include "CCDeprecated.h" + NS_CC_BEGIN CC_DLL const char* cocos2dVersion(); From c1dd874b9f0b11b14947fcb0d38502ed3a2f5ee5 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 18 Jul 2013 13:39:55 +0800 Subject: [PATCH 27/31] issue #2404: Fixing wrong replace in Box2d. --- external/Box2D/Collision/Shapes/b2ChainShape.cpp | 12 ++++++------ external/Box2D/Collision/Shapes/b2EdgeShape.cpp | 10 +++++----- external/Box2D/Collision/Shapes/b2EdgeShape.h | 12 ++++++------ external/Box2D/Collision/b2CollideEdge.cpp | 12 ++++++------ external/Box2D/Dynamics/b2Fixture.cpp | 6 +++--- external/Box2D/Dynamics/b2World.cpp | 2 +- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/external/Box2D/Collision/Shapes/b2ChainShape.cpp b/external/Box2D/Collision/Shapes/b2ChainShape.cpp index a7fac63c7b..79b4304b5b 100644 --- a/external/Box2D/Collision/Shapes/b2ChainShape.cpp +++ b/external/Box2D/Collision/Shapes/b2ChainShape.cpp @@ -91,7 +91,7 @@ void b2ChainShape::GetChildEdge(b2EdgeShape* edge, int32 index) const edge->m_radius = m_radius; edge->m_vertex1 = m_vertices[index + 0]; - edge->m_Vertex2F = m_vertices[index + 1]; + edge->m_vertex2 = m_vertices[index + 1]; if (index > 0) { @@ -106,13 +106,13 @@ void b2ChainShape::GetChildEdge(b2EdgeShape* edge, int32 index) const if (index < m_count - 2) { - edge->m_Vertex3F = m_vertices[index + 2]; - edge->m_hasVertex3F = true; + edge->m_vertex3 = m_vertices[index + 2]; + edge->m_hasVertex3 = true; } else { - edge->m_Vertex3F = m_nextVertex; - edge->m_hasVertex3F = m_hasNextVertex; + edge->m_vertex3 = m_nextVertex; + edge->m_hasVertex3 = m_hasNextVertex; } } @@ -138,7 +138,7 @@ bool b2ChainShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input, } edgeShape.m_vertex1 = m_vertices[i1]; - edgeShape.m_Vertex2F = m_vertices[i2]; + edgeShape.m_vertex2 = m_vertices[i2]; return edgeShape.RayCast(output, input, xf, 0); } diff --git a/external/Box2D/Collision/Shapes/b2EdgeShape.cpp b/external/Box2D/Collision/Shapes/b2EdgeShape.cpp index 5b76ffd146..7b09e55bf4 100644 --- a/external/Box2D/Collision/Shapes/b2EdgeShape.cpp +++ b/external/Box2D/Collision/Shapes/b2EdgeShape.cpp @@ -23,9 +23,9 @@ using namespace std; void b2EdgeShape::Set(const b2Vec2& v1, const b2Vec2& v2) { m_vertex1 = v1; - m_Vertex2F = v2; + m_vertex2 = v2; m_hasVertex0 = false; - m_hasVertex3F = false; + m_hasVertex3 = false; } b2Shape* b2EdgeShape::Clone(b2BlockAllocator* allocator) const @@ -63,7 +63,7 @@ bool b2EdgeShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input, b2Vec2 d = p2 - p1; b2Vec2 v1 = m_vertex1; - b2Vec2 v2 = m_Vertex2F; + b2Vec2 v2 = m_vertex2; b2Vec2 e = v2 - v1; b2Vec2 normal(e.y, -e.x); normal.Normalize(); @@ -119,7 +119,7 @@ void b2EdgeShape::ComputeAABB(b2AABB* aabb, const b2Transform& xf, int32 childIn B2_NOT_USED(childIndex); b2Vec2 v1 = b2Mul(xf, m_vertex1); - b2Vec2 v2 = b2Mul(xf, m_Vertex2F); + b2Vec2 v2 = b2Mul(xf, m_vertex2); b2Vec2 lower = b2Min(v1, v2); b2Vec2 upper = b2Max(v1, v2); @@ -134,6 +134,6 @@ void b2EdgeShape::ComputeMass(b2MassData* massData, float32 density) const B2_NOT_USED(density); massData->mass = 0.0f; - massData->center = 0.5f * (m_vertex1 + m_Vertex2F); + massData->center = 0.5f * (m_vertex1 + m_vertex2); massData->I = 0.0f; } diff --git a/external/Box2D/Collision/Shapes/b2EdgeShape.h b/external/Box2D/Collision/Shapes/b2EdgeShape.h index 055d10eea7..6163bcbf1c 100644 --- a/external/Box2D/Collision/Shapes/b2EdgeShape.h +++ b/external/Box2D/Collision/Shapes/b2EdgeShape.h @@ -52,11 +52,11 @@ public: void ComputeMass(b2MassData* massData, float32 density) const; /// These are the edge vertices - b2Vec2 m_vertex1, m_Vertex2F; + b2Vec2 m_vertex1, m_vertex2; /// Optional adjacent vertices. These are used for smooth collision. - b2Vec2 m_vertex0, m_Vertex3F; - bool m_hasVertex0, m_hasVertex3F; + b2Vec2 m_vertex0, m_vertex3; + bool m_hasVertex0, m_hasVertex3; }; inline b2EdgeShape::b2EdgeShape() @@ -65,10 +65,10 @@ inline b2EdgeShape::b2EdgeShape() m_radius = b2_polygonRadius; m_vertex0.x = 0.0f; m_vertex0.y = 0.0f; - m_Vertex3F.x = 0.0f; - m_Vertex3F.y = 0.0f; + m_vertex3.x = 0.0f; + m_vertex3.y = 0.0f; m_hasVertex0 = false; - m_hasVertex3F = false; + m_hasVertex3 = false; } #endif diff --git a/external/Box2D/Collision/b2CollideEdge.cpp b/external/Box2D/Collision/b2CollideEdge.cpp index 3c89d09059..96ca71dccc 100644 --- a/external/Box2D/Collision/b2CollideEdge.cpp +++ b/external/Box2D/Collision/b2CollideEdge.cpp @@ -33,7 +33,7 @@ void b2CollideEdgeAndCircle(b2Manifold* manifold, // Compute circle in frame of edge b2Vec2 Q = b2MulT(xfA, b2Mul(xfB, circleB->m_p)); - b2Vec2 A = edgeA->m_vertex1, B = edgeA->m_Vertex2F; + b2Vec2 A = edgeA->m_vertex1, B = edgeA->m_vertex2; b2Vec2 e = B - A; // Barycentric coordinates @@ -96,9 +96,9 @@ void b2CollideEdgeAndCircle(b2Manifold* manifold, } // Is there an edge connected to B? - if (edgeA->m_hasVertex3F) + if (edgeA->m_hasVertex3) { - b2Vec2 B2 = edgeA->m_Vertex3F; + b2Vec2 B2 = edgeA->m_vertex3; b2Vec2 A2 = B; b2Vec2 e2 = B2 - A2; float32 v2 = b2Dot(e2, Q - A2); @@ -236,11 +236,11 @@ void b2EPCollider::Collide(b2Manifold* manifold, const b2EdgeShape* edgeA, const m_v0 = edgeA->m_vertex0; m_v1 = edgeA->m_vertex1; - m_v2 = edgeA->m_Vertex2F; - m_v3 = edgeA->m_Vertex3F; + m_v2 = edgeA->m_vertex2; + m_v3 = edgeA->m_vertex3; bool hasVertex0 = edgeA->m_hasVertex0; - bool hasVertex3F = edgeA->m_hasVertex3F; + bool hasVertex3F = edgeA->m_hasVertex3; b2Vec2 edge1 = m_v2 - m_v1; edge1.Normalize(); diff --git a/external/Box2D/Dynamics/b2Fixture.cpp b/external/Box2D/Dynamics/b2Fixture.cpp index 9ada6646c9..774a78e5bb 100644 --- a/external/Box2D/Dynamics/b2Fixture.cpp +++ b/external/Box2D/Dynamics/b2Fixture.cpp @@ -255,10 +255,10 @@ void b2Fixture::Dump(int32 bodyIndex) b2Log(" shape.m_radius = %.15lef;\n", s->m_radius); b2Log(" shape.m_vertex0.Set(%.15lef, %.15lef);\n", s->m_vertex0.x, s->m_vertex0.y); b2Log(" shape.m_vertex1.Set(%.15lef, %.15lef);\n", s->m_vertex1.x, s->m_vertex1.y); - b2Log(" shape.m_Vertex2F.Set(%.15lef, %.15lef);\n", s->m_Vertex2F.x, s->m_Vertex2F.y); - b2Log(" shape.m_Vertex3F.Set(%.15lef, %.15lef);\n", s->m_Vertex3F.x, s->m_Vertex3F.y); + b2Log(" shape.m_vertex2.Set(%.15lef, %.15lef);\n", s->m_vertex2.x, s->m_vertex2.y); + b2Log(" shape.m_vertex3.Set(%.15lef, %.15lef);\n", s->m_vertex3.x, s->m_vertex3.y); b2Log(" shape.m_hasVertex0 = bool(%d);\n", s->m_hasVertex0); - b2Log(" shape.m_hasVertex3F = bool(%d);\n", s->m_hasVertex3F); + b2Log(" shape.m_hasVertex3 = bool(%d);\n", s->m_hasVertex3); } break; diff --git a/external/Box2D/Dynamics/b2World.cpp b/external/Box2D/Dynamics/b2World.cpp index f4bab2f143..8a0aff5114 100644 --- a/external/Box2D/Dynamics/b2World.cpp +++ b/external/Box2D/Dynamics/b2World.cpp @@ -1048,7 +1048,7 @@ void b2World::DrawShape(b2Fixture* fixture, const b2Transform& xf, const b2Color { b2EdgeShape* edge = (b2EdgeShape*)fixture->GetShape(); b2Vec2 v1 = b2Mul(xf, edge->m_vertex1); - b2Vec2 v2 = b2Mul(xf, edge->m_Vertex2F); + b2Vec2 v2 = b2Mul(xf, edge->m_vertex2); m_debugDraw->DrawSegment(v1, v2, color); } break; From 6277ae191b34f8aae57904b4c506003ed5e41eec Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 18 Jul 2013 13:40:32 +0800 Subject: [PATCH 28/31] issue #2404: Removing duplicated codes in platform/mac/CCImage.mm. --- cocos2dx/platform/mac/CCImage.mm | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/cocos2dx/platform/mac/CCImage.mm b/cocos2dx/platform/mac/CCImage.mm index 0fcb71a054..10c9708113 100644 --- a/cocos2dx/platform/mac/CCImage.mm +++ b/cocos2dx/platform/mac/CCImage.mm @@ -33,6 +33,8 @@ THE SOFTWARE. #include #include +NS_CC_BEGIN + typedef struct { unsigned int height; @@ -54,28 +56,6 @@ static unsigned int nextPOT(unsigned int x) return x + 1; } -typedef enum { - kTexture2DPixelFormat_Automatic = 0, - //! 32-bit texture: RGBA8888 - kTexture2DPixelFormat_RGBA8888, - //! 24-bit texture: RGBA888 - kTexture2DPixelFormat_RGB888, - //! 16-bit texture without Alpha channel - kTexture2DPixelFormat_RGB565, - //! 8-bit textures used as masks - kTexture2DPixelFormat_A8, - //! 16-bit textures: RGBA4444 - kTexture2DPixelFormat_RGBA4444, - //! 16-bit textures: RGB5A1 - kTexture2DPixelFormat_RGB5A1, - - //! Default texture format: RGBA8888 - kTexture2DPixelFormat_Default = kTexture2DPixelFormat_RGBA8888, - - // backward compatibility stuff - -} Texture2DPixelFormat; - static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POTWide, NSUInteger POTHigh, tImageInfo *pImageInfo) { NSUInteger i; @@ -481,7 +461,6 @@ static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlig return bRet; } -NS_CC_BEGIN static bool _enabledScale = true; From 8176f2f178cf7a606e7abc63bcbeff67014c3b6c Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 18 Jul 2013 14:48:18 +0800 Subject: [PATCH 29/31] issue #2404: Fixing wrong replacement of shape.m_Vertex2F. shape.m_Vertex2F --> shape.m_vertex2 --- .../Classes/Box2DTestBed/Tests/DumpShell.h | 24 +++++++++---------- .../Classes/Box2DTestBed/Tests/EdgeTest.h | 20 ++++++++-------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/Box2DTestBed/Tests/DumpShell.h b/samples/Cpp/TestCpp/Classes/Box2DTestBed/Tests/DumpShell.h index 6e3039842d..c87a9ca33a 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTestBed/Tests/DumpShell.h +++ b/samples/Cpp/TestCpp/Classes/Box2DTestBed/Tests/DumpShell.h @@ -140,10 +140,10 @@ b2Joint** joints = (b2Joint**)b2Alloc(2 * sizeof(b2Joint*)); shape.m_radius = 9.999999776482582e-03f; shape.m_vertex0.Set(0.000000000000000e+00f, 0.000000000000000e+00f); shape.m_vertex1.Set(4.452173995971680e+01f, 1.669565200805664e+01f); - shape.m_Vertex2F.Set(4.452173995971680e+01f, 0.000000000000000e+00f); - shape.m_Vertex3F.Set(0.000000000000000e+00f, 0.000000000000000e+00f); + shape.m_vertex2.Set(4.452173995971680e+01f, 0.000000000000000e+00f); + shape.m_vertex3.Set(0.000000000000000e+00f, 0.000000000000000e+00f); shape.m_hasVertex0 = bool(0); - shape.m_hasVertex3F = bool(0); + shape.m_hasVertex3 = bool(0); fd.shape = &shape; @@ -162,10 +162,10 @@ b2Joint** joints = (b2Joint**)b2Alloc(2 * sizeof(b2Joint*)); shape.m_radius = 9.999999776482582e-03f; shape.m_vertex0.Set(0.000000000000000e+00f, 0.000000000000000e+00f); shape.m_vertex1.Set(0.000000000000000e+00f, 1.669565200805664e+01f); - shape.m_Vertex2F.Set(0.000000000000000e+00f, 0.000000000000000e+00f); - shape.m_Vertex3F.Set(0.000000000000000e+00f, 0.000000000000000e+00f); + shape.m_vertex2.Set(0.000000000000000e+00f, 0.000000000000000e+00f); + shape.m_vertex3.Set(0.000000000000000e+00f, 0.000000000000000e+00f); shape.m_hasVertex0 = bool(0); - shape.m_hasVertex3F = bool(0); + shape.m_hasVertex3 = bool(0); fd.shape = &shape; @@ -184,10 +184,10 @@ b2Joint** joints = (b2Joint**)b2Alloc(2 * sizeof(b2Joint*)); shape.m_radius = 9.999999776482582e-03f; shape.m_vertex0.Set(0.000000000000000e+00f, 0.000000000000000e+00f); shape.m_vertex1.Set(0.000000000000000e+00f, 1.669565200805664e+01f); - shape.m_Vertex2F.Set(4.452173995971680e+01f, 1.669565200805664e+01f); - shape.m_Vertex3F.Set(0.000000000000000e+00f, 0.000000000000000e+00f); + shape.m_vertex2.Set(4.452173995971680e+01f, 1.669565200805664e+01f); + shape.m_vertex3.Set(0.000000000000000e+00f, 0.000000000000000e+00f); shape.m_hasVertex0 = bool(0); - shape.m_hasVertex3F = bool(0); + shape.m_hasVertex3 = bool(0); fd.shape = &shape; @@ -206,10 +206,10 @@ b2Joint** joints = (b2Joint**)b2Alloc(2 * sizeof(b2Joint*)); shape.m_radius = 9.999999776482582e-03f; shape.m_vertex0.Set(0.000000000000000e+00f, 0.000000000000000e+00f); shape.m_vertex1.Set(0.000000000000000e+00f, 0.000000000000000e+00f); - shape.m_Vertex2F.Set(4.452173995971680e+01f, 0.000000000000000e+00f); - shape.m_Vertex3F.Set(0.000000000000000e+00f, 0.000000000000000e+00f); + shape.m_vertex2.Set(4.452173995971680e+01f, 0.000000000000000e+00f); + shape.m_vertex3.Set(0.000000000000000e+00f, 0.000000000000000e+00f); shape.m_hasVertex0 = bool(0); - shape.m_hasVertex3F = bool(0); + shape.m_hasVertex3 = bool(0); fd.shape = &shape; diff --git a/samples/Cpp/TestCpp/Classes/Box2DTestBed/Tests/EdgeTest.h b/samples/Cpp/TestCpp/Classes/Box2DTestBed/Tests/EdgeTest.h index 12e4855fee..c5306beaba 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTestBed/Tests/EdgeTest.h +++ b/samples/Cpp/TestCpp/Classes/Box2DTestBed/Tests/EdgeTest.h @@ -35,36 +35,36 @@ public: b2EdgeShape shape; shape.Set(v1, v2); - shape.m_hasVertex3F = true; - shape.m_Vertex3F = v3; + shape.m_hasVertex3 = true; + shape.m_vertex3 = v3; ground->CreateFixture(&shape, 0.0f); shape.Set(v2, v3); shape.m_hasVertex0 = true; - shape.m_hasVertex3F = true; + shape.m_hasVertex3 = true; shape.m_vertex0 = v1; - shape.m_Vertex3F = v4; + shape.m_vertex3 = v4; ground->CreateFixture(&shape, 0.0f); shape.Set(v3, v4); shape.m_hasVertex0 = true; - shape.m_hasVertex3F = true; + shape.m_hasVertex3 = true; shape.m_vertex0 = v2; - shape.m_Vertex3F = v5; + shape.m_vertex3 = v5; ground->CreateFixture(&shape, 0.0f); shape.Set(v4, v5); shape.m_hasVertex0 = true; - shape.m_hasVertex3F = true; + shape.m_hasVertex3 = true; shape.m_vertex0 = v3; - shape.m_Vertex3F = v6; + shape.m_vertex3 = v6; ground->CreateFixture(&shape, 0.0f); shape.Set(v5, v6); shape.m_hasVertex0 = true; - shape.m_hasVertex3F = true; + shape.m_hasVertex3 = true; shape.m_vertex0 = v4; - shape.m_Vertex3F = v7; + shape.m_vertex3 = v7; ground->CreateFixture(&shape, 0.0f); shape.Set(v6, v7); From ca06ed4f2c3b83eaa801f804d73f196f7901762c Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Thu, 18 Jul 2013 07:38:53 +0000 Subject: [PATCH 30/31] [AUTO] : updating submodule reference to latest autogenerated bindings --- scripting/javascript/bindings/generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripting/javascript/bindings/generated b/scripting/javascript/bindings/generated index 8445d4412d..6453df8b93 160000 --- a/scripting/javascript/bindings/generated +++ b/scripting/javascript/bindings/generated @@ -1 +1 @@ -Subproject commit 8445d4412d1548a509f42976ce9e96d5ac6f49a3 +Subproject commit 6453df8b93b5d3f8b14fce0a84102bc0cbf97b02 From 11daa0f7697fae5a490ec53ce2080e3fd5c24fa3 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Thu, 18 Jul 2013 09:53:56 +0000 Subject: [PATCH 31/31] [AUTO] : updating submodule reference to latest autogenerated bindings --- scripting/javascript/bindings/generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripting/javascript/bindings/generated b/scripting/javascript/bindings/generated index 6453df8b93..940dd71e0e 160000 --- a/scripting/javascript/bindings/generated +++ b/scripting/javascript/bindings/generated @@ -1 +1 @@ -Subproject commit 6453df8b93b5d3f8b14fce0a84102bc0cbf97b02 +Subproject commit 940dd71e0e43fad42a00ae6fb5cdf5c20e7c0bbf