From 591d15c2a15eafeec72babccbf5c1a45b7aeec17 Mon Sep 17 00:00:00 2001 From: Ed Bartley Date: Wed, 5 Sep 2012 15:12:03 -0400 Subject: [PATCH 001/181] CCscrollView screenPos also needs to be adjusted by the scale in order to be used with Retina display. --- extensions/GUI/CCScrollView/CCScrollView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index 992408e495..7535905443 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -498,7 +498,7 @@ void CCScrollView::beforeDraw() CCDirector *director = CCDirector::sharedDirector(); s *= director->getContentScaleFactor(); - glScissor((GLint)screenPos.x, (GLint)screenPos.y, (GLsizei)(m_tViewSize.width*s), (GLsizei)(m_tViewSize.height*s)); + glScissor((GLint)screenPos.x*s, (GLint)screenPos.y*s, (GLsizei)(m_tViewSize.width*s), (GLsizei)(m_tViewSize.height*s)); } } From a392b171827f4bf96d954e7153c75173bb0ddfd3 Mon Sep 17 00:00:00 2001 From: Ed Bartley Date: Fri, 7 Sep 2012 13:14:22 -0400 Subject: [PATCH 002/181] MAC project is missing the header search path to /include --- .../proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id index 086c31b353..c3870bbc75 100644 --- a/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -e78f546d2199a6e37906db590c8a47033f3febd8 \ No newline at end of file +e5c62ad91fe1348bab31e77c3c5c0fac8421bcdf \ No newline at end of file From 5deeb3f8fa64c9b83e5940c9a52fd455124bafa1 Mon Sep 17 00:00:00 2001 From: ebartley Date: Fri, 7 Sep 2012 15:00:21 -0400 Subject: [PATCH 003/181] Update windows project files: Paths should be referenced from the $(ProjectDir) so that devs using a custom .sln that references the existing .vcxproj files in the cocos2d-x repo can use them without errors. --- cocos2dx/proj.win32/cocos2d.vcxproj | 6 +++--- extensions/proj.win32/libExtensions.vcxproj | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2dx/proj.win32/cocos2d.vcxproj b/cocos2dx/proj.win32/cocos2d.vcxproj index 2b3e5d8ac5..9b9698c84c 100644 --- a/cocos2dx/proj.win32/cocos2d.vcxproj +++ b/cocos2dx/proj.win32/cocos2d.vcxproj @@ -1,4 +1,4 @@ - + @@ -70,7 +70,7 @@ if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\libraries\*.*" "$(OutDir)" @@ -210,7 +210,7 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ - + diff --git a/extensions/proj.win32/libExtensions.vcxproj b/extensions/proj.win32/libExtensions.vcxproj index 179c857b6a..6ca5bc4bc4 100644 --- a/extensions/proj.win32/libExtensions.vcxproj +++ b/extensions/proj.win32/libExtensions.vcxproj @@ -51,7 +51,7 @@ Disabled - $(SolutionDir)cocos2dx;$(SolutionDir)cocos2dx\include;$(SolutionDir)cocos2dx\kazmath\include;$(SolutionDir)cocos2dx\platform\win32;$(SolutionDir)cocos2dx\platform\third_party\win32;$(SolutionDir)cocos2dx\platform\third_party\win32\pthread;$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES;..\;%(AdditionalIncludeDirectories) + $(ProjectDir)..\..\cocos2dx;$(ProjectDir)..\..\cocos2dx\include;$(ProjectDir)..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\OGLES;..\;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;_DEBUG;_LIB;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks From 4c7705171aa5f16aace9c01ef6030293c1a0539d Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Fri, 7 Sep 2012 17:23:04 -0700 Subject: [PATCH 004/181] Android JAVA refactoring. Android JNI Cleanup. --- cocos2dx/Android.mk | 8 +- cocos2dx/platform/android/CCAccelerometer.cpp | 2 +- cocos2dx/platform/android/CCApplication.cpp | 2 +- cocos2dx/platform/android/CCCommon.cpp | 4 +- cocos2dx/platform/android/CCEGLView.cpp | 3 +- cocos2dx/platform/android/CCFileUtils.cpp | 3 +- cocos2dx/platform/android/java/.classpath | 8 + cocos2dx/platform/android/java/.project | 33 ++ .../platform/android/java/AndroidManifest.xml | 9 +- cocos2dx/platform/android/java/ant.properties | 1 - .../cocos2dx/lib/Cocos2dxAccelerometer.java | 129 +++++ .../org/cocos2dx/lib/Cocos2dxActivity.java | 93 ++++ .../src/org/cocos2dx/lib/Cocos2dxBitmap.java | 420 ++++++++++++++++ .../cocos2dx/lib/Cocos2dxEditBoxDialog.java | 320 ++++++++++++ .../org/cocos2dx/lib/Cocos2dxEditText.java | 89 ++++ .../cocos2dx/lib/Cocos2dxGLSurfaceView.java | 356 ++++++++++++++ .../src/org/cocos2dx/lib/Cocos2dxHelper.java | 253 ++++++++++ .../src/org/cocos2dx/lib/Cocos2dxMusic.java | 250 ++++++++++ .../org/cocos2dx/lib/Cocos2dxRenderer.java | 162 +++++++ .../src/org/cocos2dx/lib/Cocos2dxSound.java | 263 ++++++++++ .../cocos2dx/lib/Cocos2dxTextInputWraper.java | 153 ++++++ .../org/cocos2dx/lib/Cocos2dxTypefaces.java | 71 +++ .../cocos2dx/lib/Cocos2dxAccelerometer.java | 107 ---- .../org/cocos2dx/lib/Cocos2dxActivity.java | 346 ------------- .../org/cocos2dx/lib/Cocos2dxBitmap.java | 455 ------------------ .../cocos2dx/lib/Cocos2dxEditBoxDialog.java | 338 ------------- .../org/cocos2dx/lib/Cocos2dxEditText.java | 65 --- .../cocos2dx/lib/Cocos2dxGLSurfaceView.java | 417 ---------------- .../org/cocos2dx/lib/Cocos2dxMusic.java | 228 --------- .../org/cocos2dx/lib/Cocos2dxRenderer.java | 137 ------ .../org/cocos2dx/lib/Cocos2dxSound.java | 245 ---------- .../org/cocos2dx/lib/Cocos2dxTypefaces.java | 44 -- cocos2dx/platform/android/jni/EditBoxJni.cpp | 170 ------- cocos2dx/platform/android/jni/EditBoxJni.h | 47 -- cocos2dx/platform/android/jni/IMEJni.cpp | 54 +-- cocos2dx/platform/android/jni/IMEJni.h | 6 +- ...org_cocos2dx_lib_Cocos2dxAccelerometer.cpp | 15 + .../Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp | 48 ++ .../Java_org_cocos2dx_lib_Cocos2dxHelper.cpp | 177 +++++++ ...=> Java_org_cocos2dx_lib_Cocos2dxHelper.h} | 18 +- ...Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp | 48 ++ cocos2dx/platform/android/jni/JniHelper.cpp | 22 + cocos2dx/platform/android/jni/JniHelper.h | 7 + cocos2dx/platform/android/jni/MessageJni.cpp | 141 ------ cocos2dx/platform/android/jni/MessageJni.h | 35 -- cocos2dx/platform/android/jni/SensorJni.cpp | 83 ---- .../platform/android/jni/SystemInfoJni.cpp | 91 ---- cocos2dx/platform/android/jni/SystemInfoJni.h | 36 -- cocos2dx/platform/android/jni/TouchesJni.cpp | 105 ++-- scripting/javascript/bindings/Android.mk | 2 +- .../{android => }/Android.mk | 4 +- .../{dist => }/include/ds/BitArray.h | 0 .../{dist => }/include/gc/Barrier.h | 0 .../{dist => }/include/gc/Root.h | 0 .../{dist => }/include/gc/Statistics.h | 0 .../{dist => }/include/js-config.h | 0 .../{dist => }/include/js.msg | 0 .../{dist => }/include/js/HashTable.h | 0 .../{dist => }/include/js/LegacyIntTypes.h | 0 .../{dist => }/include/js/MemoryMetrics.h | 0 .../{dist => }/include/js/TemplateLib.h | 0 .../{dist => }/include/js/Utility.h | 0 .../{dist => }/include/js/Vector.h | 0 .../{dist => }/include/jsalloc.h | 0 .../{dist => }/include/jsapi.h.REMOVED.git-id | 0 .../{dist => }/include/jsatom.h | 0 .../{dist => }/include/jsatom.tbl | 0 .../{dist => }/include/jscell.h | 0 .../{dist => }/include/jsclass.h | 0 .../{dist => }/include/jsclist.h | 0 .../{dist => }/include/jscpucfg.h | 0 .../{dist => }/include/jsdbgapi.h | 0 .../{dist => }/include/jsdhash.h | 0 .../{dist => }/include/jsfriendapi.h | 0 .../{dist => }/include/jsgc.h | 0 .../{dist => }/include/jshash.h | 0 .../{dist => }/include/jslock.h | 0 .../{dist => }/include/json.h | 0 .../{dist => }/include/jsperf.h | 0 .../{dist => }/include/jsprf.h | 0 .../{dist => }/include/jsproto.tbl | 0 .../{dist => }/include/jsproxy.h | 0 .../{dist => }/include/jsprvtd.h | 0 .../{dist => }/include/jspubtd.h | 0 .../{dist => }/include/jstypedarray.h | 0 .../{dist => }/include/jstypes.h | 0 .../{dist => }/include/jsutil.h | 0 .../{dist => }/include/jsval.h | 0 .../{dist => }/include/jsversion.h | 0 .../{dist => }/include/jswrapper.h | 0 .../{dist => }/include/jsxdrapi.h | 0 .../{dist => }/include/mozilla/Assertions.h | 0 .../{dist => }/include/mozilla/Attributes.h | 0 .../{dist => }/include/mozilla/BloomFilter.h | 0 .../include/mozilla/FloatingPoint.h | 0 .../{dist => }/include/mozilla/GuardObjects.h | 0 .../include/mozilla/HashFunctions.h | 0 .../{dist => }/include/mozilla/Likely.h | 0 .../{dist => }/include/mozilla/LinkedList.h | 0 .../{dist => }/include/mozilla/MSStdInt.h | 0 .../{dist => }/include/mozilla/RangedPtr.h | 0 .../{dist => }/include/mozilla/RefPtr.h | 0 .../{dist => }/include/mozilla/Scoped.h | 0 .../include/mozilla/StandardInteger.h | 0 .../{dist => }/include/mozilla/Types.h | 0 .../{dist => }/include/mozilla/Util.h | 0 .../lib/libjs_static.a.REMOVED.git-id | 0 107 files changed, 3010 insertions(+), 3113 deletions(-) create mode 100644 cocos2dx/platform/android/java/.classpath create mode 100644 cocos2dx/platform/android/java/.project create mode 100644 cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java create mode 100644 cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java create mode 100644 cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java create mode 100755 cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java create mode 100644 cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditText.java create mode 100644 cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java create mode 100644 cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java create mode 100644 cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxMusic.java create mode 100644 cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxRenderer.java create mode 100644 cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java create mode 100644 cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTextInputWraper.java create mode 100644 cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTypefaces.java delete mode 100644 cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxAccelerometer.java delete mode 100644 cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxActivity.java delete mode 100644 cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxBitmap.java delete mode 100755 cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java delete mode 100644 cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxEditText.java delete mode 100644 cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java delete mode 100644 cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxMusic.java delete mode 100644 cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxRenderer.java delete mode 100644 cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxSound.java delete mode 100644 cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxTypefaces.java delete mode 100644 cocos2dx/platform/android/jni/EditBoxJni.cpp delete mode 100644 cocos2dx/platform/android/jni/EditBoxJni.h create mode 100644 cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp create mode 100644 cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp create mode 100644 cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp rename cocos2dx/platform/android/jni/{SensorJni.h => Java_org_cocos2dx_lib_Cocos2dxHelper.h} (67%) create mode 100644 cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp delete mode 100644 cocos2dx/platform/android/jni/MessageJni.cpp delete mode 100644 cocos2dx/platform/android/jni/MessageJni.h delete mode 100644 cocos2dx/platform/android/jni/SensorJni.cpp delete mode 100644 cocos2dx/platform/android/jni/SystemInfoJni.cpp delete mode 100644 cocos2dx/platform/android/jni/SystemInfoJni.h rename scripting/javascript/spidermonkey-android/{android => }/Android.mk (70%) rename scripting/javascript/spidermonkey-android/{dist => }/include/ds/BitArray.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/gc/Barrier.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/gc/Root.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/gc/Statistics.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/js-config.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/js.msg (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/js/HashTable.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/js/LegacyIntTypes.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/js/MemoryMetrics.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/js/TemplateLib.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/js/Utility.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/js/Vector.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsalloc.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsapi.h.REMOVED.git-id (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsatom.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsatom.tbl (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jscell.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsclass.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsclist.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jscpucfg.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsdbgapi.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsdhash.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsfriendapi.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsgc.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jshash.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jslock.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/json.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsperf.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsprf.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsproto.tbl (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsproxy.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsprvtd.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jspubtd.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jstypedarray.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jstypes.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsutil.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsval.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsversion.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jswrapper.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/jsxdrapi.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/mozilla/Assertions.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/mozilla/Attributes.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/mozilla/BloomFilter.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/mozilla/FloatingPoint.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/mozilla/GuardObjects.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/mozilla/HashFunctions.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/mozilla/Likely.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/mozilla/LinkedList.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/mozilla/MSStdInt.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/mozilla/RangedPtr.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/mozilla/RefPtr.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/mozilla/Scoped.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/mozilla/StandardInteger.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/mozilla/Types.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/include/mozilla/Util.h (100%) rename scripting/javascript/spidermonkey-android/{dist => }/lib/libjs_static.a.REMOVED.git-id (100%) diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index b6ae74b809..a8c0c7084b 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -82,12 +82,12 @@ platform/android/CCApplication.cpp \ platform/android/CCCommon.cpp \ platform/android/CCFileUtils.cpp \ platform/android/CCImage.cpp \ -platform/android/jni/EditBoxJni.cpp \ +platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp \ +platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp \ +platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp \ +platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp \ platform/android/jni/JniHelper.cpp \ platform/android/jni/IMEJni.cpp \ -platform/android/jni/MessageJni.cpp \ -platform/android/jni/SensorJni.cpp \ -platform/android/jni/SystemInfoJni.cpp \ platform/android/jni/TouchesJni.cpp \ script_support/CCScriptSupport.cpp \ shaders/ccShaders.cpp \ diff --git a/cocos2dx/platform/android/CCAccelerometer.cpp b/cocos2dx/platform/android/CCAccelerometer.cpp index 3403b7b9d2..23aa11bd8e 100644 --- a/cocos2dx/platform/android/CCAccelerometer.cpp +++ b/cocos2dx/platform/android/CCAccelerometer.cpp @@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCAccelerometer.h" -#include "jni/SensorJni.h" +#include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" #include #include diff --git a/cocos2dx/platform/android/CCApplication.cpp b/cocos2dx/platform/android/CCApplication.cpp index d475346c4c..cc261e28f9 100644 --- a/cocos2dx/platform/android/CCApplication.cpp +++ b/cocos2dx/platform/android/CCApplication.cpp @@ -1,5 +1,5 @@ #include "jni/JniHelper.h" -#include "jni/SystemInfoJni.h" +#include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" #include "CCApplication.h" #include "CCDirector.h" #include "CCEGLView.h" diff --git a/cocos2dx/platform/android/CCCommon.cpp b/cocos2dx/platform/android/CCCommon.cpp index eef3ad11bd..594a138e08 100644 --- a/cocos2dx/platform/android/CCCommon.cpp +++ b/cocos2dx/platform/android/CCCommon.cpp @@ -23,7 +23,7 @@ THE SOFTWARE. ****************************************************************************/ #include "platform/CCCommon.h" -#include "jni/MessageJni.h" +#include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" #include #include #include @@ -46,7 +46,7 @@ void CCLog(const char * pszFormat, ...) void CCMessageBox(const char * pszMsg, const char * pszTitle) { - showMessageBoxJNI(pszMsg, pszTitle); + showDialogJNI(pszMsg, pszTitle); } void CCLuaLog(const char * pszFormat) diff --git a/cocos2dx/platform/android/CCEGLView.cpp b/cocos2dx/platform/android/CCEGLView.cpp index 21999b51f6..7b41f5ca45 100644 --- a/cocos2dx/platform/android/CCEGLView.cpp +++ b/cocos2dx/platform/android/CCEGLView.cpp @@ -27,8 +27,7 @@ THE SOFTWARE. #include "ccMacros.h" #include "touch_dispatcher/CCTouchDispatcher.h" #include "jni/IMEJni.h" -#include "jni/EditBoxJni.h" -#include "jni/MessageJni.h" +#include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" #include "CCGL.h" #include diff --git a/cocos2dx/platform/android/CCFileUtils.cpp b/cocos2dx/platform/android/CCFileUtils.cpp index 680a591f7d..10887d0a93 100644 --- a/cocos2dx/platform/android/CCFileUtils.cpp +++ b/cocos2dx/platform/android/CCFileUtils.cpp @@ -30,8 +30,7 @@ using namespace std; NS_CC_BEGIN #include "platform/CCCommon.h" -#include "jni/SystemInfoJni.h" -#include "jni/MessageJni.h" +#include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" // record the resource path static string s_strResourcePath = ""; diff --git a/cocos2dx/platform/android/java/.classpath b/cocos2dx/platform/android/java/.classpath new file mode 100644 index 0000000000..3f9691c5dd --- /dev/null +++ b/cocos2dx/platform/android/java/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/cocos2dx/platform/android/java/.project b/cocos2dx/platform/android/java/.project new file mode 100644 index 0000000000..45ae73e116 --- /dev/null +++ b/cocos2dx/platform/android/java/.project @@ -0,0 +1,33 @@ + + + java + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/cocos2dx/platform/android/java/AndroidManifest.xml b/cocos2dx/platform/android/java/AndroidManifest.xml index d93da3f7f9..58d8fef36f 100644 --- a/cocos2dx/platform/android/java/AndroidManifest.xml +++ b/cocos2dx/platform/android/java/AndroidManifest.xml @@ -1,6 +1,9 @@ + package="org.cocos2dx.lib" + android:versionCode="1" + android:versionName="1.0"> + + + diff --git a/cocos2dx/platform/android/java/ant.properties b/cocos2dx/platform/android/java/ant.properties index e06eefd0d1..b0971e891e 100644 --- a/cocos2dx/platform/android/java/ant.properties +++ b/cocos2dx/platform/android/java/ant.properties @@ -15,4 +15,3 @@ # 'key.alias' for the name of the key to use. # The password will be asked during the build when you use the 'release' target. -source.dir=src_common diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java new file mode 100644 index 0000000000..c89439b0af --- /dev/null +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java @@ -0,0 +1,129 @@ +/**************************************************************************** +Copyright (c) 2010-2011 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + ****************************************************************************/ +package org.cocos2dx.lib; + +import android.content.Context; +import android.content.res.Configuration; +import android.hardware.Sensor; +import android.hardware.SensorEvent; +import android.hardware.SensorEventListener; +import android.hardware.SensorManager; +import android.util.Log; +import android.view.Display; +import android.view.Surface; +import android.view.WindowManager; + +public class Cocos2dxAccelerometer implements SensorEventListener { + // =========================================================== + // Constants + // =========================================================== + + private static final String TAG = Cocos2dxAccelerometer.class.getSimpleName(); + + // =========================================================== + // Fields + // =========================================================== + + private final Context mContext; + private final SensorManager mSensorManager; + private final Sensor mAccelerometer; + private final int mNaturalOrientation; + + // =========================================================== + // Constructors + // =========================================================== + + public Cocos2dxAccelerometer(final Context pContext) { + this.mContext = pContext; + + this.mSensorManager = (SensorManager) this.mContext.getSystemService(Context.SENSOR_SERVICE); + this.mAccelerometer = this.mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); + + final Display display = ((WindowManager) this.mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); + this.mNaturalOrientation = display.getOrientation(); + } + + // =========================================================== + // Getter & Setter + // =========================================================== + + public void enable() { + this.mSensorManager.registerListener(this, this.mAccelerometer, SensorManager.SENSOR_DELAY_GAME); + } + + public void disable() { + this.mSensorManager.unregisterListener(this); + } + + // =========================================================== + // Methods for/from SuperClass/Interfaces + // =========================================================== + + @Override + public void onSensorChanged(final SensorEvent pSensorEvent) { + if (pSensorEvent.sensor.getType() != Sensor.TYPE_ACCELEROMETER) { + return; + } + + float x = pSensorEvent.values[0]; + float y = pSensorEvent.values[1]; + final float z = pSensorEvent.values[2]; + + /* + * Because the axes are not swapped when the device's screen orientation + * changes. So we should swap it here. In tablets such as Motorola Xoom, + * the default orientation is landscape, so should consider this. + */ + final int orientation = this.mContext.getResources().getConfiguration().orientation; + + if ((orientation == Configuration.ORIENTATION_LANDSCAPE) && (this.mNaturalOrientation != Surface.ROTATION_0)) { + final float tmp = x; + x = -y; + y = tmp; + } else if ((orientation == Configuration.ORIENTATION_PORTRAIT) && (this.mNaturalOrientation != Surface.ROTATION_0)) { + final float tmp = x; + x = y; + y = -tmp; + } + + Cocos2dxAccelerometer.onSensorChanged(x, y, z, pSensorEvent.timestamp); + if(BuildConfig.DEBUG) { + Log.d(TAG, "x = " + pSensorEvent.values[0] + " y = " + pSensorEvent.values[1] + " z = " + pSensorEvent.values[2]); + } + } + + @Override + public void onAccuracyChanged(final Sensor pSensor, final int pAccuracy) { + } + + // =========================================================== + // Methods + // =========================================================== + + private static native void onSensorChanged(final float pX, final float pY, final float pZ, final long pTimestamp); + + // =========================================================== + // Inner and Anonymous Classes + // =========================================================== +} diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java new file mode 100644 index 0000000000..3722781190 --- /dev/null +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java @@ -0,0 +1,93 @@ +/**************************************************************************** +Copyright (c) 2010-2011 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + ****************************************************************************/ +package org.cocos2dx.lib; + +import org.cocos2dx.lib.Cocos2dxHelper.Cocos2dxHelperListener; + +import android.app.Activity; +import android.app.AlertDialog; +import android.os.Bundle; + +public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelperListener { + // =========================================================== + // Constants + // =========================================================== + + private static final String TAG = Cocos2dxActivity.class.getSimpleName(); + + // =========================================================== + // Fields + // =========================================================== + + // =========================================================== + // Constructors + // =========================================================== + + @Override + protected void onCreate(final Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Cocos2dxHelper.init(this, this); + } + + // =========================================================== + // Getter & Setter + // =========================================================== + + // =========================================================== + // Methods for/from SuperClass/Interfaces + // =========================================================== + + @Override + protected void onResume() { + super.onResume(); + + Cocos2dxHelper.onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + + Cocos2dxHelper.onPause(); + } + + @Override + public void showDialog(final String pTitle, final String pMessage) { + new AlertDialog.Builder(this).setTitle(pTitle).setMessage(pMessage).setPositiveButton("OK", null).create().show(); // TODO Dialog will not survive configuration changes + } + + @Override + public void showEditTextDialog(final String pTitle, final String pContent, final int pInputMode, final int pInputFlag, final int pReturnType, final int pMaxLength) { // TODO Dialog will not survive configuration changes + new Cocos2dxEditBoxDialog(this, pTitle, pContent, pInputMode, pInputFlag, pReturnType, pMaxLength).show(); + } + + // =========================================================== + // Methods + // =========================================================== + + // =========================================================== + // Inner and Anonymous Classes + // =========================================================== +} diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java new file mode 100644 index 0000000000..fef9cb788d --- /dev/null +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java @@ -0,0 +1,420 @@ +/**************************************************************************** +Copyright (c) 2010-2011 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + ****************************************************************************/ +package org.cocos2dx.lib; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.LinkedList; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Paint.Align; +import android.graphics.Paint.FontMetricsInt; +import android.graphics.Rect; +import android.graphics.Typeface; +import android.text.TextPaint; +import android.text.TextUtils; +import android.util.FloatMath; +import android.util.Log; + +public class Cocos2dxBitmap { + // =========================================================== + // Constants + // =========================================================== + + /* The values are the same as cocos2dx/platform/CCImage.h. */ + private static final int HORIZONTALALIGN_LEFT = 1; + private static final int HORIZONTALALIGN_RIGHT = 2; + private static final int HORIZONTALALIGN_CENTER = 3; + private static final int VERTICALALIGN_TOP = 1; + private static final int VERTICALALIGN_BOTTOM = 2; + private static final int VERTICALALIGN_CENTER = 3; + + // =========================================================== + // Fields + // =========================================================== + + private static Context sContext; + + // =========================================================== + // Constructors + // =========================================================== + + // =========================================================== + // Getter & Setter + // =========================================================== + + public static void setContext(final Context pContext) { + Cocos2dxBitmap.sContext = pContext; + } + + // =========================================================== + // Methods for/from SuperClass/Interfaces + // =========================================================== + + // =========================================================== + // Methods + // =========================================================== + + private static native void nativeInitBitmapDC(final int pWidth, final int pHeight, final byte[] pPixels); + + /** + * @param pWidth + * the width to draw, it can be 0 + * @param pHeight + * the height to draw, it can be 0 + */ + public static void createTextBitmap(String pString, final String pFontName, final int pFontSize, final int pAlignment, final int pWidth, final int pHeight) { + final int horizontalAlignment = pAlignment & 0x0F; + final int verticalAlignment = (pAlignment >> 4) & 0x0F; + + pString = Cocos2dxBitmap.refactorString(pString); + final Paint paint = Cocos2dxBitmap.newPaint(pFontName, pFontSize, horizontalAlignment); + + final TextProperty textProperty = Cocos2dxBitmap.computeTextProperty(pString, pWidth, pHeight, paint); + + final int bitmapTotalHeight = (pHeight == 0 ? textProperty.mTotalHeight : pHeight); + + final Bitmap bitmap = Bitmap.createBitmap(textProperty.mMaxWidth, bitmapTotalHeight, Bitmap.Config.ARGB_8888); + final Canvas canvas = new Canvas(bitmap); + + /* Draw string. */ + final FontMetricsInt fontMetricsInt = paint.getFontMetricsInt(); + int x = 0; + int y = Cocos2dxBitmap.computeY(fontMetricsInt, pHeight, textProperty.mTotalHeight, verticalAlignment); + final String[] lines = textProperty.mLines; + for (final String line : lines) { + x = Cocos2dxBitmap.computeX(line, textProperty.mMaxWidth, horizontalAlignment); + canvas.drawText(line, x, y, paint); + y += textProperty.mHeightPerLine; + } + + Cocos2dxBitmap.initNativeObject(bitmap); + } + + private static Paint newPaint(final String pFontName, final int pFontSize, final int pHorizontalAlignment) { + final Paint paint = new Paint(); + paint.setColor(Color.WHITE); + paint.setTextSize(pFontSize); + paint.setAntiAlias(true); + + /* Set type face for paint, now it support .ttf file. */ + if (pFontName.endsWith(".ttf")) { + try { + final Typeface typeFace = Cocos2dxTypefaces.get(Cocos2dxBitmap.sContext, pFontName); + paint.setTypeface(typeFace); + } catch (final Exception e) { + Log.e("Cocos2dxBitmap", "error to create ttf type face: " + pFontName); + + /* The file may not find, use system font. */ + paint.setTypeface(Typeface.create(pFontName, Typeface.NORMAL)); + } + } else { + paint.setTypeface(Typeface.create(pFontName, Typeface.NORMAL)); + } + + switch (pHorizontalAlignment) { + case HORIZONTALALIGN_CENTER: + paint.setTextAlign(Align.CENTER); + break; + case HORIZONTALALIGN_RIGHT: + paint.setTextAlign(Align.RIGHT); + break; + case HORIZONTALALIGN_LEFT: + default: + paint.setTextAlign(Align.LEFT); + break; + } + + return paint; + } + + private static TextProperty computeTextProperty(final String pString, final int pWidth, final int pHeight, final Paint pPaint) { + final FontMetricsInt fm = pPaint.getFontMetricsInt(); + final int h = (int) Math.ceil(fm.bottom - fm.top); + int maxContentWidth = 0; + + final String[] lines = Cocos2dxBitmap.splitString(pString, pWidth, pHeight, pPaint); + + if (pWidth != 0) { + maxContentWidth = pWidth; + } else { + /* Compute the max width. */ + int temp = 0; + for (final String line : lines) { + temp = (int) FloatMath.ceil(pPaint.measureText(line, 0, line.length())); + if (temp > maxContentWidth) { + maxContentWidth = temp; + } + } + } + + return new TextProperty(maxContentWidth, h, lines); + } + + private static int computeX(final String pText, final int pMaxWidth, final int pHorizontalAlignment) { + int ret = 0; + + switch (pHorizontalAlignment) { + case HORIZONTALALIGN_CENTER: + ret = pMaxWidth / 2; + break; + case HORIZONTALALIGN_RIGHT: + ret = pMaxWidth; + break; + case HORIZONTALALIGN_LEFT: + default: + break; + } + + return ret; + } + + private static int computeY(final FontMetricsInt pFontMetricsInt, final int pConstrainHeight, final int pTotalHeight, final int pVerticalAlignment) { + int y = -pFontMetricsInt.top; + + if (pConstrainHeight > pTotalHeight) { + switch (pVerticalAlignment) { + case VERTICALALIGN_TOP: + y = -pFontMetricsInt.top; + break; + case VERTICALALIGN_CENTER: + y = -pFontMetricsInt.top + (pConstrainHeight - pTotalHeight) / 2; + break; + case VERTICALALIGN_BOTTOM: + y = -pFontMetricsInt.top + (pConstrainHeight - pTotalHeight); + break; + default: + break; + } + } + + return y; + } + + /* + * If maxWidth or maxHeight is not 0, split the string to fix the maxWidth and maxHeight. + */ + private static String[] splitString(final String pString, final int pMaxWidth, final int pMaxHeight, final Paint pPaint) { + final String[] lines = pString.split("\\n"); + String[] ret = null; + final FontMetricsInt fm = pPaint.getFontMetricsInt(); + final int heightPerLine = (int) Math.ceil(fm.bottom - fm.top); + final int maxLines = pMaxHeight / heightPerLine; + + if (pMaxWidth != 0) { + final LinkedList strList = new LinkedList(); + for (final String line : lines) { + /* The width of line is exceed maxWidth, should divide it into two or more lines. */ + final int lineWidth = (int) FloatMath.ceil(pPaint.measureText(line)); + if (lineWidth > pMaxWidth) { + strList.addAll(Cocos2dxBitmap.divideStringWithMaxWidth(line, pMaxWidth, pPaint)); + } else { + strList.add(line); + } + + /* Should not exceed the max height. */ + if (maxLines > 0 && strList.size() >= maxLines) { + break; + } + } + + /* Remove exceeding lines. */ + if (maxLines > 0 && strList.size() > maxLines) { + while (strList.size() > maxLines) { + strList.removeLast(); + } + } + + ret = new String[strList.size()]; + strList.toArray(ret); + } else if (pMaxHeight != 0 && lines.length > maxLines) { + /* Remove exceeding lines. */ + final LinkedList strList = new LinkedList(); + for (int i = 0; i < maxLines; i++) { + strList.add(lines[i]); + } + ret = new String[strList.size()]; + strList.toArray(ret); + } else { + ret = lines; + } + + return ret; + } + + private static LinkedList divideStringWithMaxWidth(final String pString, final int pMaxWidth, final Paint pPaint) { + final int charLength = pString.length(); + int start = 0; + int tempWidth = 0; + final LinkedList strList = new LinkedList(); + + /* Break a String into String[] by the width & should wrap the word. */ + for (int i = 1; i <= charLength; ++i) { + tempWidth = (int) FloatMath.ceil(pPaint.measureText(pString, start, i)); + if (tempWidth >= pMaxWidth) { + final int lastIndexOfSpace = pString.substring(0, i).lastIndexOf(" "); + + if (lastIndexOfSpace != -1 && lastIndexOfSpace > start) { + /* Should wrap the word. */ + strList.add(pString.substring(start, lastIndexOfSpace)); + i = lastIndexOfSpace; + } else { + /* Should not exceed the width. */ + if (tempWidth > pMaxWidth) { + strList.add(pString.substring(start, i - 1)); + /* Compute from previous char. */ + --i; + } else { + strList.add(pString.substring(start, i)); + } + } + + /* Remove spaces at the beginning of a new line. */ + while (pString.indexOf(i++) == ' ') { + ; + } + + start = i; + } + } + + /* Add the last chars. */ + if (start < charLength) { + strList.add(pString.substring(start)); + } + + return strList; + } + + private static String refactorString(final String pString) { + /* Avoid error when content is "". */ + if (pString.compareTo("") == 0) { + return " "; + } + + /* + * If the font of "\n" is "" or "\n", insert " " in front of it. For example: "\nabc" -> " \nabc" "\nabc\n\n" -> " \nabc\n \n". + */ + final StringBuilder strBuilder = new StringBuilder(pString); + int start = 0; + int index = strBuilder.indexOf("\n"); + while (index != -1) { + if (index == 0 || strBuilder.charAt(index - 1) == '\n') { + strBuilder.insert(start, " "); + start = index + 2; + } else { + start = index + 1; + } + + if (start > strBuilder.length() || index == strBuilder.length()) { + break; + } + + index = strBuilder.indexOf("\n", start); + } + + return strBuilder.toString(); + } + + private static void initNativeObject(final Bitmap pBitmap) { + final byte[] pixels = Cocos2dxBitmap.getPixels(pBitmap); + if (pixels == null) { + return; + } + + Cocos2dxBitmap.nativeInitBitmapDC(pBitmap.getWidth(), pBitmap.getHeight(), pixels); + } + + private static byte[] getPixels(final Bitmap pBitmap) { + if (pBitmap != null) { + final byte[] pixels = new byte[pBitmap.getWidth() * pBitmap.getHeight() * 4]; + final ByteBuffer buf = ByteBuffer.wrap(pixels); + buf.order(ByteOrder.nativeOrder()); + pBitmap.copyPixelsToBuffer(buf); + return pixels; + } + + return null; + } + + private static int getFontSizeAccordingHeight(int height) { + Paint paint = new Paint(); + Rect bounds = new Rect(); + + paint.setTypeface(Typeface.DEFAULT); + int incr_text_size = 1; + boolean found_desired_size = false; + + while (!found_desired_size) { + + paint.setTextSize(incr_text_size); + String text = "SghMNy"; + paint.getTextBounds(text, 0, text.length(), bounds); + + incr_text_size++; + + if (height - bounds.height() <= 2) { + found_desired_size = true; + } + Log.d("font size", "incr size:" + incr_text_size); + } + return incr_text_size; + } + + private static String getStringWithEllipsis(String pString, float width, float fontSize) { + if (TextUtils.isEmpty(pString)) { + return ""; + } + + TextPaint paint = new TextPaint(); + paint.setTypeface(Typeface.DEFAULT); + paint.setTextSize(fontSize); + + return TextUtils.ellipsize(pString, paint, width, TextUtils.TruncateAt.END).toString(); + } + + // =========================================================== + // Inner and Anonymous Classes + // =========================================================== + + private static class TextProperty { + /** The max width of lines. */ + private final int mMaxWidth; + /** The height of all lines. */ + private final int mTotalHeight; + private final int mHeightPerLine; + private final String[] mLines; + + TextProperty(final int pMaxWidth, final int pHeightPerLine, final String[] pLines) { + this.mMaxWidth = pMaxWidth; + this.mHeightPerLine = pHeightPerLine; + this.mTotalHeight = pHeightPerLine * pLines.length; + this.mLines = pLines; + } + } +} diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java new file mode 100755 index 0000000000..0b1a8a32d7 --- /dev/null +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java @@ -0,0 +1,320 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + ****************************************************************************/ + +package org.cocos2dx.lib; + +import android.app.Dialog; +import android.content.Context; +import android.graphics.drawable.ColorDrawable; +import android.os.Bundle; +import android.os.Handler; +import android.text.InputFilter; +import android.text.InputType; +import android.util.TypedValue; +import android.view.KeyEvent; +import android.view.ViewGroup; +import android.view.WindowManager; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.TextView; +import android.widget.TextView.OnEditorActionListener; + +public class Cocos2dxEditBoxDialog extends Dialog { + // =========================================================== + // Constants + // =========================================================== + + /** + * The user is allowed to enter any text, including line breaks. + */ + private final int kEditBoxInputModeAny = 0; + + /** + * The user is allowed to enter an e-mail address. + */ + private final int kEditBoxInputModeEmailAddr = 1; + + /** + * The user is allowed to enter an integer value. + */ + private final int kEditBoxInputModeNumeric = 2; + + /** + * The user is allowed to enter a phone number. + */ + private final int kEditBoxInputModePhoneNumber = 3; + + /** + * The user is allowed to enter a URL. + */ + private final int kEditBoxInputModeUrl = 4; + + /** + * The user is allowed to enter a real number value. This extends kEditBoxInputModeNumeric by allowing a decimal point. + */ + private final int kEditBoxInputModeDecimal = 5; + + /** + * The user is allowed to enter any text, except for line breaks. + */ + private final int kEditBoxInputModeSingleLine = 6; + + /** + * Indicates that the text entered is confidential data that should be obscured whenever possible. This implies EDIT_BOX_INPUT_FLAG_SENSITIVE. + */ + private final int kEditBoxInputFlagPassword = 0; + + /** + * Indicates that the text entered is sensitive data that the implementation must never store into a dictionary or table for use in predictive, auto-completing, or other accelerated input schemes. A credit card number is an example of sensitive data. + */ + private final int kEditBoxInputFlagSensitive = 1; + + /** + * This flag is a hint to the implementation that during text editing, the initial letter of each word should be capitalized. + */ + private final int kEditBoxInputFlagInitialCapsWord = 2; + + /** + * This flag is a hint to the implementation that during text editing, the initial letter of each sentence should be capitalized. + */ + private final int kEditBoxInputFlagInitialCapsSentence = 3; + + /** + * Capitalize all characters automatically. + */ + private final int kEditBoxInputFlagInitialCapsAllCharacters = 4; + + private final int kKeyboardReturnTypeDefault = 0; + private final int kKeyboardReturnTypeDone = 1; + private final int kKeyboardReturnTypeSend = 2; + private final int kKeyboardReturnTypeSearch = 3; + private final int kKeyboardReturnTypeGo = 4; + + // =========================================================== + // Fields + // =========================================================== + + private EditText mInputEditText; + private TextView mTextViewTitle; + + private final String mTitle; + private final String mMessage; + private final int mInputMode; + private final int mInputFlag; + private final int mReturnType; + private final int mMaxLength; + + private int mInputFlagConstraints; + private int mInputModeContraints; + private boolean mIsMultiline; + + // =========================================================== + // Constructors + // =========================================================== + + public Cocos2dxEditBoxDialog(final Context pContext, final String pTitle, final String pMessage, final int pInputMode, final int pInputFlag, final int pReturnType, final int pMaxLength) { + super(pContext, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen); +// super(context, R.style.Theme_Translucent); + + this.mTitle = pTitle; + this.mMessage = pMessage; + this.mInputMode = pInputMode; + this.mInputFlag = pInputFlag; + this.mReturnType = pReturnType; + this.mMaxLength = pMaxLength; + } + + @Override + protected void onCreate(final Bundle pSavedInstanceState) { + super.onCreate(pSavedInstanceState); + + this.getWindow().setBackgroundDrawable(new ColorDrawable(0x80000000)); + + final LinearLayout layout = new LinearLayout(this.getContext()); + layout.setOrientation(LinearLayout.VERTICAL); + + final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); + + this.mTextViewTitle = new TextView(this.getContext()); + final LinearLayout.LayoutParams textviewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + textviewParams.leftMargin = textviewParams.rightMargin = this.convertDipsToPixels(10); + this.mTextViewTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); + layout.addView(this.mTextViewTitle, textviewParams); + + this.mInputEditText = new EditText(this.getContext()); + final LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + editTextParams.leftMargin = editTextParams.rightMargin = this.convertDipsToPixels(10); + + layout.addView(this.mInputEditText, editTextParams); + + this.setContentView(layout, layoutParams); + + this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); + + this.mTextViewTitle.setText(this.mTitle); + this.mInputEditText.setText(this.mMessage); + + int oldImeOptions = this.mInputEditText.getImeOptions(); + this.mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_FLAG_NO_EXTRACT_UI); + oldImeOptions = this.mInputEditText.getImeOptions(); + + switch (this.mInputMode) { + case kEditBoxInputModeAny: + this.mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE; + break; + case kEditBoxInputModeEmailAddr: + this.mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; + break; + case kEditBoxInputModeNumeric: + this.mInputModeContraints = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED; + break; + case kEditBoxInputModePhoneNumber: + this.mInputModeContraints = InputType.TYPE_CLASS_PHONE; + break; + case kEditBoxInputModeUrl: + this.mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI; + break; + case kEditBoxInputModeDecimal: + this.mInputModeContraints = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED; + break; + case kEditBoxInputModeSingleLine: + this.mInputModeContraints = InputType.TYPE_CLASS_TEXT; + break; + default: + + break; + } + + if (this.mIsMultiline) { + this.mInputModeContraints |= InputType.TYPE_TEXT_FLAG_MULTI_LINE; + } + + this.mInputEditText.setInputType(this.mInputModeContraints | this.mInputFlagConstraints); + + switch (this.mInputFlag) { + case kEditBoxInputFlagPassword: + this.mInputFlagConstraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD; + break; + case kEditBoxInputFlagSensitive: + this.mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS; + break; + case kEditBoxInputFlagInitialCapsWord: + this.mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_WORDS; + break; + case kEditBoxInputFlagInitialCapsSentence: + this.mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; + break; + case kEditBoxInputFlagInitialCapsAllCharacters: + this.mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS; + break; + default: + break; + } + + this.mInputEditText.setInputType(this.mInputFlagConstraints | this.mInputModeContraints); + + switch (this.mReturnType) { + case kKeyboardReturnTypeDefault: + this.mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE); + break; + case kKeyboardReturnTypeDone: + this.mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_DONE); + break; + case kKeyboardReturnTypeSend: + this.mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEND); + break; + case kKeyboardReturnTypeSearch: + this.mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEARCH); + break; + case kKeyboardReturnTypeGo: + this.mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_GO); + break; + default: + this.mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE); + break; + } + + if (this.mMaxLength > 0) { + this.mInputEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(this.mMaxLength) }); + } + + final Handler initHandler = new Handler(); + initHandler.postDelayed(new Runnable() { + @Override + public void run() { + Cocos2dxEditBoxDialog.this.mInputEditText.requestFocus(); + Cocos2dxEditBoxDialog.this.mInputEditText.setSelection(Cocos2dxEditBoxDialog.this.mInputEditText.length()); + Cocos2dxEditBoxDialog.this.openKeyboard(); + } + }, 200); + + this.mInputEditText.setOnEditorActionListener(new OnEditorActionListener() { + @Override + public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) { + /* If user didn't set keyboard type, this callback will be invoked twice with 'KeyEvent.ACTION_DOWN' and 'KeyEvent.ACTION_UP'. */ + if (actionId != EditorInfo.IME_NULL || (actionId == EditorInfo.IME_NULL && event != null && event.getAction() == KeyEvent.ACTION_DOWN)) { + Cocos2dxHelper.setEditTextDialogResult(Cocos2dxEditBoxDialog.this.mInputEditText.getText().toString()); + Cocos2dxEditBoxDialog.this.closeKeyboard(); + Cocos2dxEditBoxDialog.this.dismiss(); + return true; + } + return false; + } + }); + } + + + // =========================================================== + // Getter & Setter + // =========================================================== + + // =========================================================== + // Methods for/from SuperClass/Interfaces + // =========================================================== + + // =========================================================== + // Methods + // =========================================================== + + private int convertDipsToPixels(final float pDIPs) { + final float scale = this.getContext().getResources().getDisplayMetrics().density; + return Math.round(pDIPs * scale); + } + + private void openKeyboard() { + final InputMethodManager imm = (InputMethodManager) this.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + imm.showSoftInput(this.mInputEditText, 0); + } + + private void closeKeyboard() { + final InputMethodManager imm = (InputMethodManager) this.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(this.mInputEditText.getWindowToken(), 0); + } + + // =========================================================== + // Inner and Anonymous Classes + // =========================================================== +} diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditText.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditText.java new file mode 100644 index 0000000000..8cdfd7a633 --- /dev/null +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditText.java @@ -0,0 +1,89 @@ +/**************************************************************************** +Copyright (c) 2012 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + ****************************************************************************/ +package org.cocos2dx.lib; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.KeyEvent; +import android.widget.EditText; + +public class Cocos2dxEditText extends EditText { + // =========================================================== + // Constants + // =========================================================== + + // =========================================================== + // Fields + // =========================================================== + + private Cocos2dxGLSurfaceView mCocos2dxGLSurfaceView; + + // =========================================================== + // Constructors + // =========================================================== + + public Cocos2dxEditText(final Context context) { + super(context); + } + + public Cocos2dxEditText(final Context context, final AttributeSet attrs) { + super(context, attrs); + } + + public Cocos2dxEditText(final Context context, final AttributeSet attrs, final int defStyle) { + super(context, attrs, defStyle); + } + + // =========================================================== + // Getter & Setter + // =========================================================== + + public void setCocos2dxGLSurfaceView(final Cocos2dxGLSurfaceView pCocos2dxGLSurfaceView) { + this.mCocos2dxGLSurfaceView = pCocos2dxGLSurfaceView; + } + + // =========================================================== + // Methods for/from SuperClass/Interfaces + // =========================================================== + + @Override + public boolean onKeyDown(final int pKeyCode, final KeyEvent pKeyEvent) { + super.onKeyDown(pKeyCode, pKeyEvent); + + /* Let GlSurfaceView get focus if back key is input. */ + if (pKeyCode == KeyEvent.KEYCODE_BACK) { + this.mCocos2dxGLSurfaceView.requestFocus(); + } + + return true; + } + + // =========================================================== + // Methods + // =========================================================== + + // =========================================================== + // Inner and Anonymous Classes + // =========================================================== +} diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java new file mode 100644 index 0000000000..5c719f999c --- /dev/null +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java @@ -0,0 +1,356 @@ +/**************************************************************************** +Copyright (c) 2010-2011 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + ****************************************************************************/ +package org.cocos2dx.lib; + +import android.content.Context; +import android.opengl.GLSurfaceView; +import android.os.Handler; +import android.os.Message; +import android.util.AttributeSet; +import android.util.Log; +import android.view.KeyEvent; +import android.view.MotionEvent; +import android.view.inputmethod.InputMethodManager; + +public class Cocos2dxGLSurfaceView extends GLSurfaceView { + // =========================================================== + // Constants + // =========================================================== + + private static final String TAG = Cocos2dxGLSurfaceView.class.getSimpleName(); + + private final static int HANDLER_OPEN_IME_KEYBOARD = 2; + private final static int HANDLER_CLOSE_IME_KEYBOARD = 3; + + // =========================================================== + // Fields + // =========================================================== + + // TODO Static handler -> Potential leak! + private static Handler sHandler; + + private static Cocos2dxGLSurfaceView mCocos2dxGLSurfaceView; + private static Cocos2dxTextInputWraper sCocos2dxTextInputWraper; + + private Cocos2dxRenderer mCocos2dxRenderer; + private Cocos2dxEditText mCocos2dxEditText; + + // =========================================================== + // Constructors + // =========================================================== + + public Cocos2dxGLSurfaceView(final Context context) { + super(context); + + this.setEGLContextClientVersion(2); + + this.initView(); + } + + public Cocos2dxGLSurfaceView(final Context context, final AttributeSet attrs) { + super(context, attrs); + + this.setEGLContextClientVersion(2); + + this.initView(); + } + + protected void initView() { + this.setFocusableInTouchMode(true); + + Cocos2dxGLSurfaceView.mCocos2dxGLSurfaceView = this; + Cocos2dxGLSurfaceView.sCocos2dxTextInputWraper = new Cocos2dxTextInputWraper(this); + + Cocos2dxGLSurfaceView.sHandler = new Handler() { + @Override + public void handleMessage(final Message msg) { + switch (msg.what) { + case HANDLER_OPEN_IME_KEYBOARD: + if (null != Cocos2dxGLSurfaceView.this.mCocos2dxEditText && Cocos2dxGLSurfaceView.this.mCocos2dxEditText.requestFocus()) { + Cocos2dxGLSurfaceView.this.mCocos2dxEditText.removeTextChangedListener(Cocos2dxGLSurfaceView.sCocos2dxTextInputWraper); + Cocos2dxGLSurfaceView.this.mCocos2dxEditText.setText(""); + final String text = (String) msg.obj; + Cocos2dxGLSurfaceView.this.mCocos2dxEditText.append(text); + Cocos2dxGLSurfaceView.sCocos2dxTextInputWraper.setOriginText(text); + Cocos2dxGLSurfaceView.this.mCocos2dxEditText.addTextChangedListener(Cocos2dxGLSurfaceView.sCocos2dxTextInputWraper); + final InputMethodManager imm = (InputMethodManager) Cocos2dxGLSurfaceView.mCocos2dxGLSurfaceView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + imm.showSoftInput(Cocos2dxGLSurfaceView.this.mCocos2dxEditText, 0); + Log.d("GLSurfaceView", "showSoftInput"); + } + break; + + case HANDLER_CLOSE_IME_KEYBOARD: + if (null != Cocos2dxGLSurfaceView.this.mCocos2dxEditText) { + Cocos2dxGLSurfaceView.this.mCocos2dxEditText.removeTextChangedListener(Cocos2dxGLSurfaceView.sCocos2dxTextInputWraper); + final InputMethodManager imm = (InputMethodManager) Cocos2dxGLSurfaceView.mCocos2dxGLSurfaceView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(Cocos2dxGLSurfaceView.this.mCocos2dxEditText.getWindowToken(), 0); + Log.d("GLSurfaceView", "HideSoftInput"); + } + break; + } + } + }; + } + + // =========================================================== + // Getter & Setter + // =========================================================== + + public void setCocos2dxRenderer(final Cocos2dxRenderer renderer) { + this.mCocos2dxRenderer = renderer; + this.setRenderer(this.mCocos2dxRenderer); + } + + private String getContentText() { + return this.mCocos2dxRenderer.getContentText(); + } + + public Cocos2dxEditText getCocos2dxEditText() { + return this.mCocos2dxEditText; + } + + public void setCocos2dxEditText(final Cocos2dxEditText pCocos2dxEditText) { + this.mCocos2dxEditText = pCocos2dxEditText; + if (null != this.mCocos2dxEditText && null != Cocos2dxGLSurfaceView.sCocos2dxTextInputWraper) { + this.mCocos2dxEditText.setOnEditorActionListener(Cocos2dxGLSurfaceView.sCocos2dxTextInputWraper); + this.mCocos2dxEditText.setCocos2dxGLSurfaceView(this); + this.requestFocus(); + } + } + + // =========================================================== + // Methods for/from SuperClass/Interfaces + // =========================================================== + + @Override + public void onResume() { + super.onResume(); + + this.queueEvent(new Runnable() { + @Override + public void run() { + Cocos2dxGLSurfaceView.this.mCocos2dxRenderer.handleOnResume(); + } + }); + } + + @Override + public void onPause() { + this.queueEvent(new Runnable() { + @Override + public void run() { + Cocos2dxGLSurfaceView.this.mCocos2dxRenderer.handleOnPause(); + } + }); + + super.onPause(); + } + + @Override + public boolean onTouchEvent(final MotionEvent pMotionEvent) { + // these data are used in ACTION_MOVE and ACTION_CANCEL + final int pointerNumber = pMotionEvent.getPointerCount(); + final int[] ids = new int[pointerNumber]; + final float[] xs = new float[pointerNumber]; + final float[] ys = new float[pointerNumber]; + + for (int i = 0; i < pointerNumber; i++) { + ids[i] = pMotionEvent.getPointerId(i); + xs[i] = pMotionEvent.getX(i); + ys[i] = pMotionEvent.getY(i); + } + + switch (pMotionEvent.getAction() & MotionEvent.ACTION_MASK) { + case MotionEvent.ACTION_POINTER_DOWN: + final int indexPointerDown = pMotionEvent.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT; + final int idPointerDown = pMotionEvent.getPointerId(indexPointerDown); + final float xPointerDown = pMotionEvent.getX(indexPointerDown); + final float yPointerDown = pMotionEvent.getY(indexPointerDown); + + this.queueEvent(new Runnable() { + @Override + public void run() { + Cocos2dxGLSurfaceView.this.mCocos2dxRenderer.handleActionDown(idPointerDown, xPointerDown, yPointerDown); + } + }); + break; + + case MotionEvent.ACTION_DOWN: + // there are only one finger on the screen + final int idDown = pMotionEvent.getPointerId(0); + final float xDown = xs[0]; + final float yDown = ys[0]; + + this.queueEvent(new Runnable() { + @Override + public void run() { + Cocos2dxGLSurfaceView.this.mCocos2dxRenderer.handleActionDown(idDown, xDown, yDown); + } + }); + break; + + case MotionEvent.ACTION_MOVE: + this.queueEvent(new Runnable() { + @Override + public void run() { + Cocos2dxGLSurfaceView.this.mCocos2dxRenderer.handleActionMove(ids, xs, ys); + } + }); + break; + + case MotionEvent.ACTION_POINTER_UP: + final int indexPointUp = pMotionEvent.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT; + final int idPointerUp = pMotionEvent.getPointerId(indexPointUp); + final float xPointerUp = pMotionEvent.getX(indexPointUp); + final float yPointerUp = pMotionEvent.getY(indexPointUp); + + this.queueEvent(new Runnable() { + @Override + public void run() { + Cocos2dxGLSurfaceView.this.mCocos2dxRenderer.handleActionUp(idPointerUp, xPointerUp, yPointerUp); + } + }); + break; + + case MotionEvent.ACTION_UP: + // there are only one finger on the screen + final int idUp = pMotionEvent.getPointerId(0); + final float xUp = xs[0]; + final float yUp = ys[0]; + + this.queueEvent(new Runnable() { + @Override + public void run() { + Cocos2dxGLSurfaceView.this.mCocos2dxRenderer.handleActionUp(idUp, xUp, yUp); + } + }); + break; + + case MotionEvent.ACTION_CANCEL: + this.queueEvent(new Runnable() { + @Override + public void run() { + Cocos2dxGLSurfaceView.this.mCocos2dxRenderer.handleActionCancel(ids, xs, ys); + } + }); + break; + } + + if (BuildConfig.DEBUG) { + Cocos2dxGLSurfaceView.dumpMotionEvent(pMotionEvent); + } + return true; + } + + /* + * This function is called before Cocos2dxRenderer.nativeInit(), so the + * width and height is correct. + */ + @Override + protected void onSizeChanged(final int pNewSurfaceWidth, final int pNewSurfaceHeight, final int pOldSurfaceWidth, final int pOldSurfaceHeight) { + if(!this.isInEditMode()) { + this.mCocos2dxRenderer.setScreenWidthAndHeight(pNewSurfaceWidth, pNewSurfaceHeight); + } + } + + @Override + public boolean onKeyDown(final int pKeyCode, final KeyEvent pKeyEvent) { + switch (pKeyCode) { + case KeyEvent.KEYCODE_BACK: + case KeyEvent.KEYCODE_MENU: + this.queueEvent(new Runnable() { + @Override + public void run() { + Cocos2dxGLSurfaceView.this.mCocos2dxRenderer.handleKeyDown(pKeyCode); + } + }); + return true; + default: + return super.onKeyDown(pKeyCode, pKeyEvent); + } + } + + // =========================================================== + // Methods + // =========================================================== + + // =========================================================== + // Inner and Anonymous Classes + // =========================================================== + + public static void openIMEKeyboard() { + final Message msg = new Message(); + msg.what = Cocos2dxGLSurfaceView.HANDLER_OPEN_IME_KEYBOARD; + msg.obj = Cocos2dxGLSurfaceView.mCocos2dxGLSurfaceView.getContentText(); + Cocos2dxGLSurfaceView.sHandler.sendMessage(msg); + } + + public static void closeIMEKeyboard() { + final Message msg = new Message(); + msg.what = Cocos2dxGLSurfaceView.HANDLER_CLOSE_IME_KEYBOARD; + Cocos2dxGLSurfaceView.sHandler.sendMessage(msg); + } + + public void insertText(final String pText) { + this.queueEvent(new Runnable() { + @Override + public void run() { + Cocos2dxGLSurfaceView.this.mCocos2dxRenderer.handleInsertText(pText); + } + }); + } + + public void deleteBackward() { + this.queueEvent(new Runnable() { + @Override + public void run() { + Cocos2dxGLSurfaceView.this.mCocos2dxRenderer.handleDeleteBackward(); + } + }); + } + + private static void dumpMotionEvent(final MotionEvent event) { + final String names[] = { "DOWN", "UP", "MOVE", "CANCEL", "OUTSIDE", "POINTER_DOWN", "POINTER_UP", "7?", "8?", "9?" }; + final StringBuilder sb = new StringBuilder(); + final int action = event.getAction(); + final int actionCode = action & MotionEvent.ACTION_MASK; + sb.append("event ACTION_").append(names[actionCode]); + if (actionCode == MotionEvent.ACTION_POINTER_DOWN || actionCode == MotionEvent.ACTION_POINTER_UP) { + sb.append("(pid ").append(action >> MotionEvent.ACTION_POINTER_ID_SHIFT); + sb.append(")"); + } + sb.append("["); + for (int i = 0; i < event.getPointerCount(); i++) { + sb.append("#").append(i); + sb.append("(pid ").append(event.getPointerId(i)); + sb.append(")=").append((int) event.getX(i)); + sb.append(",").append((int) event.getY(i)); + if (i + 1 < event.getPointerCount()) { + sb.append(";"); + } + } + sb.append("]"); + Log.d(Cocos2dxGLSurfaceView.TAG, sb.toString()); + } +} diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java new file mode 100644 index 0000000000..3b9285d70e --- /dev/null +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java @@ -0,0 +1,253 @@ +/**************************************************************************** +Copyright (c) 2010-2011 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + ****************************************************************************/ +package org.cocos2dx.lib; + +import java.io.UnsupportedEncodingException; +import java.util.Locale; + +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.res.AssetManager; +import android.os.Environment; + +public class Cocos2dxHelper { + // =========================================================== + // Constants + // =========================================================== + + // =========================================================== + // Fields + // =========================================================== + + private static Cocos2dxMusic sCocos2dMusic; + private static Cocos2dxSound sCocos2dSound; + private static AssetManager sAssetManager; + private static Cocos2dxAccelerometer sCocos2dxAccelerometer; + private static boolean sAccelerometerEnabled; + private static String sPackageName; + + private static Cocos2dxHelperListener sCocos2dxHelperListener; + + // =========================================================== + // Constructors + // =========================================================== + + public static void init(final Context pContext, final Cocos2dxHelperListener pCocos2dxHelperListener) { + final ApplicationInfo applicationInfo = pContext.getApplicationInfo(); + + Cocos2dxHelper.sCocos2dxHelperListener = pCocos2dxHelperListener; + + Cocos2dxHelper.sPackageName = applicationInfo.packageName; + Cocos2dxHelper.nativeSetApkPath(applicationInfo.sourceDir); + Cocos2dxHelper.nativeSetExternalAssetPath(Cocos2dxHelper.getAbsolutePathOnExternalStorage(applicationInfo, "assets/")); + Cocos2dxHelper.nativeSetAssetManager(pContext.getAssets()); + + Cocos2dxHelper.sCocos2dxAccelerometer = new Cocos2dxAccelerometer(pContext); + Cocos2dxHelper.sCocos2dMusic = new Cocos2dxMusic(pContext); + Cocos2dxHelper.sCocos2dSound = new Cocos2dxSound(pContext); + Cocos2dxHelper.sAssetManager = pContext.getAssets(); + Cocos2dxBitmap.setContext(pContext); + } + + // =========================================================== + // Getter & Setter + // =========================================================== + + // =========================================================== + // Methods for/from SuperClass/Interfaces + // =========================================================== + + // =========================================================== + // Methods + // =========================================================== + + private static native void nativeSetApkPath(final String pApkPath); + + private static native void nativeSetExternalAssetPath(final String pExternalAssetPath); + + private static native void nativeSetAssetManager(final AssetManager pAssetManager); + + private static native void nativeSetEditTextDialogResult(final byte[] pBytes); + + public static String getCocos2dxPackageName() { + return Cocos2dxHelper.sPackageName; + } + + public static String getCurrentLanguage() { + return Locale.getDefault().getLanguage(); + } + + public static AssetManager getAssetManager() { + return Cocos2dxHelper.sAssetManager; + } + + public static void enableAccelerometer() { + Cocos2dxHelper.sAccelerometerEnabled = true; + Cocos2dxHelper.sCocos2dxAccelerometer.enable(); + } + + public static void disableAccelerometer() { + Cocos2dxHelper.sAccelerometerEnabled = false; + Cocos2dxHelper.sCocos2dxAccelerometer.disable(); + } + + public static void preloadBackgroundMusic(final String pPath) { + Cocos2dxHelper.sCocos2dMusic.preloadBackgroundMusic(pPath); + } + + public static void playBackgroundMusic(final String pPath, final boolean isLoop) { + Cocos2dxHelper.sCocos2dMusic.playBackgroundMusic(pPath, isLoop); + } + + public static void resumeBackgroundMusic() { + Cocos2dxHelper.sCocos2dMusic.resumeBackgroundMusic(); + } + + public static void pauseBackgroundMusic() { + Cocos2dxHelper.sCocos2dMusic.pauseBackgroundMusic(); + } + + public static void stopBackgroundMusic() { + Cocos2dxHelper.sCocos2dMusic.stopBackgroundMusic(); + } + + public static void rewindBackgroundMusic() { + Cocos2dxHelper.sCocos2dMusic.rewindBackgroundMusic(); + } + + public static boolean isBackgroundMusicPlaying() { + return Cocos2dxHelper.sCocos2dMusic.isBackgroundMusicPlaying(); + } + + public static float getBackgroundMusicVolume() { + return Cocos2dxHelper.sCocos2dMusic.getBackgroundVolume(); + } + + public static void setBackgroundMusicVolume(final float volume) { + Cocos2dxHelper.sCocos2dMusic.setBackgroundVolume(volume); + } + + public static void preloadEffect(final String path) { + Cocos2dxHelper.sCocos2dSound.preloadEffect(path); + } + + public static int playEffect(final String path, final boolean isLoop) { + return Cocos2dxHelper.sCocos2dSound.playEffect(path, isLoop); + } + + public static void resumeEffect(final int soundId) { + Cocos2dxHelper.sCocos2dSound.resumeEffect(soundId); + } + + public static void pauseEffect(final int soundId) { + Cocos2dxHelper.sCocos2dSound.pauseEffect(soundId); + } + + public static void stopEffect(final int soundId) { + Cocos2dxHelper.sCocos2dSound.stopEffect(soundId); + } + + public static float getEffectsVolume() { + return Cocos2dxHelper.sCocos2dSound.getEffectsVolume(); + } + + public static void setEffectsVolume(final float volume) { + Cocos2dxHelper.sCocos2dSound.setEffectsVolume(volume); + } + + public static void unloadEffect(final String path) { + Cocos2dxHelper.sCocos2dSound.unloadEffect(path); + } + + public static void pauseAllEffects() { + Cocos2dxHelper.sCocos2dSound.pauseAllEffects(); + } + + public static void resumeAllEffects() { + Cocos2dxHelper.sCocos2dSound.resumeAllEffects(); + } + + public static void stopAllEffects() { + Cocos2dxHelper.sCocos2dSound.stopAllEffects(); + } + + public static void end() { + Cocos2dxHelper.sCocos2dMusic.end(); + Cocos2dxHelper.sCocos2dSound.end(); + } + + public static void onResume() { + if (Cocos2dxHelper.sAccelerometerEnabled) { + Cocos2dxHelper.sCocos2dxAccelerometer.enable(); + } + } + + public static void onPause() { + if (Cocos2dxHelper.sAccelerometerEnabled) { + Cocos2dxHelper.sCocos2dxAccelerometer.disable(); + } + } + + public static void terminateProcess() { + android.os.Process.killProcess(android.os.Process.myPid()); + } + + private static void showDialog(final String pTitle, final String pMessage) { + Cocos2dxHelper.sCocos2dxHelperListener.showDialog(pTitle, pMessage); + } + + private static void showEditTextDialog(final String pTitle, final String pMessage, final int pInputMode, final int pInputFlag, final int pReturnType, final int pMaxLength) { + Cocos2dxHelper.sCocos2dxHelperListener.showEditTextDialog(pTitle, pMessage, pInputMode, pInputFlag, pReturnType, pMaxLength); + } + + public static void setEditTextDialogResult(final String pResult) { + try { + final byte[] bytesUTF8 = pResult.getBytes("UTF8"); + + Cocos2dxHelper.sCocos2dxHelperListener.runOnGLThread(new Runnable() { + @Override + public void run() { + Cocos2dxHelper.nativeSetEditTextDialogResult(bytesUTF8); + } + }); + } catch (UnsupportedEncodingException pUnsupportedEncodingException) { + /* Nothing. */ + } + } + + private static String getAbsolutePathOnExternalStorage(final ApplicationInfo pApplicationInfo, final String pPath) { + return Environment.getExternalStorageDirectory() + "/Android/data/" + pApplicationInfo.packageName + "/files/" + pPath; + } + + // =========================================================== + // Inner and Anonymous Classes + // =========================================================== + + public static interface Cocos2dxHelperListener { + public void showDialog(final String pTitle, final String pMessage); + public void showEditTextDialog(final String pTitle, final String pMessage, final int pInputMode, final int pInputFlag, final int pReturnType, final int pMaxLength); + + public void runOnGLThread(final Runnable pRunnable); + } +} diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxMusic.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxMusic.java new file mode 100644 index 0000000000..b067056c69 --- /dev/null +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxMusic.java @@ -0,0 +1,250 @@ +/**************************************************************************** +Copyright (c) 2010-2011 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + ****************************************************************************/ +package org.cocos2dx.lib; + +import android.content.Context; +import android.content.res.AssetFileDescriptor; +import android.media.MediaPlayer; +import android.util.Log; + +public class Cocos2dxMusic { + // =========================================================== + // Constants + // =========================================================== + + private static final String TAG = Cocos2dxMusic.class.getSimpleName(); + + // =========================================================== + // Fields + // =========================================================== + + private final Context mContext; + private MediaPlayer mBackgroundMediaPlayer; + private float mLeftVolume; + private float mRightVolume; + private boolean mPaused; + private String mCurrentPath; + + // =========================================================== + // Constructors + // =========================================================== + + public Cocos2dxMusic(final Context pContext) { + this.mContext = pContext; + + this.initData(); + } + + // =========================================================== + // Getter & Setter + // =========================================================== + + // =========================================================== + // Methods for/from SuperClass/Interfaces + // =========================================================== + + // =========================================================== + // Methods + // =========================================================== + + public void preloadBackgroundMusic(final String pPath) { + if ((this.mCurrentPath == null) || (!this.mCurrentPath.equals(pPath))) { + // preload new background music + + // release old resource and create a new one + if (this.mBackgroundMediaPlayer != null) { + this.mBackgroundMediaPlayer.release(); + } + + this.mBackgroundMediaPlayer = this.createMediaplayerFromAssets(pPath); + + // record the path + this.mCurrentPath = pPath; + } + } + + public void playBackgroundMusic(final String pPath, final boolean isLoop) { + if (this.mCurrentPath == null) { + // it is the first time to play background music or end() was called + this.mBackgroundMediaPlayer = this.createMediaplayerFromAssets(pPath); + this.mCurrentPath = pPath; + } else { + if (!this.mCurrentPath.equals(pPath)) { + // play new background music + + // release old resource and create a new one + if (this.mBackgroundMediaPlayer != null) { + this.mBackgroundMediaPlayer.release(); + } + this.mBackgroundMediaPlayer = this.createMediaplayerFromAssets(pPath); + + // record the path + this.mCurrentPath = pPath; + } + } + + if (this.mBackgroundMediaPlayer == null) { + Log.e(Cocos2dxMusic.TAG, "playBackgroundMusic: background media player is null"); + } else { + // if the music is playing or paused, stop it + this.mBackgroundMediaPlayer.stop(); + + this.mBackgroundMediaPlayer.setLooping(isLoop); + + try { + this.mBackgroundMediaPlayer.prepare(); + this.mBackgroundMediaPlayer.seekTo(0); + this.mBackgroundMediaPlayer.start(); + + this.mPaused = false; + } catch (final Exception e) { + Log.e(Cocos2dxMusic.TAG, "playBackgroundMusic: error state"); + } + } + } + + public void stopBackgroundMusic() { + if (this.mBackgroundMediaPlayer != null) { + this.mBackgroundMediaPlayer.stop(); + + // should set the state, if not, the following sequence will be error + // play -> pause -> stop -> resume + this.mPaused = false; + } + } + + public void pauseBackgroundMusic() { + if (this.mBackgroundMediaPlayer != null && this.mBackgroundMediaPlayer.isPlaying()) { + this.mBackgroundMediaPlayer.pause(); + this.mPaused = true; + } + } + + public void resumeBackgroundMusic() { + if (this.mBackgroundMediaPlayer != null && this.mPaused) { + this.mBackgroundMediaPlayer.start(); + this.mPaused = false; + } + } + + public void rewindBackgroundMusic() { + if (this.mBackgroundMediaPlayer != null) { + this.mBackgroundMediaPlayer.stop(); + + try { + this.mBackgroundMediaPlayer.prepare(); + this.mBackgroundMediaPlayer.seekTo(0); + this.mBackgroundMediaPlayer.start(); + + this.mPaused = false; + } catch (final Exception e) { + Log.e(Cocos2dxMusic.TAG, "rewindBackgroundMusic: error state"); + } + } + } + + public boolean isBackgroundMusicPlaying() { + boolean ret = false; + + if (this.mBackgroundMediaPlayer == null) { + ret = false; + } else { + ret = this.mBackgroundMediaPlayer.isPlaying(); + } + + return ret; + } + + public void end() { + if (this.mBackgroundMediaPlayer != null) { + this.mBackgroundMediaPlayer.release(); + } + + this.initData(); + } + + public float getBackgroundVolume() { + if (this.mBackgroundMediaPlayer != null) { + return (this.mLeftVolume + this.mRightVolume) / 2; + } else { + return 0.0f; + } + } + + public void setBackgroundVolume(float pVolume) { + if (pVolume < 0.0f) { + pVolume = 0.0f; + } + + if (pVolume > 1.0f) { + pVolume = 1.0f; + } + + this.mLeftVolume = this.mRightVolume = pVolume; + if (this.mBackgroundMediaPlayer != null) { + this.mBackgroundMediaPlayer.setVolume(this.mLeftVolume, this.mRightVolume); + } + } + + private void initData() { + this.mLeftVolume = 0.5f; + this.mRightVolume = 0.5f; + this.mBackgroundMediaPlayer = null; + this.mPaused = false; + this.mCurrentPath = null; + } + + /** + * create mediaplayer for music + * + * @param pPath + * the pPath relative to assets + * @return + */ + private MediaPlayer createMediaplayerFromAssets(final String pPath) { + MediaPlayer mediaPlayer = new MediaPlayer(); + + try { + if (pPath.startsWith("/")) { + mediaPlayer.setDataSource(pPath); + } else { + final AssetFileDescriptor assetFileDescritor = this.mContext.getAssets().openFd(pPath); + mediaPlayer.setDataSource(assetFileDescritor.getFileDescriptor(), assetFileDescritor.getStartOffset(), assetFileDescritor.getLength()); + } + + mediaPlayer.prepare(); + + mediaPlayer.setVolume(this.mLeftVolume, this.mRightVolume); + } catch (final Exception e) { + mediaPlayer = null; + Log.e(Cocos2dxMusic.TAG, "error: " + e.getMessage(), e); + } + + return mediaPlayer; + } + + // =========================================================== + // Inner and Anonymous Classes + // =========================================================== +} diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxRenderer.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxRenderer.java new file mode 100644 index 0000000000..8ae3476f59 --- /dev/null +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxRenderer.java @@ -0,0 +1,162 @@ +/**************************************************************************** +Copyright (c) 2010-2011 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + ****************************************************************************/ +package org.cocos2dx.lib; + +import javax.microedition.khronos.egl.EGLConfig; +import javax.microedition.khronos.opengles.GL10; + +import android.opengl.GLSurfaceView; + +public class Cocos2dxRenderer implements GLSurfaceView.Renderer { + // =========================================================== + // Constants + // =========================================================== + + private final static long NANOSECONDSPERSECOND = 1000000000L; + private final static long NANOSECONDSPERMICROSECOND = 1000000; + + private static long sAnimationInterval = (long) (1.0 / 60 * Cocos2dxRenderer.NANOSECONDSPERSECOND); + + // =========================================================== + // Fields + // =========================================================== + + private long mLastTickInNanoSeconds; + private int mScreenWidth; + private int mScreenHeight; + + // =========================================================== + // Constructors + // =========================================================== + + // =========================================================== + // Getter & Setter + // =========================================================== + + public static void setAnimationInterval(final double pAnimationInterval) { + Cocos2dxRenderer.sAnimationInterval = (long) (pAnimationInterval * Cocos2dxRenderer.NANOSECONDSPERSECOND); + } + + public void setScreenWidthAndHeight(final int pSurfaceWidth, final int pSurfaceHeight) { + this.mScreenWidth = pSurfaceWidth; + this.mScreenHeight = pSurfaceHeight; + } + + // =========================================================== + // Methods for/from SuperClass/Interfaces + // =========================================================== + + @Override + public void onSurfaceCreated(final GL10 pGL10, final EGLConfig pEGLConfig) { + Cocos2dxRenderer.nativeInit(this.mScreenWidth, this.mScreenHeight); + this.mLastTickInNanoSeconds = System.nanoTime(); + } + + @Override + public void onSurfaceChanged(final GL10 pGL10, final int pWidth, final int pHeight) { + } + + @Override + public void onDrawFrame(final GL10 gl) { + final long nowInNanoSeconds = System.nanoTime(); + final long interval = nowInNanoSeconds - this.mLastTickInNanoSeconds; + + // should render a frame when onDrawFrame() is called or there is a + // "ghost" + Cocos2dxRenderer.nativeRender(); + + // fps controlling + if (interval < Cocos2dxRenderer.sAnimationInterval) { + try { + // because we render it before, so we should sleep twice time interval + Thread.sleep((Cocos2dxRenderer.sAnimationInterval - interval) * 2 / Cocos2dxRenderer.NANOSECONDSPERMICROSECOND); + } catch (final Exception e) { + } + } + + this.mLastTickInNanoSeconds = nowInNanoSeconds; + } + + // =========================================================== + // Methods + // =========================================================== + + private static native void nativeTouchesBegin(final int pID, final float pX, final float pY); + private static native void nativeTouchesEnd(final int pID, final float pX, final float pY); + private static native void nativeTouchesMove(final int[] pIDs, final float[] pXs, final float[] pYs); + private static native void nativeTouchesCancel(final int[] pIDs, final float[] pXs, final float[] pYs); + private static native boolean nativeKeyDown(final int pKeyCode); + private static native void nativeRender(); + private static native void nativeInit(final int pWidth, final int pHeight); + private static native void nativeOnPause(); + private static native void nativeOnResume(); + + public void handleActionDown(final int pID, final float pX, final float pY) { + Cocos2dxRenderer.nativeTouchesBegin(pID, pX, pY); + } + + public void handleActionUp(final int pID, final float pX, final float pY) { + Cocos2dxRenderer.nativeTouchesEnd(pID, pX, pY); + } + + public void handleActionCancel(final int[] pIDs, final float[] pXs, final float[] pYs) { + Cocos2dxRenderer.nativeTouchesCancel(pIDs, pXs, pYs); + } + + public void handleActionMove(final int[] pIDs, final float[] pXs, final float[] pYs) { + Cocos2dxRenderer.nativeTouchesMove(pIDs, pXs, pYs); + } + + public void handleKeyDown(final int pKeyCode) { + Cocos2dxRenderer.nativeKeyDown(pKeyCode); + } + + public void handleOnPause() { + Cocos2dxRenderer.nativeOnPause(); + } + + public void handleOnResume() { + Cocos2dxRenderer.nativeOnResume(); + } + + private static native void nativeInsertText(final String pText); + private static native void nativeDeleteBackward(); + private static native String nativeGetContentText(); + + public void handleInsertText(final String pText) { + Cocos2dxRenderer.nativeInsertText(pText); + } + + public void handleDeleteBackward() { + Cocos2dxRenderer.nativeDeleteBackward(); + } + + public String getContentText() { + return Cocos2dxRenderer.nativeGetContentText(); + } + + // =========================================================== + // Inner and Anonymous Classes + // =========================================================== +} diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java new file mode 100644 index 0000000000..0b3c0bec14 --- /dev/null +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java @@ -0,0 +1,263 @@ +/**************************************************************************** +Copyright (c) 2010-2011 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + ****************************************************************************/ +package org.cocos2dx.lib; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +import android.content.Context; +import android.media.AudioManager; +import android.media.SoundPool; +import android.util.Log; + +public class Cocos2dxSound { + // =========================================================== + // Constants + // =========================================================== + + private static final String TAG = "Cocos2dxSound"; + + // =========================================================== + // Fields + // =========================================================== + + private final Context mContext; + private SoundPool mSoundPool; + private float mLeftVolume; + private float mRightVolume; + + // sound path and stream ids map + // a file may be played many times at the same time + // so there is an array map to a file path + private final HashMap> mPathStreamIDsMap = new HashMap>(); + + private final HashMap mPathSoundIDMap = new HashMap(); + + private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5; + private static final float SOUND_RATE = 1.0f; + private static final int SOUND_PRIORITY = 1; + private static final int SOUND_QUALITY = 5; + + private final static int INVALID_SOUND_ID = -1; + private final static int INVALID_STREAM_ID = -1; + + // =========================================================== + // Constructors + // =========================================================== + + public Cocos2dxSound(final Context pContext) { + this.mContext = pContext; + + this.initData(); + } + + private void initData() { + this.mSoundPool = new SoundPool(Cocos2dxSound.MAX_SIMULTANEOUS_STREAMS_DEFAULT, AudioManager.STREAM_MUSIC, Cocos2dxSound.SOUND_QUALITY); + + this.mLeftVolume = 0.5f; + this.mRightVolume = 0.5f; + } + + // =========================================================== + // Getter & Setter + // =========================================================== + + // =========================================================== + // Methods for/from SuperClass/Interfaces + // =========================================================== + + // =========================================================== + // Methods + // =========================================================== + + public int preloadEffect(final String pPath) { + Integer soundID = this.mPathSoundIDMap.get(pPath); + + if (soundID == null) { + soundID = this.createSoundIDFromAsset(pPath); + this.mPathSoundIDMap.put(pPath, soundID); + } + + return soundID; + } + + public void unloadEffect(final String pPath) { + // stop effects + final ArrayList streamIDs = this.mPathStreamIDsMap.get(pPath); + if (streamIDs != null) { + for (final Integer pStreamID : streamIDs) { + this.mSoundPool.stop(pStreamID); + } + } + this.mPathStreamIDsMap.remove(pPath); + + // unload effect + final Integer soundID = this.mPathSoundIDMap.get(pPath); + this.mSoundPool.unload(soundID); + this.mPathSoundIDMap.remove(pPath); + } + + public int playEffect(final String pPath, final boolean pLoop) { + Integer soundID = this.mPathSoundIDMap.get(pPath); + int streamID = Cocos2dxSound.INVALID_STREAM_ID; + + if (soundID != null) { + // play sound + streamID = this.mSoundPool.play(soundID.intValue(), this.mLeftVolume, this.mRightVolume, Cocos2dxSound.SOUND_PRIORITY, pLoop ? -1 : 0, Cocos2dxSound.SOUND_RATE); + + // record stream id + ArrayList streamIDs = this.mPathStreamIDsMap.get(pPath); + if (streamIDs == null) { + streamIDs = new ArrayList(); + this.mPathStreamIDsMap.put(pPath, streamIDs); + } + streamIDs.add(streamID); + } else { + // the effect is not prepared + soundID = this.preloadEffect(pPath); + if (soundID == Cocos2dxSound.INVALID_SOUND_ID) { + // can not preload effect + return Cocos2dxSound.INVALID_SOUND_ID; + } + + /* + * Someone reports that, it can not play effect for the first time. + * If you are lucky to meet it. There are two ways to resolve it. 1. + * Add some delay here. I don't know how long it is, so I don't add + * it here. 2. If you use 2.2(API level 8), you can call + * SoundPool.setOnLoadCompleteListener() to play the effect. Because + * the method is supported from 2.2, so I can't use it here. + */ + this.playEffect(pPath, pLoop); + } + + return streamID; + } + + public void stopEffect(final int pStreamID) { + this.mSoundPool.stop(pStreamID); + + // remove record + for (final String pPath : this.mPathStreamIDsMap.keySet()) { + if (this.mPathStreamIDsMap.get(pPath).contains(pStreamID)) { + this.mPathStreamIDsMap.get(pPath).remove(this.mPathStreamIDsMap.get(pPath).indexOf(pStreamID)); + break; + } + } + } + + public void pauseEffect(final int pStreamID) { + this.mSoundPool.pause(pStreamID); + } + + public void resumeEffect(final int pStreamID) { + this.mSoundPool.resume(pStreamID); + } + + public void pauseAllEffects() { + this.mSoundPool.autoPause(); + } + + public void resumeAllEffects() { + // autoPause() is available since level 8 + this.mSoundPool.autoResume(); + } + + @SuppressWarnings("unchecked") + public void stopAllEffects() { + // stop effects + if (!this.mPathStreamIDsMap.isEmpty()) { + final Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); + while (iter.hasNext()) { + final Map.Entry> entry = (Map.Entry>) iter.next(); + for (final int pStreamID : entry.getValue()) { + this.mSoundPool.stop(pStreamID); + } + } + } + + // remove records + this.mPathStreamIDsMap.clear(); + } + + public float getEffectsVolume() { + return (this.mLeftVolume + this.mRightVolume) / 2; + } + + public void setEffectsVolume(float pVolume) { + // pVolume should be in [0, 1.0] + if (pVolume < 0) { + pVolume = 0; + } + if (pVolume > 1) { + pVolume = 1; + } + + this.mLeftVolume = this.mRightVolume = pVolume; + + // change the volume of playing sounds + if (!this.mPathStreamIDsMap.isEmpty()) { + final Iterator>> iter = this.mPathStreamIDsMap.entrySet().iterator(); + while (iter.hasNext()) { + final Entry> entry = iter.next(); + for (final int pStreamID : entry.getValue()) { + this.mSoundPool.setVolume(pStreamID, this.mLeftVolume, this.mRightVolume); + } + } + } + } + + public void end() { + this.mSoundPool.release(); + this.mPathStreamIDsMap.clear(); + this.mPathSoundIDMap.clear(); + + this.mLeftVolume = 0.5f; + this.mRightVolume = 0.5f; + } + + public int createSoundIDFromAsset(final String pPath) { + int soundID = Cocos2dxSound.INVALID_SOUND_ID; + + try { + if (pPath.startsWith("/")) { + soundID = this.mSoundPool.load(pPath, 0); + } else { + soundID = this.mSoundPool.load(this.mContext.getAssets().openFd(pPath), 0); + } + } catch (final Exception e) { + soundID = Cocos2dxSound.INVALID_SOUND_ID; + Log.e(Cocos2dxSound.TAG, "error: " + e.getMessage(), e); + } + + return soundID; + } + + // =========================================================== + // Inner and Anonymous Classes + // =========================================================== +} diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTextInputWraper.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTextInputWraper.java new file mode 100644 index 0000000000..e3a4685e4d --- /dev/null +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTextInputWraper.java @@ -0,0 +1,153 @@ +/**************************************************************************** +Copyright (c) 2010-2011 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + ****************************************************************************/ +package org.cocos2dx.lib; + +import android.content.Context; +import android.text.Editable; +import android.text.TextWatcher; +import android.util.Log; +import android.view.KeyEvent; +import android.view.inputmethod.InputMethodManager; +import android.widget.TextView; +import android.widget.TextView.OnEditorActionListener; + +public class Cocos2dxTextInputWraper implements TextWatcher, OnEditorActionListener { + // =========================================================== + // Constants + // =========================================================== + + private static final String TAG = Cocos2dxTextInputWraper.class.getSimpleName(); + + // =========================================================== + // Fields + // =========================================================== + + private final Cocos2dxGLSurfaceView mCocos2dxGLSurfaceView; + private String mText; + private String mOriginText; + + // =========================================================== + // Constructors + // =========================================================== + + public Cocos2dxTextInputWraper(final Cocos2dxGLSurfaceView pCocos2dxGLSurfaceView) { + this.mCocos2dxGLSurfaceView = pCocos2dxGLSurfaceView; + } + + // =========================================================== + // Getter & Setter + // =========================================================== + + private boolean isFullScreenEdit() { + final TextView textField = this.mCocos2dxGLSurfaceView.getCocos2dxEditText(); + final InputMethodManager imm = (InputMethodManager) textField.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + return imm.isFullscreenMode(); + } + + public void setOriginText(final String pOriginText) { + this.mOriginText = pOriginText; + } + + // =========================================================== + // Methods for/from SuperClass/Interfaces + // =========================================================== + + @Override + public void afterTextChanged(final Editable s) { + if (this.isFullScreenEdit()) { + return; + } + + if (BuildConfig.DEBUG) { + Log.d(TAG, "afterTextChanged: " + s); + } + int nModified = s.length() - this.mText.length(); + if (nModified > 0) { + final String insertText = s.subSequence(this.mText.length(), s.length()).toString(); + this.mCocos2dxGLSurfaceView.insertText(insertText); + if (BuildConfig.DEBUG) { + Log.d(TAG, "insertText(" + insertText + ")"); + } + } else { + for (; nModified < 0; ++nModified) { + this.mCocos2dxGLSurfaceView.deleteBackward(); + if (BuildConfig.DEBUG) { + Log.d(TAG, "deleteBackward"); + } + } + } + this.mText = s.toString(); + } + + @Override + public void beforeTextChanged(final CharSequence pCharSequence, final int start, final int count, final int after) { + if (BuildConfig.DEBUG) { + Log.d(TAG, "beforeTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",after: " + after); + } + this.mText = pCharSequence.toString(); + } + + @Override + public void onTextChanged(final CharSequence pCharSequence, final int start, final int before, final int count) { + + } + + @Override + public boolean onEditorAction(final TextView pTextView, final int pActionID, final KeyEvent pKeyEvent) { + if (this.mCocos2dxGLSurfaceView.getCocos2dxEditText() == pTextView && this.isFullScreenEdit()) { + // user press the action button, delete all old text and insert new text + for (int i = this.mOriginText.length(); i > 0; i--) { + this.mCocos2dxGLSurfaceView.deleteBackward(); + if (BuildConfig.DEBUG) { + Log.d(TAG, "deleteBackward"); + } + } + String text = pTextView.getText().toString(); + + /* If user input nothing, translate "\n" to engine. */ + if (text.compareTo("") == 0) { + text = "\n"; + } + + if ('\n' != text.charAt(text.length() - 1)) { + text += '\n'; + } + + final String insertText = text; + this.mCocos2dxGLSurfaceView.insertText(insertText); + if (BuildConfig.DEBUG) { + Log.d(TAG, "insertText(" + insertText + ")"); + } + } + return false; + } + + // =========================================================== + // Methods + // =========================================================== + + // =========================================================== + // Inner and Anonymous Classes + // =========================================================== +} \ No newline at end of file diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTypefaces.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTypefaces.java new file mode 100644 index 0000000000..901b38153b --- /dev/null +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTypefaces.java @@ -0,0 +1,71 @@ +/**************************************************************************** +Copyright (c) 2010-2011 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + ****************************************************************************/ +package org.cocos2dx.lib; + +import java.util.HashMap; + +import android.content.Context; +import android.graphics.Typeface; + +public class Cocos2dxTypefaces { + // =========================================================== + // Constants + // =========================================================== + + // =========================================================== + // Fields + // =========================================================== + + private static final HashMap sTypefaceCache = new HashMap(); + + // =========================================================== + // Constructors + // =========================================================== + + // =========================================================== + // Getter & Setter + // =========================================================== + + // =========================================================== + // Methods for/from SuperClass/Interfaces + // =========================================================== + + // =========================================================== + // Methods + // =========================================================== + + public static synchronized Typeface get(final Context pContext, final String pAssetName) { + if (!Cocos2dxTypefaces.sTypefaceCache.containsKey(pAssetName)) { + final Typeface typeface = Typeface.createFromAsset(pContext.getAssets(), pAssetName); + Cocos2dxTypefaces.sTypefaceCache.put(pAssetName, typeface); + } + + return Cocos2dxTypefaces.sTypefaceCache.get(pAssetName); + } + + // =========================================================== + // Inner and Anonymous Classes + // =========================================================== + +} diff --git a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxAccelerometer.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxAccelerometer.java deleted file mode 100644 index c515349cab..0000000000 --- a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxAccelerometer.java +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import android.content.Context; -import android.content.res.Configuration; -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; -import android.view.Display; -import android.view.Surface; -import android.view.WindowManager; - -/** - * - * This class is used for controlling the Accelerometer - * - */ -public class Cocos2dxAccelerometer implements SensorEventListener { - - private static final String TAG = "Cocos2dxAccelerometer"; - private Context mContext; - private SensorManager mSensorManager; - private Sensor mAccelerometer; - private int mNaturalOrientation; - - public Cocos2dxAccelerometer(Context context){ - mContext = context; - - //Get an instance of the SensorManager - mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE); - mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); - - Display display = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); - mNaturalOrientation = display.getOrientation(); - } - - public void enable() { - mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME); - } - - public void disable () { - mSensorManager.unregisterListener(this); - } - - @Override - public void onSensorChanged(SensorEvent event) { - - if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER){ - return; - } - - float x = event.values[0]; - float y = event.values[1]; - float z = event.values[2]; - - /* - * Because the axes are not swapped when the device's screen orientation changes. - * So we should swap it here. - * In tablets such as Motorola Xoom, the default orientation is landscape, so should - * consider this. - */ - int orientation = mContext.getResources().getConfiguration().orientation; - if ((orientation == Configuration.ORIENTATION_LANDSCAPE) && (mNaturalOrientation != Surface.ROTATION_0)){ - float tmp = x; - x = -y; - y = tmp; - } - else if ((orientation == Configuration.ORIENTATION_PORTRAIT) && (mNaturalOrientation != Surface.ROTATION_0)) - { - float tmp = x; - x = y; - y = -tmp; - } - - onSensorChanged(x, y, z, event.timestamp); - // Log.d(TAG, "x = " + event.values[0] + " y = " + event.values[1] + " z = " + event.values[2]); - } - - @Override - public void onAccuracyChanged(Sensor sensor, int accuracy) { - } - - private static native void onSensorChanged(float x, float y, float z, long timeStamp); -} diff --git a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxActivity.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxActivity.java deleted file mode 100644 index 952d5148fb..0000000000 --- a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxActivity.java +++ /dev/null @@ -1,346 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -package org.cocos2dx.lib; - -import java.lang.ref.WeakReference; - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.Dialog; -import android.content.DialogInterface; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.content.res.AssetManager; -import android.os.Build; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.util.DisplayMetrics; -import android.util.Log; - -public class Cocos2dxActivity extends Activity{ - - protected Cocos2dxGLSurfaceView mGLView; - private static Cocos2dxMusic backgroundMusicPlayer; - private static Cocos2dxSound soundPlayer; - private static Cocos2dxAccelerometer accelerometer; - private static AssetManager assetManager; - private static boolean accelerometerEnabled = false; - private static Handler handler; - private final static int HANDLER_SHOW_DIALOG = 1; - private final static int HANDLER_SHOW_EDITBOX_DIALOG = 2; - - private static String packageName; - - private static native void nativeSetPaths(String apkPath); - private static native void nativeSetEditboxText(byte[] text); - - - static class ShowDialogHandler extends Handler { - WeakReference mActivity; - - ShowDialogHandler(Cocos2dxActivity activity) { - mActivity = new WeakReference(activity); - } - - @Override - public void handleMessage(Message msg) { - Cocos2dxActivity theActivity = mActivity.get(); - switch(msg.what) { - case HANDLER_SHOW_DIALOG: - theActivity.showDialog(((DialogMessage)msg.obj).title, ((DialogMessage)msg.obj).message); - break; - case HANDLER_SHOW_EDITBOX_DIALOG: - theActivity.onShowEditBoxDialog((EditBoxMessage)msg.obj); - break; - } - } - }; - - public Cocos2dxGLSurfaceView getGLView() { - return mGLView; - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // get frame size - DisplayMetrics dm = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(dm); - accelerometer = new Cocos2dxAccelerometer(this); - - // init media player and sound player - backgroundMusicPlayer = new Cocos2dxMusic(this); - soundPlayer = new Cocos2dxSound(this); - - // init asset manager for jni call - assetManager = getAssets(); - - // init bitmap context - Cocos2dxBitmap.setContext(this); - - handler = new ShowDialogHandler(this); - } - - public static String getDeviceModel(){ - return Build.MODEL; - } - - public static AssetManager getAssetManager() { - return assetManager; - } - - public static String getCurrentLanguage() { - String languageName = java.util.Locale.getDefault().getLanguage(); - return languageName; - } - - public static void showMessageBox(String title, String message){ - Message msg = new Message(); - msg.what = HANDLER_SHOW_DIALOG; - msg.obj = new DialogMessage(title, message); - - handler.sendMessage(msg); - } - - public static void enableAccelerometer() { - accelerometerEnabled = true; - accelerometer.enable(); - } - - public static void disableAccelerometer() { - accelerometerEnabled = false; - accelerometer.disable(); - } - - public static void preloadBackgroundMusic(String path){ - backgroundMusicPlayer.preloadBackgroundMusic(path); - } - - public static void playBackgroundMusic(String path, boolean isLoop){ - backgroundMusicPlayer.playBackgroundMusic(path, isLoop); - } - - public static void stopBackgroundMusic(){ - backgroundMusicPlayer.stopBackgroundMusic(); - } - - public static void pauseBackgroundMusic(){ - backgroundMusicPlayer.pauseBackgroundMusic(); - } - - public static void resumeBackgroundMusic(){ - backgroundMusicPlayer.resumeBackgroundMusic(); - } - - public static void rewindBackgroundMusic(){ - backgroundMusicPlayer.rewindBackgroundMusic(); - } - - public static boolean isBackgroundMusicPlaying(){ - return backgroundMusicPlayer.isBackgroundMusicPlaying(); - } - - public static float getBackgroundMusicVolume(){ - return backgroundMusicPlayer.getBackgroundVolume(); - } - - public static void setBackgroundMusicVolume(float volume){ - backgroundMusicPlayer.setBackgroundVolume(volume); - } - - public static int playEffect(String path, boolean isLoop){ - return soundPlayer.playEffect(path, isLoop); - } - - public static void stopEffect(int soundId){ - soundPlayer.stopEffect(soundId); - } - - public static void pauseEffect(int soundId){ - soundPlayer.pauseEffect(soundId); - } - - public static void resumeEffect(int soundId){ - soundPlayer.resumeEffect(soundId); - } - - public static float getEffectsVolume(){ - return soundPlayer.getEffectsVolume(); - } - - public static void setEffectsVolume(float volume){ - soundPlayer.setEffectsVolume(volume); - } - - public static void preloadEffect(String path){ - soundPlayer.preloadEffect(path); - } - - public static void unloadEffect(String path){ - soundPlayer.unloadEffect(path); - } - - public static void stopAllEffects(){ - soundPlayer.stopAllEffects(); - } - - public static void pauseAllEffects(){ - soundPlayer.pauseAllEffects(); - } - - public static void resumeAllEffects(){ - soundPlayer.resumeAllEffects(); - } - - public static void end(){ - backgroundMusicPlayer.end(); - soundPlayer.end(); - } - - public static String getCocos2dxPackageName(){ - return packageName; - } - - public static void terminateProcess(){ - android.os.Process.killProcess(android.os.Process.myPid()); - } - - @Override - protected void onResume() { - super.onResume(); - if (accelerometerEnabled) { - accelerometer.enable(); - } - } - - @Override - protected void onPause() { - super.onPause(); - if (accelerometerEnabled) { - accelerometer.disable(); - } - } - - protected void setPackageName(String packageName) { - Cocos2dxActivity.packageName = packageName; - - String apkFilePath = ""; - ApplicationInfo appInfo = null; - PackageManager packMgmr = getApplication().getPackageManager(); - try { - appInfo = packMgmr.getApplicationInfo(packageName, 0); - } catch (NameNotFoundException e) { - e.printStackTrace(); - throw new RuntimeException("Unable to locate assets, aborting..."); - } - apkFilePath = appInfo.sourceDir; - Log.w("apk path", apkFilePath); - - // add this link at the renderer class - nativeSetPaths(apkFilePath); - } - - private void showDialog(String title, String message){ - Dialog dialog = new AlertDialog.Builder(this) - .setTitle(title) - .setMessage(message) - .setPositiveButton("Ok", - new DialogInterface.OnClickListener() - { - public void onClick(DialogInterface dialog, int whichButton){ - - } - }).create(); - - dialog.show(); - } - - private static void showEditBoxDialog(String title, String content, int inputMode, int inputFlag, int returnType, int maxLength) - { - Message msg = new Message(); - msg.what = HANDLER_SHOW_EDITBOX_DIALOG; - msg.obj = new EditBoxMessage(title, content, inputMode, inputFlag, returnType, maxLength); - handler.sendMessage(msg); - } - - private void onShowEditBoxDialog(EditBoxMessage msg) - { - Dialog dialog = new Cocos2dxEditBoxDialog(this, msg); - dialog.show(); - } - - public void setEditBoxResult(String editResult) - { - Log.i("editbox_content", editResult); - - try - { - final byte[] bytesUTF8 = editResult.getBytes("UTF8"); - // pass utf8 string from editbox activity to native. - // Should invoke native method in GL thread. - mGLView.queueEvent(new Runnable() { - @Override - public void run() { - nativeSetEditboxText(bytesUTF8); - } - }); - } - catch (java.io.UnsupportedEncodingException e) - { - e.printStackTrace(); - } - } -} - -class DialogMessage { - public String title; - public String message; - - public DialogMessage(String title, String message){ - this.message = message; - this.title = title; - } -} - -class EditBoxMessage { - public String title; - public String content; - public int inputMode; - public int inputFlag; - public int returnType; - public int maxLength; - - public EditBoxMessage(String title, String content, int inputMode, int inputFlag, int returnType, int maxLength){ - this.content = content; - this.title = title; - this.inputMode = inputMode; - this.inputFlag = inputFlag; - this.returnType = returnType; - this.maxLength = maxLength; - } -} diff --git a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxBitmap.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxBitmap.java deleted file mode 100644 index 395400b779..0000000000 --- a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxBitmap.java +++ /dev/null @@ -1,455 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.LinkedList; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Rect; -import android.graphics.Typeface; -import android.graphics.Paint.Align; -import android.graphics.Paint.FontMetricsInt; -import android.text.TextPaint; -import android.text.TextUtils; -import android.util.Log; - -public class Cocos2dxBitmap{ - /* - * The values are the same as cocos2dx/platform/CCImage.h. - */ - private static final int HALIGNCENTER = 3; - private static final int HALIGNLEFT = 1; - private static final int HALIGNRIGHT = 2; - // vertical alignment - private static final int VALIGNTOP = 1; - private static final int VALIGNBOTTOM = 2; - private static final int VALIGNCENTER = 3; - - private static Context context; - - public static void setContext(Context context){ - Cocos2dxBitmap.context = context; - } - - /* - * @width: the width to draw, it can be 0 - * @height: the height to draw, it can be 0 - */ - public static void createTextBitmap(String content, String fontName, - int fontSize, int alignment, int width, int height){ - - content = refactorString(content); - Paint paint = newPaint(fontName, fontSize, alignment); - - TextProperty textProperty = computeTextProperty(content, paint, width, height); - - int bitmapTotalHeight = (height == 0 ? textProperty.totalHeight:height); - - // Draw text to bitmap - Bitmap bitmap = Bitmap.createBitmap(textProperty.maxWidth, - bitmapTotalHeight, Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - - // Draw string - FontMetricsInt fm = paint.getFontMetricsInt(); - int x = 0; - int y = computeY(fm, height, textProperty.totalHeight, alignment); - String[] lines = textProperty.lines; - for (String line : lines){ - x = computeX(paint, line, textProperty.maxWidth, alignment); - canvas.drawText(line, x, y, paint); - y += textProperty.heightPerLine; - } - - initNativeObject(bitmap); - } - - private static int computeX(Paint paint, String content, int w, int alignment){ - int ret = 0; - int hAlignment = alignment & 0x0F; - - switch (hAlignment){ - case HALIGNCENTER: - ret = w / 2; - break; - - // ret = 0 - case HALIGNLEFT: - break; - - case HALIGNRIGHT: - ret = w; - break; - - /* - * Default is align left. - * Should be same as newPaint(). - */ - default: - break; - } - - return ret; - } - - private static int computeY(FontMetricsInt fm, int constrainHeight, int totalHeight, int alignment) { - int y = -fm.top; - - if (constrainHeight > totalHeight) { - int vAlignment = (alignment >> 4) & 0x0F; - - switch (vAlignment) { - case VALIGNTOP: - y = -fm.top; - break; - case VALIGNCENTER: - y = -fm.top + (constrainHeight - totalHeight)/2; - break; - case VALIGNBOTTOM: - y = -fm.top + (constrainHeight - totalHeight); - break; - default: - break; - } - } - - return y; - } - - private static class TextProperty{ - // The max width of lines - int maxWidth; - // The height of all lines - int totalHeight; - int heightPerLine; - String[] lines; - - TextProperty(int w, int h, String[] lines){ - this.maxWidth = w; - this.heightPerLine = h; - this.totalHeight = h * lines.length; - this.lines = lines; - } - } - - private static TextProperty computeTextProperty(String content, Paint paint, - int maxWidth, int maxHeight){ - FontMetricsInt fm = paint.getFontMetricsInt(); - int h = (int)Math.ceil(fm.bottom - fm.top); - int maxContentWidth = 0; - - String[] lines = splitString(content, maxHeight, maxWidth, paint); - - if (maxWidth != 0){ - maxContentWidth = maxWidth; - } - else { - /* - * Compute the max width - */ - int temp = 0; - for (String line : lines){ - temp = (int)Math.ceil(paint.measureText(line, 0, line.length())); - if (temp > maxContentWidth){ - maxContentWidth = temp; - } - } - } - - return new TextProperty(maxContentWidth, h, lines); - } - - /* - * If maxWidth or maxHeight is not 0, - * split the string to fix the maxWidth and maxHeight. - */ - private static String[] splitString(String content, int maxHeight, int maxWidth, - Paint paint){ - String[] lines = content.split("\\n"); - String[] ret = null; - FontMetricsInt fm = paint.getFontMetricsInt(); - int heightPerLine = (int)Math.ceil(fm.bottom - fm.top); - int maxLines = maxHeight / heightPerLine; - - if (maxWidth != 0){ - LinkedList strList = new LinkedList(); - for (String line : lines){ - /* - * The width of line is exceed maxWidth, should divide it into - * two or more lines. - */ - int lineWidth = (int)Math.ceil(paint.measureText(line)); - if (lineWidth > maxWidth){ - strList.addAll(divideStringWithMaxWidth(paint, line, maxWidth)); - } - else{ - strList.add(line); - } - - /* - * Should not exceed the max height; - */ - if (maxLines > 0 && strList.size() >= maxLines){ - break; - } - } - - /* - * Remove exceeding lines - */ - if (maxLines > 0 && strList.size() > maxLines){ - while (strList.size() > maxLines){ - strList.removeLast(); - } - } - - ret = new String[strList.size()]; - strList.toArray(ret); - } else - if (maxHeight != 0 && lines.length > maxLines) { - /* - * Remove exceeding lines - */ - LinkedList strList = new LinkedList(); - for (int i = 0; i < maxLines; i++){ - strList.add(lines[i]); - } - ret = new String[strList.size()]; - strList.toArray(ret); - } - else { - ret = lines; - } - - return ret; - } - - private static LinkedList divideStringWithMaxWidth(Paint paint, String content, - int width){ - int charLength = content.length(); - int start = 0; - int tempWidth = 0; - LinkedList strList = new LinkedList(); - - /* - * Break a String into String[] by the width & should wrap the word - */ - for (int i = 1; i <= charLength; ++i){ - tempWidth = (int)Math.ceil(paint.measureText(content, start, i)); - if (tempWidth >= width){ - int lastIndexOfSpace = content.substring(0, i).lastIndexOf(" "); - - if (lastIndexOfSpace != -1 && lastIndexOfSpace > start){ - /** - * Should wrap the word - */ - strList.add(content.substring(start, lastIndexOfSpace)); - i = lastIndexOfSpace; - } - else { - /* - * Should not exceed the width - */ - if (tempWidth > width){ - strList.add(content.substring(start, i - 1)); - /* - * compute from previous char - */ - --i; - } - else { - strList.add(content.substring(start, i)); - } - } - - // remove spaces at the beginning of a new line - while(content.indexOf(i++) == ' ') { - } - - start = i; - } - } - - /* - * Add the last chars - */ - if (start < charLength){ - strList.add(content.substring(start)); - } - - return strList; - } - - private static Paint newPaint(String fontName, int fontSize, int alignment){ - Paint paint = new Paint(); - paint.setColor(Color.WHITE); - paint.setTextSize(fontSize); - paint.setAntiAlias(true); - - /* - * Set type face for paint, now it support .ttf file. - */ - if (fontName.endsWith(".ttf")){ - try { - //Typeface typeFace = Typeface.createFromAsset(context.getAssets(), fontName); - Typeface typeFace = Cocos2dxTypefaces.get(context, fontName); - paint.setTypeface(typeFace); - } catch (Exception e){ - Log.e("Cocos2dxBitmap", - "error to create ttf type face: " + fontName); - - /* - * The file may not find, use system font - */ - paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL)); - } - } - else { - paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL)); - } - - int hAlignment = alignment & 0x0F; - switch (hAlignment){ - case HALIGNCENTER: - paint.setTextAlign(Align.CENTER); - break; - - case HALIGNLEFT: - paint.setTextAlign(Align.LEFT); - break; - - case HALIGNRIGHT: - paint.setTextAlign(Align.RIGHT); - break; - - default: - paint.setTextAlign(Align.LEFT); - break; - } - - return paint; - } - - private static String refactorString(String str){ - // Avoid error when content is "" - if (str.compareTo("") == 0){ - return " "; - } - - /* - * If the font of "\n" is "" or "\n", insert " " in front of it. - * - * For example: - * "\nabc" -> " \nabc" - * "\nabc\n\n" -> " \nabc\n \n" - */ - StringBuilder strBuilder = new StringBuilder(str); - int start = 0; - int index = strBuilder.indexOf("\n"); - while (index != -1){ - if (index == 0 || strBuilder.charAt(index -1) == '\n'){ - strBuilder.insert(start, " "); - start = index + 2; - } else { - start = index + 1; - } - - if (start > strBuilder.length() || index == strBuilder.length()){ - break; - } - - index = strBuilder.indexOf("\n", start); - } - - return strBuilder.toString(); - } - - private static void initNativeObject(Bitmap bitmap){ - byte[] pixels = getPixels(bitmap); - if (pixels == null){ - return; - } - - nativeInitBitmapDC(bitmap.getWidth(), bitmap.getHeight(), pixels); - } - - private static byte[] getPixels(Bitmap bitmap){ - if (bitmap != null){ - byte[] pixels = new byte[bitmap.getWidth() * bitmap.getHeight() * 4]; - ByteBuffer buf = ByteBuffer.wrap(pixels); - buf.order(ByteOrder.nativeOrder()); - bitmap.copyPixelsToBuffer(buf); - return pixels; - } - - return null; - } - - private static native void nativeInitBitmapDC(int width, int height, byte[] pixels); - - private static int getFontSizeAccordingHeight(int height) - { - Paint paint = new Paint(); - Rect bounds = new Rect(); - - paint.setTypeface(Typeface.DEFAULT); - int incr_text_size = 1; - boolean found_desired_size = false; - - while (!found_desired_size) { - - paint.setTextSize(incr_text_size); - String text = "SghMNy"; - paint.getTextBounds(text, 0, text.length(), bounds); - - incr_text_size++; - - if (height - bounds.height() <= 2) { - found_desired_size = true; - } - Log.d("font size", "incr size:" + incr_text_size); - } - return incr_text_size; - } - - private static String getStringWithEllipsis(String originalText, float width, float fontSize){ - if(TextUtils.isEmpty(originalText)){ - return ""; - } - - TextPaint paint = new TextPaint(); - paint.setTypeface(Typeface.DEFAULT); - paint.setTextSize(fontSize); - - return TextUtils.ellipsize(originalText, paint, width, - TextUtils.TruncateAt.valueOf("END")).toString(); - } - -} diff --git a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java deleted file mode 100755 index 66e94e242c..0000000000 --- a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java +++ /dev/null @@ -1,338 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -package org.cocos2dx.lib; - -import android.app.Dialog; -import android.content.Context; -import android.graphics.drawable.ColorDrawable; -import android.os.Bundle; -import android.os.Handler; -import android.text.InputFilter; -import android.text.InputType; -import android.util.Log; -import android.util.TypedValue; -import android.view.KeyEvent; -import android.view.ViewGroup; -import android.view.WindowManager; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; -import android.widget.LinearLayout; -import android.widget.TextView; -import android.widget.TextView.OnEditorActionListener; - -public class Cocos2dxEditBoxDialog extends Dialog { - - /** - * The user is allowed to enter any text, including line breaks. - */ - private final int kEditBoxInputModeAny = 0; - - /** - * The user is allowed to enter an e-mail address. - */ - private final int kEditBoxInputModeEmailAddr = 1; - - /** - * The user is allowed to enter an integer value. - */ - private final int kEditBoxInputModeNumeric = 2; - - /** - * The user is allowed to enter a phone number. - */ - private final int kEditBoxInputModePhoneNumber = 3; - - /** - * The user is allowed to enter a URL. - */ - private final int kEditBoxInputModeUrl = 4; - - /** - * The user is allowed to enter a real number value. - * This extends kEditBoxInputModeNumeric by allowing a decimal point. - */ - private final int kEditBoxInputModeDecimal = 5; - - /** - * The user is allowed to enter any text, except for line breaks. - */ - private final int kEditBoxInputModeSingleLine = 6; - - - /** - * Indicates that the text entered is confidential data that should be - * obscured whenever possible. This implies EDIT_BOX_INPUT_FLAG_SENSITIVE. - */ - private final int kEditBoxInputFlagPassword = 0; - - /** - * Indicates that the text entered is sensitive data that the - * implementation must never store into a dictionary or table for use - * in predictive, auto-completing, or other accelerated input schemes. - * A credit card number is an example of sensitive data. - */ - private final int kEditBoxInputFlagSensitive = 1; - - /** - * This flag is a hint to the implementation that during text editing, - * the initial letter of each word should be capitalized. - */ - private final int kEditBoxInputFlagInitialCapsWord = 2; - - /** - * This flag is a hint to the implementation that during text editing, - * the initial letter of each sentence should be capitalized. - */ - private final int kEditBoxInputFlagInitialCapsSentence = 3; - - /** - * Capitalize all characters automatically. - */ - private final int kEditBoxInputFlagInitialCapsAllCharacters = 4; - - private final int kKeyboardReturnTypeDefault = 0; - private final int kKeyboardReturnTypeDone = 1; - private final int kKeyboardReturnTypeSend = 2; - private final int kKeyboardReturnTypeSearch = 3; - private final int kKeyboardReturnTypeGo = 4; - - // - private EditText mInputEditText = null; - private TextView mTextViewTitle = null; - private int mInputMode = 0; - private int mInputFlag = 0; - private int mReturnType = 0; - private int mMaxLength = -1; - - private int mInputFlagConstraints = 0x00000; - private int mInputModeContraints = 0x00000; - private boolean mIsMultiline = false; - private Cocos2dxActivity mParentActivity = null; - private EditBoxMessage mMsg = null; - - public Cocos2dxEditBoxDialog(Context context, EditBoxMessage msg) { - //super(context, R.style.Theme_Translucent); - super(context, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen); - // TODO Auto-generated constructor stub - mParentActivity = (Cocos2dxActivity)context; - mMsg = msg; - } - - // Converting dips to pixels - private int convertDipsToPixels(float dips) - { - float scale = getContext().getResources().getDisplayMetrics().density; - return Math.round(dips * scale); - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - // TODO Auto-generated method stub - super.onCreate(savedInstanceState); - - getWindow().setBackgroundDrawable(new ColorDrawable(0x80000000)); - - LinearLayout layout = new LinearLayout(mParentActivity); - layout.setOrientation(LinearLayout.VERTICAL); - - LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup. - LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT); - - mTextViewTitle = new TextView(mParentActivity); - LinearLayout.LayoutParams textviewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.WRAP_CONTENT); - textviewParams.leftMargin = textviewParams.rightMargin = convertDipsToPixels(10); - mTextViewTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); - layout.addView(mTextViewTitle, textviewParams); - - mInputEditText = new EditText(mParentActivity); - LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT); - editTextParams.leftMargin = editTextParams.rightMargin = convertDipsToPixels(10); - - layout.addView(mInputEditText, editTextParams); - - setContentView(layout, layoutParams); - - getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - - mInputMode = mMsg.inputMode; - mInputFlag = mMsg.inputFlag; - mReturnType = mMsg.returnType; - mMaxLength = mMsg.maxLength; - - mTextViewTitle.setText(mMsg.title); - mInputEditText.setText(mMsg.content); - - int oldImeOptions = mInputEditText.getImeOptions(); - mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_FLAG_NO_EXTRACT_UI); - oldImeOptions = mInputEditText.getImeOptions(); - - switch (mInputMode) - { - case kEditBoxInputModeAny: - mInputModeContraints = - InputType.TYPE_CLASS_TEXT | - InputType.TYPE_TEXT_FLAG_MULTI_LINE; - break; - case kEditBoxInputModeEmailAddr: - mInputModeContraints = - InputType.TYPE_CLASS_TEXT | - InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; - break; - case kEditBoxInputModeNumeric: - mInputModeContraints = - InputType.TYPE_CLASS_NUMBER | - InputType.TYPE_NUMBER_FLAG_SIGNED; - break; - case kEditBoxInputModePhoneNumber: - mInputModeContraints = InputType.TYPE_CLASS_PHONE; - break; - case kEditBoxInputModeUrl: - mInputModeContraints = - InputType.TYPE_CLASS_TEXT | - InputType.TYPE_TEXT_VARIATION_URI; - break; - case kEditBoxInputModeDecimal: - mInputModeContraints = - InputType.TYPE_CLASS_NUMBER | - InputType.TYPE_NUMBER_FLAG_DECIMAL | - InputType.TYPE_NUMBER_FLAG_SIGNED; - break; - case kEditBoxInputModeSingleLine: - mInputModeContraints = InputType.TYPE_CLASS_TEXT; - break; - default: - - break; - } - - if ( mIsMultiline ) { - mInputModeContraints |= InputType.TYPE_TEXT_FLAG_MULTI_LINE; - } - - mInputEditText.setInputType(mInputModeContraints | mInputFlagConstraints); - - switch (mInputFlag) - { - case kEditBoxInputFlagPassword: - mInputFlagConstraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD; - break; - case kEditBoxInputFlagSensitive: - mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS; - break; - case kEditBoxInputFlagInitialCapsWord: - mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_WORDS; - break; - case kEditBoxInputFlagInitialCapsSentence: - mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; - break; - case kEditBoxInputFlagInitialCapsAllCharacters: - mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS; - break; - default: - break; - } - mInputEditText.setInputType(mInputFlagConstraints | mInputModeContraints); - - switch (mReturnType) { - case kKeyboardReturnTypeDefault: - mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE); - break; - case kKeyboardReturnTypeDone: - mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_DONE); - break; - case kKeyboardReturnTypeSend: - mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEND); - break; - case kKeyboardReturnTypeSearch: - mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEARCH); - break; - case kKeyboardReturnTypeGo: - mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_GO); - break; - default: - mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE); - break; - } - - if (mMaxLength > 0) { - mInputEditText.setFilters( - new InputFilter[] { - new InputFilter.LengthFilter(mMaxLength) - } - ); - } - - Handler initHandler = new Handler(); - initHandler.postDelayed(new Runnable() { - public void run() { - mInputEditText.requestFocus(); - mInputEditText.setSelection(mInputEditText.length()); - openKeyboard(); - } - }, 200); - - mInputEditText.setOnEditorActionListener(new OnEditorActionListener() { - @Override - public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - // if user didn't set keyboard type, - // this callback will be invoked twice with 'KeyEvent.ACTION_DOWN' and 'KeyEvent.ACTION_UP' - if (actionId != EditorInfo.IME_NULL - || (actionId == EditorInfo.IME_NULL - && event != null - && event.getAction() == KeyEvent.ACTION_DOWN)) - { - //Log.d("EditBox", "actionId: "+actionId +",event: "+event); - mParentActivity.setEditBoxResult(mInputEditText.getText().toString()); - closeKeyboard(); - dismiss(); - return true; - } - return false; - } - }); - } - - private void openKeyboard() { - InputMethodManager imm = (InputMethodManager) mParentActivity.getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(mInputEditText, 0); - Log.d("Cocos2dxEditBox", "openKeyboard"); - } - - private void closeKeyboard() { - InputMethodManager imm = (InputMethodManager) mParentActivity.getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(mInputEditText.getWindowToken(), 0); - Log.d("Cocos2dxEditBox", "closeKeyboard"); - } - - @Override - protected void onStop() { - // TODO Auto-generated method stub - super.onStop(); - Log.d("EditBox", "onStop..."); - } -} diff --git a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxEditText.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxEditText.java deleted file mode 100644 index 1c9778293f..0000000000 --- a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxEditText.java +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -package org.cocos2dx.lib; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.KeyEvent; -import android.widget.EditText; - -public class Cocos2dxEditText extends EditText { - - private Cocos2dxGLSurfaceView mView; - - public Cocos2dxEditText(Context context) { - super(context); - // TODO Auto-generated constructor stub - } - - public Cocos2dxEditText(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public Cocos2dxEditText(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - public void setMainView(Cocos2dxGLSurfaceView glSurfaceView) { - mView = glSurfaceView; - } - - /* - * Let GlSurfaceView get focus if back key is input - */ - public boolean onKeyDown(int keyCode, KeyEvent event) { - super.onKeyDown(keyCode, event); - - if (keyCode == KeyEvent.KEYCODE_BACK) { - mView.requestFocus(); - } - - return true; - } -} diff --git a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java deleted file mode 100644 index e7c4721cf3..0000000000 --- a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java +++ /dev/null @@ -1,417 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import android.content.Context; -import android.opengl.GLSurfaceView; -import android.os.Handler; -import android.os.Message; -import android.text.Editable; -import android.text.TextWatcher; -import android.util.AttributeSet; -import android.util.Log; -import android.view.KeyEvent; -import android.view.MotionEvent; -import android.view.inputmethod.InputMethodManager; -import android.widget.TextView; -import android.widget.TextView.OnEditorActionListener; - -class TextInputWraper implements TextWatcher, OnEditorActionListener { - - private static final Boolean debug = false; - private void LogD(String msg) { - if (debug) Log.d("TextInputFilter", msg); - } - - private Cocos2dxGLSurfaceView mMainView; - private String mText; - private String mOriginText; - - private Boolean isFullScreenEdit() { - InputMethodManager imm = (InputMethodManager)mMainView.getTextField().getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - return imm.isFullscreenMode(); - } - - public TextInputWraper(Cocos2dxGLSurfaceView view) { - mMainView = view; - } - - public void setOriginText(String text) { - mOriginText = text; - } - - @Override - public void afterTextChanged(Editable s) { - if (isFullScreenEdit()) { - return; - } - - LogD("afterTextChanged: " + s); - int nModified = s.length() - mText.length(); - if (nModified > 0) { - final String insertText = s.subSequence(mText.length(), s.length()).toString(); - mMainView.insertText(insertText); - LogD("insertText(" + insertText + ")"); - } - else { - for (; nModified < 0; ++nModified) { - mMainView.deleteBackward(); - LogD("deleteBackward"); - } - } - mText = s.toString(); - } - - @Override - public void beforeTextChanged(CharSequence s, int start, int count, - int after) { - LogD("beforeTextChanged(" + s + ")start: " + start + ",count: " + count + ",after: " + after); - mText = s.toString(); - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - - @Override - public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - if (mMainView.getTextField() == v && isFullScreenEdit()) { - // user press the action button, delete all old text and insert new text - for (int i = mOriginText.length(); i > 0; --i) { - mMainView.deleteBackward(); - LogD("deleteBackward"); - } - String text = v.getText().toString(); - - /* - * If user input nothing, translate "\n" to engine. - */ - if (text.compareTo("") == 0){ - text = "\n"; - } - - if ('\n' != text.charAt(text.length() - 1)) { - text += '\n'; - } - - final String insertText = text; - mMainView.insertText(insertText); - LogD("insertText(" + insertText + ")"); - } - return false; - } -} - -public class Cocos2dxGLSurfaceView extends GLSurfaceView { - - static private Cocos2dxGLSurfaceView mainView; - - private static final String TAG = Cocos2dxGLSurfaceView.class.getCanonicalName(); - private Cocos2dxRenderer mRenderer; - - private static final boolean debug = false; - - /////////////////////////////////////////////////////////////////////////// - // for initialize - /////////////////////////////////////////////////////////////////////////// - public Cocos2dxGLSurfaceView(Context context) { - super(context); - initView(); - } - - public Cocos2dxGLSurfaceView(Context context, AttributeSet attrs) { - super(context, attrs); - initView(); - } - - public void setCocos2dxRenderer(Cocos2dxRenderer renderer){ - mRenderer = renderer; - setRenderer(mRenderer); - } - - protected void initView() { - setFocusableInTouchMode(true); - - textInputWraper = new TextInputWraper(this); - - handler = new Handler(){ - public void handleMessage(Message msg){ - switch(msg.what){ - case HANDLER_OPEN_IME_KEYBOARD: - if (null != mTextField && mTextField.requestFocus()) { - mTextField.removeTextChangedListener(textInputWraper); - mTextField.setText(""); - String text = (String)msg.obj; - mTextField.append(text); - textInputWraper.setOriginText(text); - mTextField.addTextChangedListener(textInputWraper); - InputMethodManager imm = (InputMethodManager)mainView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(mTextField, 0); - Log.d("GLSurfaceView", "showSoftInput"); - } - break; - - case HANDLER_CLOSE_IME_KEYBOARD: - if (null != mTextField) { - mTextField.removeTextChangedListener(textInputWraper); - InputMethodManager imm = (InputMethodManager)mainView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(mTextField.getWindowToken(), 0); - Log.d("GLSurfaceView", "HideSoftInput"); - } - break; - } - } - }; - - mainView = this; - } - - public void onPause(){ - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleOnPause(); - } - }); - - super.onPause(); - } - - public void onResume(){ - super.onResume(); - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleOnResume(); - } - }); - } - - /////////////////////////////////////////////////////////////////////////// - // for text input - /////////////////////////////////////////////////////////////////////////// - private final static int HANDLER_OPEN_IME_KEYBOARD = 2; - private final static int HANDLER_CLOSE_IME_KEYBOARD = 3; - private static Handler handler; - private static TextInputWraper textInputWraper; - private Cocos2dxEditText mTextField; - - public TextView getTextField() { - return mTextField; - } - - public void setTextField(Cocos2dxEditText view) { - mTextField = view; - if (null != mTextField && null != textInputWraper) { - mTextField.setOnEditorActionListener(textInputWraper); - mTextField.setMainView(this); - this.requestFocus(); - } - } - - public static void openIMEKeyboard() { - Message msg = new Message(); - msg.what = HANDLER_OPEN_IME_KEYBOARD; - msg.obj = mainView.getContentText(); - handler.sendMessage(msg); - - } - - private String getContentText() { - return mRenderer.getContentText(); - } - - public static void closeIMEKeyboard() { - Message msg = new Message(); - msg.what = HANDLER_CLOSE_IME_KEYBOARD; - handler.sendMessage(msg); - } - - public void insertText(final String text) { - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleInsertText(text); - } - }); - } - - public void deleteBackward() { - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleDeleteBackward(); - } - }); - } - - /////////////////////////////////////////////////////////////////////////// - // for touch event - /////////////////////////////////////////////////////////////////////////// - - public boolean onTouchEvent(final MotionEvent event) { - // these data are used in ACTION_MOVE and ACTION_CANCEL - final int pointerNumber = event.getPointerCount(); - final int[] ids = new int[pointerNumber]; - final float[] xs = new float[pointerNumber]; - final float[] ys = new float[pointerNumber]; - - for (int i = 0; i < pointerNumber; i++) { - ids[i] = event.getPointerId(i); - xs[i] = event.getX(i); - ys[i] = event.getY(i); - } - - switch (event.getAction() & MotionEvent.ACTION_MASK) { - case MotionEvent.ACTION_POINTER_DOWN: - final int indexPointerDown = event.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT; - final int idPointerDown = event.getPointerId(indexPointerDown); - final float xPointerDown = event.getX(indexPointerDown); - final float yPointerDown = event.getY(indexPointerDown); - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionDown(idPointerDown, xPointerDown, yPointerDown); - } - }); - break; - - case MotionEvent.ACTION_DOWN: - // there are only one finger on the screen - final int idDown = event.getPointerId(0); - final float xDown = xs[0]; - final float yDown = ys[0]; - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionDown(idDown, xDown, yDown); - } - }); - break; - - case MotionEvent.ACTION_MOVE: - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionMove(ids, xs, ys); - } - }); - break; - - case MotionEvent.ACTION_POINTER_UP: - final int indexPointUp = event.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT; - final int idPointerUp = event.getPointerId(indexPointUp); - final float xPointerUp = event.getX(indexPointUp); - final float yPointerUp = event.getY(indexPointUp); - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionUp(idPointerUp, xPointerUp, yPointerUp); - } - }); - break; - - case MotionEvent.ACTION_UP: - // there are only one finger on the screen - final int idUp = event.getPointerId(0); - final float xUp = xs[0]; - final float yUp = ys[0]; - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionUp(idUp, xUp, yUp); - } - }); - break; - - case MotionEvent.ACTION_CANCEL: - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionCancel(ids, xs, ys); - } - }); - break; - } - - if (debug){ - dumpEvent(event); - } - return true; - } - - /* - * This function is called before Cocos2dxRenderer.nativeInit(), so the width and height is correct. - */ - protected void onSizeChanged(int w, int h, int oldw, int oldh){ - this.mRenderer.setScreenWidthAndHeight(w, h); - } - - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) { - final int kc = keyCode; - if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) { - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleKeyDown(kc); - } - }); - return true; - } - return super.onKeyDown(keyCode, event); - } - - // Show an event in the LogCat view, for debugging - private void dumpEvent(MotionEvent event) { - String names[] = { "DOWN" , "UP" , "MOVE" , "CANCEL" , "OUTSIDE" , - "POINTER_DOWN" , "POINTER_UP" , "7?" , "8?" , "9?" }; - StringBuilder sb = new StringBuilder(); - int action = event.getAction(); - int actionCode = action & MotionEvent.ACTION_MASK; - sb.append("event ACTION_" ).append(names[actionCode]); - if (actionCode == MotionEvent.ACTION_POINTER_DOWN - || actionCode == MotionEvent.ACTION_POINTER_UP) { - sb.append("(pid " ).append( - action >> MotionEvent.ACTION_POINTER_ID_SHIFT); - sb.append(")" ); - } - sb.append("[" ); - for (int i = 0; i < event.getPointerCount(); i++) { - sb.append("#" ).append(i); - sb.append("(pid " ).append(event.getPointerId(i)); - sb.append(")=" ).append((int) event.getX(i)); - sb.append("," ).append((int) event.getY(i)); - if (i + 1 < event.getPointerCount()) - sb.append(";" ); - } - sb.append("]" ); - Log.d(TAG, sb.toString()); - } -} diff --git a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxMusic.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxMusic.java deleted file mode 100644 index 10e3e5f3c6..0000000000 --- a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxMusic.java +++ /dev/null @@ -1,228 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import android.content.Context; -import android.content.res.AssetFileDescriptor; -import android.media.MediaPlayer; -import android.util.Log; - -/** - * - * This class is used for controlling background music - * - */ -public class Cocos2dxMusic { - - private static final String TAG = "Cocos2dxMusic"; - private float mLeftVolume; - private float mRightVolume; - private Context mContext; - private MediaPlayer mBackgroundMediaPlayer; - private boolean mIsPaused; - private String mCurrentPath; - - public Cocos2dxMusic(Context context){ - this.mContext = context; - initData(); - } - - public void preloadBackgroundMusic(String path){ - if ((mCurrentPath == null) || (! mCurrentPath.equals(path))){ - // preload new background music - - // release old resource and create a new one - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.release(); - } - - mBackgroundMediaPlayer = createMediaplayerFromAssets(path); - - // record the path - mCurrentPath = path; - } - } - - public void playBackgroundMusic(String path, boolean isLoop){ - if (mCurrentPath == null){ - // it is the first time to play background music - // or end() was called - mBackgroundMediaPlayer = createMediaplayerFromAssets(path); - mCurrentPath = path; - } - else { - if (! mCurrentPath.equals(path)){ - // play new background music - - // release old resource and create a new one - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.release(); - } - mBackgroundMediaPlayer = createMediaplayerFromAssets(path); - - // record the path - mCurrentPath = path; - } - } - - if (mBackgroundMediaPlayer == null){ - Log.e(TAG, "playBackgroundMusic: background media player is null"); - } else { - // if the music is playing or paused, stop it - mBackgroundMediaPlayer.stop(); - - mBackgroundMediaPlayer.setLooping(isLoop); - - try { - mBackgroundMediaPlayer.prepare(); - mBackgroundMediaPlayer.seekTo(0); - mBackgroundMediaPlayer.start(); - - this.mIsPaused = false; - } catch (Exception e){ - Log.e(TAG, "playBackgroundMusic: error state"); - } - } - } - - public void stopBackgroundMusic(){ - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.stop(); - - // should set the state, if not , the following sequence will be error - // play -> pause -> stop -> resume - this.mIsPaused = false; - } - } - - public void pauseBackgroundMusic(){ - if (mBackgroundMediaPlayer != null && mBackgroundMediaPlayer.isPlaying()){ - mBackgroundMediaPlayer.pause(); - this.mIsPaused = true; - } - } - - public void resumeBackgroundMusic(){ - if (mBackgroundMediaPlayer != null && this.mIsPaused){ - mBackgroundMediaPlayer.start(); - this.mIsPaused = false; - } - } - - public void rewindBackgroundMusic(){ - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.stop(); - - try { - mBackgroundMediaPlayer.prepare(); - mBackgroundMediaPlayer.seekTo(0); - mBackgroundMediaPlayer.start(); - - this.mIsPaused = false; - } catch (Exception e){ - Log.e(TAG, "rewindBackgroundMusic: error state"); - } - } - } - - public boolean isBackgroundMusicPlaying(){ - boolean ret = false; - - if (mBackgroundMediaPlayer == null){ - ret = false; - } else { - ret = mBackgroundMediaPlayer.isPlaying(); - } - - return ret; - } - - public void end(){ - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.release(); - } - - initData(); - } - - public float getBackgroundVolume(){ - if (this.mBackgroundMediaPlayer != null){ - return (this.mLeftVolume + this.mRightVolume) / 2; - } else { - return 0.0f; - } - } - - public void setBackgroundVolume(float volume){ - if (volume < 0.0f){ - volume = 0.0f; - } - - if (volume > 1.0f){ - volume = 1.0f; - } - - this.mLeftVolume = this.mRightVolume = volume; - if (this.mBackgroundMediaPlayer != null){ - this.mBackgroundMediaPlayer.setVolume(this.mLeftVolume, this.mRightVolume); - } - } - - private void initData(){ - mLeftVolume =0.5f; - mRightVolume = 0.5f; - mBackgroundMediaPlayer = null; - mIsPaused = false; - mCurrentPath = null; - } - - /** - * create mediaplayer for music - * @param path the path relative to assets - * @return - */ - private MediaPlayer createMediaplayerFromAssets(String path){ - MediaPlayer mediaPlayer = new MediaPlayer(); - - try{ - if (path.startsWith("/")) { - mediaPlayer.setDataSource(path); - } - else { - AssetFileDescriptor assetFileDescritor = mContext.getAssets().openFd(path); - mediaPlayer.setDataSource(assetFileDescritor.getFileDescriptor(), - assetFileDescritor.getStartOffset(), assetFileDescritor.getLength()); - } - - mediaPlayer.prepare(); - - mediaPlayer.setVolume(mLeftVolume, mRightVolume); - }catch (Exception e) { - mediaPlayer = null; - Log.e(TAG, "error: " + e.getMessage(), e); - } - - return mediaPlayer; - } -} diff --git a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxRenderer.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxRenderer.java deleted file mode 100644 index fad0974f42..0000000000 --- a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxRenderer.java +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; - -import android.opengl.GLSurfaceView; - -public class Cocos2dxRenderer implements GLSurfaceView.Renderer { - private final static long NANOSECONDSPERSECOND = 1000000000L; - private final static long NANOSECONDSPERMINISECOND = 1000000; - private static long animationInterval = (long)(1.0 / 60 * NANOSECONDSPERSECOND); - private long last; - private int screenWidth; - private int screenHeight; - - public void onSurfaceCreated(GL10 gl, EGLConfig config) { - nativeInit(screenWidth, screenHeight); - last = System.nanoTime(); - } - - public void setScreenWidthAndHeight(int w, int h){ - this.screenWidth = w; - this.screenHeight = h; - } - - public void onSurfaceChanged(GL10 gl, int w, int h) { - } - - public void onDrawFrame(GL10 gl) { - - long now = System.nanoTime(); - long interval = now - last; - - // should render a frame when onDrawFrame() is called - // or there is a "ghost" - nativeRender(); - - // fps controlling - if (interval < animationInterval){ - try { - // because we render it before, so we should sleep twice time interval - Thread.sleep((animationInterval - interval) * 2 / NANOSECONDSPERMINISECOND); - } catch (Exception e){} - } - - last = now; - } - - public void handleActionDown(int id, float x, float y) - { - nativeTouchesBegin(id, x, y); - } - - public void handleActionUp(int id, float x, float y) - { - nativeTouchesEnd(id, x, y); - } - - public void handleActionCancel(int[] id, float[] x, float[] y) - { - nativeTouchesCancel(id, x, y); - } - - public void handleActionMove(int[] id, float[] x, float[] y) - { - nativeTouchesMove(id, x, y); - } - - public void handleKeyDown(int keyCode) - { - nativeKeyDown(keyCode); - } - - public void handleOnPause(){ - nativeOnPause(); - } - - public void handleOnResume(){ - nativeOnResume(); - } - - public static void setAnimationInterval(double interval){ - animationInterval = (long)(interval * NANOSECONDSPERSECOND); - } - private static native void nativeTouchesBegin(int id, float x, float y); - private static native void nativeTouchesEnd(int id, float x, float y); - private static native void nativeTouchesMove(int[] id, float[] x, float[] y); - private static native void nativeTouchesCancel(int[] id, float[] x, float[] y); - private static native boolean nativeKeyDown(int keyCode); - private static native void nativeRender(); - private static native void nativeInit(int w, int h); - private static native void nativeOnPause(); - private static native void nativeOnResume(); - - ///////////////////////////////////////////////////////////////////////////////// - // handle input method edit message - ///////////////////////////////////////////////////////////////////////////////// - - public void handleInsertText(final String text) { - nativeInsertText(text); - } - - public void handleDeleteBackward() { - nativeDeleteBackward(); - } - - public String getContentText() { - return nativeGetContentText(); - } - - private static native void nativeInsertText(String text); - private static native void nativeDeleteBackward(); - private static native String nativeGetContentText(); -} diff --git a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxSound.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxSound.java deleted file mode 100644 index e7061f74de..0000000000 --- a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxSound.java +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import android.content.Context; -import android.media.AudioManager; -import android.media.SoundPool; -import android.util.Log; - -/** - * - * This class is used for controlling effect - * - */ - -public class Cocos2dxSound { - private Context mContext; - private SoundPool mSoundPool; - private float mLeftVolume; - private float mRightVolume; - - // sound path and stream ids map - // a file may be played many times at the same time - // so there is an array map to a file path - private HashMap> mPathStreamIDsMap; - - private HashMap mPathSoundIdMap; - - private static final String TAG = "Cocos2dxSound"; - private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5; - private static final float SOUND_RATE = 1.0f; - private static final int SOUND_PRIORITY = 1; - private static final int SOUND_QUALITY = 5; - - private final static int INVALID_SOUND_ID = -1; - private final static int INVALID_STREAM_ID = -1; - - public Cocos2dxSound(Context context){ - this.mContext = context; - initData(); - } - - public int preloadEffect(String path){ - Integer soundID = this.mPathSoundIdMap.get(path); - - if (soundID == null) { - soundID = createSoundIdFromAsset(path); - this.mPathSoundIdMap.put(path, soundID); - } - - return soundID; - } - - public void unloadEffect(String path){ - // stop effects - ArrayList streamIDs = this.mPathStreamIDsMap.get(path); - if (streamIDs != null) { - for (Integer streamID : streamIDs) { - this.mSoundPool.stop(streamID); - } - } - this.mPathStreamIDsMap.remove(path); - - // unload effect - Integer soundID = this.mPathSoundIdMap.get(path); - this.mSoundPool.unload(soundID); - this.mPathSoundIdMap.remove(path); - } - - public int playEffect(String path, boolean isLoop){ - Integer soundId = this.mPathSoundIdMap.get(path); - int streamId = INVALID_STREAM_ID; - - if (soundId != null){ - // play sound - streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, - this.mRightVolume, SOUND_PRIORITY, isLoop ? -1 : 0, SOUND_RATE); - - // record stream id - ArrayList streamIds = this.mPathStreamIDsMap.get(path); - if (streamIds == null) { - streamIds = new ArrayList(); - this.mPathStreamIDsMap.put(path, streamIds); - } - streamIds.add(streamId); - } else { - // the effect is not prepared - soundId = preloadEffect(path); - if (soundId == INVALID_SOUND_ID){ - // can not preload effect - return INVALID_SOUND_ID; - } - - /* - * Someone reports that, it can not play effect for the - * first time. If you are lucky to meet it. There are two - * ways to resolve it. - * 1. Add some delay here. I don't know how long it is, so - * I don't add it here. - * 2. If you use 2.2(API level 8), you can call - * SoundPool.setOnLoadCompleteListener() to play the effect. - * Because the method is supported from 2.2, so I can't use - * it here. - */ - playEffect(path, isLoop); - } - - return streamId; - } - - public void stopEffect(int streamID){ - this.mSoundPool.stop(streamID); - - // remove record - for (String path : this.mPathStreamIDsMap.keySet()) { - if (this.mPathStreamIDsMap.get(path).contains(streamID)) { - this.mPathStreamIDsMap.get(path).remove(this.mPathStreamIDsMap.get(path).indexOf(streamID)); - break; - } - } - } - - public void pauseEffect(int streamID){ - this.mSoundPool.pause(streamID); - } - - public void resumeEffect(int streamID){ - this.mSoundPool.resume(streamID); - } - - public void pauseAllEffects(){ - this.mSoundPool.autoPause(); - } - - public void resumeAllEffects(){ - // autoPause() is available since level 8 - this.mSoundPool.autoResume(); - } - - @SuppressWarnings("unchecked") - public void stopAllEffects(){ - // stop effects - if (! this.mPathStreamIDsMap.isEmpty()) { - Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry> entry = (Map.Entry>)iter.next(); - for (int streamID : entry.getValue()) { - this.mSoundPool.stop(streamID); - } - } - } - - // remove records - this.mPathStreamIDsMap.clear(); - } - - public float getEffectsVolume(){ - return (this.mLeftVolume + this.mRightVolume) / 2; - } - - @SuppressWarnings("unchecked") - public void setEffectsVolume(float volume){ - // volume should be in [0, 1.0] - if (volume < 0){ - volume = 0; - } - if (volume > 1){ - volume = 1; - } - - this.mLeftVolume = this.mRightVolume = volume; - - // change the volume of playing sounds - if (! this.mPathStreamIDsMap.isEmpty()) { - Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry> entry = (Map.Entry>)iter.next(); - for (int streamID : entry.getValue()) { - this.mSoundPool.setVolume(streamID, mLeftVolume, mRightVolume); - } - } - } - } - - public void end(){ - this.mSoundPool.release(); - this.mPathStreamIDsMap.clear(); - this.mPathSoundIdMap.clear(); - - initData(); - } - - public int createSoundIdFromAsset(String path){ - int soundId = INVALID_SOUND_ID; - - try { - if (path.startsWith("/")){ - soundId = mSoundPool.load(path, 0); - } - else { - soundId = mSoundPool.load(mContext.getAssets().openFd(path), 0); - } - } catch(Exception e){ - soundId = INVALID_SOUND_ID; - Log.e(TAG, "error: " + e.getMessage(), e); - } - - return soundId; - } - - private void initData(){ - this.mPathStreamIDsMap = new HashMap>(); - this.mPathSoundIdMap = new HashMap(); - mSoundPool = new SoundPool(MAX_SIMULTANEOUS_STREAMS_DEFAULT, AudioManager.STREAM_MUSIC, SOUND_QUALITY); - - this.mLeftVolume = 0.5f; - this.mRightVolume = 0.5f; - } -} diff --git a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxTypefaces.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxTypefaces.java deleted file mode 100644 index 79af1ed3af..0000000000 --- a/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxTypefaces.java +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import java.util.Hashtable; - -import android.content.Context; -import android.graphics.Typeface; - -public class Cocos2dxTypefaces { - private static final Hashtable cache = new Hashtable(); - - public static Typeface get(Context context, String name){ - synchronized(cache){ - if (! cache.containsKey(name)){ - Typeface t = Typeface.createFromAsset(context.getAssets(), name); - cache.put(name, t); - } - - return cache.get(name); - } - } -} diff --git a/cocos2dx/platform/android/jni/EditBoxJni.cpp b/cocos2dx/platform/android/jni/EditBoxJni.cpp deleted file mode 100644 index 6e34af184d..0000000000 --- a/cocos2dx/platform/android/jni/EditBoxJni.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -#include "EditBoxJni.h" -#include "text_input_node/CCIMEDispatcher.h" -#include "JniHelper.h" - -#include -#include -#include - -#if 0 -#define LOG_TAG "EditBoxJni" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) -#else -#define LOGD(...) -#endif - -using namespace cocos2d; - -static EditBoxCallback s_pfEditBoxCB = NULL; -static void* s_ctx = NULL; - -extern "C" -{ -////////////////////////////////////////////////////////////////////////// -// handle EditBox message -////////////////////////////////////////////////////////////////////////// - - - -void showEditBoxDialogJni(const char* pszTitle, - const char* pszContent, - int nInputMode, - int nInputFlag, - int nReturnType, - int nMaxLength, - EditBoxCallback pfEditBoxCB, - void* ctx) -{ - LOGD("showEditBoxDialogJni..."); - - if (pszContent == NULL) { - return; - } - - s_pfEditBoxCB = pfEditBoxCB; - s_ctx = ctx; - - JniMethodInfo t; - if (JniHelper::getStaticMethodInfo(t - , "org/cocos2dx/lib/Cocos2dxActivity" - , "showEditBoxDialog" - , "(Ljava/lang/String;Ljava/lang/String;IIII)V")) - { - jstring stringArg1; - - if (!pszTitle) - { - stringArg1 = t.env->NewStringUTF(""); - } - else - { - stringArg1 = t.env->NewStringUTF(pszTitle); - } - - jstring stringArg2 = t.env->NewStringUTF(pszContent); - - t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1, stringArg2, nInputMode, nInputFlag, nReturnType, nMaxLength); - - t.env->DeleteLocalRef(stringArg1); - t.env->DeleteLocalRef(stringArg2); - t.env->DeleteLocalRef(t.classID); - } -} - -void JNICALL Java_org_cocos2dx_lib_Cocos2dxActivity_nativeSetEditboxText(JNIEnv * env, jobject obj, jbyteArray text) -{ - jsize size = env->GetArrayLength(text); - - if (size > 0) - { - jbyte * data = (jbyte*)env->GetByteArrayElements(text, 0); - char* pBuf = (char*)malloc(size+1); - if (pBuf != NULL) - { - memcpy(pBuf, data, size); - pBuf[size] = '\0'; - // pass data to editbox's delegate - if (s_pfEditBoxCB) s_pfEditBoxCB(pBuf, s_ctx); - free(pBuf); - } - env->ReleaseByteArrayElements(text, data, 0); - } - else - { - if (s_pfEditBoxCB) s_pfEditBoxCB("", s_ctx); - } -} - -int getFontSizeAccordingHeightJni(int height) -{ - int ret = 0; - JniMethodInfo t; - if (JniHelper::getStaticMethodInfo(t - , "org/cocos2dx/lib/Cocos2dxBitmap" - , "getFontSizeAccordingHeight" - , "(I)I")) - { - ret = t.env->CallStaticIntMethod(t.classID, t.methodID, height); - t.env->DeleteLocalRef(t.classID); - } - - return ret; -} - -std::string getStringWithEllipsisJni(const char* pszText, float width, float fontSize) -{ - std::string ret; - JniMethodInfo t; - - if (JniHelper::getStaticMethodInfo(t - , "org/cocos2dx/lib/Cocos2dxBitmap" - , "getStringWithEllipsis" - , "(Ljava/lang/String;FF)Ljava/lang/String;")) - { - jstring stringArg1; - - if (!pszText) - { - stringArg1 = t.env->NewStringUTF(""); - } - else - { - stringArg1 = t.env->NewStringUTF(pszText); - } - - jstring retFromJava = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID, stringArg1, width, fontSize); - const char* str = t.env->GetStringUTFChars(retFromJava, 0); - ret = str; - - t.env->ReleaseStringUTFChars(retFromJava, str); - t.env->DeleteLocalRef(stringArg1); - t.env->DeleteLocalRef(t.classID); - } - LOGD("getStringWithEllipsisJni 07"); - return ret; -} - -} // end of extern "C" diff --git a/cocos2dx/platform/android/jni/EditBoxJni.h b/cocos2dx/platform/android/jni/EditBoxJni.h deleted file mode 100644 index 38b3811809..0000000000 --- a/cocos2dx/platform/android/jni/EditBoxJni.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -#ifndef __EDITBOX_JNI_H__ -#define __EDITBOX_JNI_H__ - -#include - -typedef void (*EditBoxCallback)(const char* pText, void* ctx); - -extern "C" -{ -void showEditBoxDialogJni(const char* pszTitle, - const char* pszContent, - int nInputMode, - int nInputFlag, - int nReturnType, - int nMaxLength, - EditBoxCallback pfEditBoxCB, - void* ctx); - -int getFontSizeAccordingHeightJni(int height); -std::string getStringWithEllipsisJni(const char* pszText, float width, float fontSize); - -} // end of extern "C" - -#endif // __EDITBOX_JNI_H__ diff --git a/cocos2dx/platform/android/jni/IMEJni.cpp b/cocos2dx/platform/android/jni/IMEJni.cpp index 9a6b548aea..e9b0f0321c 100644 --- a/cocos2dx/platform/android/jni/IMEJni.cpp +++ b/cocos2dx/platform/android/jni/IMEJni.cpp @@ -29,56 +29,32 @@ THE SOFTWARE. #include #include -#if 0 -#define LOG_TAG "IMEJni" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) -#else -#define LOGD(...) -#endif - using namespace cocos2d; -extern "C" -{ - ////////////////////////////////////////////////////////////////////////// - // handle IME message - ////////////////////////////////////////////////////////////////////////// +extern "C" { + void setKeyboardStateJNI(int bOpen) { + if (bOpen) { + openKeyboardJNI(); + } else { + closeKeyboardJNI(); + } + } - void setKeyboardStateJNI(int bOpen) - { + void openKeyboardJNI() { JniMethodInfo t; - if (JniHelper::getStaticMethodInfo(t, - "org/cocos2dx/lib/Cocos2dxGLSurfaceView", - (bOpen) ? "openIMEKeyboard" : "closeIMEKeyboard", - "()V")) - { + if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxGLSurfaceView", "openIMEKeyboard", "()V")) { t.env->CallStaticVoidMethod(t.classID, t.methodID); t.env->DeleteLocalRef(t.classID); } } - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInsertText(JNIEnv* env, jobject thiz, jstring text) - { - const char* pszText = env->GetStringUTFChars(text, NULL); - cocos2d::CCIMEDispatcher::sharedDispatcher()->dispatchInsertText(pszText, strlen(pszText)); - env->ReleaseStringUTFChars(text, pszText); - } + void closeKeyboardJNI() { + JniMethodInfo t; - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeDeleteBackward(JNIEnv* env, jobject thiz) - { - cocos2d::CCIMEDispatcher::sharedDispatcher()->dispatchDeleteBackward(); - } - - jstring Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeGetContentText() - { - JNIEnv * env = 0; - - if (JniHelper::getJavaVM()->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK || ! env) - { - return 0; + if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxGLSurfaceView", "closeIMEKeyboard", "()V")) { + t.env->CallStaticVoidMethod(t.classID, t.methodID); + t.env->DeleteLocalRef(t.classID); } - const char * pszText = cocos2d::CCIMEDispatcher::sharedDispatcher()->getContentText(); - return env->NewStringUTF(pszText); } } diff --git a/cocos2dx/platform/android/jni/IMEJni.h b/cocos2dx/platform/android/jni/IMEJni.h index 2840ad3e4e..2d3dd62d87 100644 --- a/cocos2dx/platform/android/jni/IMEJni.h +++ b/cocos2dx/platform/android/jni/IMEJni.h @@ -24,10 +24,10 @@ THE SOFTWARE. #ifndef __ANDROID_IME_JNI_H__ #define __ANDROID_IME_JNI_H__ -extern "C" - -{ +extern "C" { extern void setKeyboardStateJNI(int bOpen); + extern void openKeyboardJNI(); + extern void closeKeyboardJNI(); } #endif // __ANDROID_IME_JNI_H__ diff --git a/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp new file mode 100644 index 0000000000..be04763b95 --- /dev/null +++ b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp @@ -0,0 +1,15 @@ +#include "cocoa/CCGeometry.h" +#include "platform/android/CCAccelerometer.h" +#include "../CCEGLView.h" +#include "JniHelper.h" +#include +#include "CCDirector.h" + +using namespace cocos2d; + +extern "C" { + void Java_org_cocos2dx_lib_Cocos2dxAccelerometer_onSensorChanged(JNIEnv* env, jobject thiz, jfloat x, jfloat y, jfloat z, jlong timeStamp) { + CCDirector* pDirector = CCDirector::sharedDirector(); + pDirector->getAccelerometer()->update(x, y, z, timeStamp); + } +} diff --git a/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp new file mode 100644 index 0000000000..63e80e6dc4 --- /dev/null +++ b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp @@ -0,0 +1,48 @@ +#include "JniHelper.h" +#include +#include "CCDirector.h" +#include "../CCApplication.h" +#include "platform/CCFileUtils.h" +#include "CCEventType.h" +#include "support/CCNotificationCenter.h" +#include + +using namespace cocos2d; + +extern "C" { + int getFontSizeAccordingHeightJni(int height) { + int ret = 0; + + JniMethodInfo t; + if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxBitmap", "getFontSizeAccordingHeight", "(I)I")) { + ret = t.env->CallStaticIntMethod(t.classID, t.methodID, height); + t.env->DeleteLocalRef(t.classID); + } + + return ret; + } + + std::string getStringWithEllipsisJni(const char* pszText, float width, float fontSize) { + std::string ret; + JniMethodInfo t; + + if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxBitmap", "getStringWithEllipsis", "(Ljava/lang/String;FF)Ljava/lang/String;")) { + jstring stringArg1; + + if (!pszText) { + stringArg1 = t.env->NewStringUTF(""); + } else { + stringArg1 = t.env->NewStringUTF(pszText); + } + + jstring retFromJava = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID, stringArg1, width, fontSize); + const char* str = t.env->GetStringUTFChars(retFromJava, 0); + ret = str; + + t.env->ReleaseStringUTFChars(retFromJava, str); + t.env->DeleteLocalRef(stringArg1); + t.env->DeleteLocalRef(t.classID); + } + return ret; + } +} diff --git a/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp new file mode 100644 index 0000000000..3d3ca973dc --- /dev/null +++ b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp @@ -0,0 +1,177 @@ +#include +#include +#include +#include +#include +#include "JniHelper.h" +#include "cocoa/CCString.h" +#include "Java_org_cocos2dx_lib_Cocos2dxHelper.h" + + +#define LOG_TAG "Java_org_cocos2dx_lib_Cocos2dxHelper.cpp" +#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) + +#define CLASS_NAME "org/cocos2dx/lib/Cocos2dxHelper" + +static EditTextCallback s_pfEditTextCallback = NULL; +static void* s_ctx = NULL; + +using namespace cocos2d; + +extern "C" { + const char * g_pApkPath; + + void Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetApkPath(JNIEnv* env, jobject thiz, jstring apkPath) { + g_pApkPath = env->GetStringUTFChars(apkPath, NULL); + } + + const char * getApkPath() { + return g_pApkPath; + } + + void Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetAssetManager(JNIEnv* env, jobject thiz, jobject java_assetmanager) { + AAssetManager* assetmanager = AAssetManager_fromJava(env, java_assetmanager); + if (assetmanager == NULL) { + LOGD("ERROR: assetmanager == NULL"); + return; + } + + cocos2d::JniHelper::setAssetManager(assetmanager); + } + + void Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetExternalAssetPath(JNIEnv* env, jobject thiz, jstring externalAssetPath) { + const char* externalAssetPathChars = env->GetStringUTFChars(externalAssetPath, NULL); + cocos2d::JniHelper::setExternalAssetPath(externalAssetPathChars); + env->ReleaseStringUTFChars(externalAssetPath, externalAssetPathChars); + } + + void showDialogJNI(const char * pszMsg, const char * pszTitle) { + if (!pszMsg) { + return; + } + + JniMethodInfo t; + if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "showDialog", "(Ljava/lang/String;Ljava/lang/String;)V")) { + jstring stringArg1; + + if (!pszTitle) { + stringArg1 = t.env->NewStringUTF(""); + } else { + stringArg1 = t.env->NewStringUTF(pszTitle); + } + + jstring stringArg2 = t.env->NewStringUTF(pszMsg); + t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1, stringArg2); + + t.env->DeleteLocalRef(stringArg1); + t.env->DeleteLocalRef(stringArg2); + t.env->DeleteLocalRef(t.classID); + } + } + + void showEditTextDialogJNI(const char* pszTitle, const char* pszMessage, int nInputMode, int nInputFlag, int nReturnType, int nMaxLength, EditTextCallback pfEditTextCallback, void* ctx) { + if (pszMessage == NULL) { + return; + } + + s_pfEditTextCallback = pfEditTextCallback; + s_ctx = ctx; + + JniMethodInfo t; + if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "showEditTextDialog", "(Ljava/lang/String;Ljava/lang/String;IIII)V")) { + jstring stringArg1; + + if (!pszTitle) { + stringArg1 = t.env->NewStringUTF(""); + } else { + stringArg1 = t.env->NewStringUTF(pszTitle); + } + + jstring stringArg2 = t.env->NewStringUTF(pszMessage); + + t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1, stringArg2, nInputMode, nInputFlag, nReturnType, nMaxLength); + + t.env->DeleteLocalRef(stringArg1); + t.env->DeleteLocalRef(stringArg2); + t.env->DeleteLocalRef(t.classID); + } + } + + void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetEditTextDialogResult(JNIEnv * env, jobject obj, jbyteArray text) { + jsize size = env->GetArrayLength(text); + + if (size > 0) { + jbyte * data = (jbyte*)env->GetByteArrayElements(text, 0); + char* pBuf = (char*)malloc(size+1); + if (pBuf != NULL) { + memcpy(pBuf, data, size); + pBuf[size] = '\0'; + // pass data to edittext's delegate + if (s_pfEditTextCallback) s_pfEditTextCallback(pBuf, s_ctx); + free(pBuf); + } + env->ReleaseByteArrayElements(text, data, 0); + } else { + if (s_pfEditTextCallback) s_pfEditTextCallback("", s_ctx); + } + } + + void terminateProcessJNI() { + JniMethodInfo t; + + if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "terminateProcess", "()V")) { + t.env->CallStaticVoidMethod(t.classID, t.methodID); + t.env->DeleteLocalRef(t.classID); + } + } + + const char* getPackageNameJNI() { + JniMethodInfo t; + + if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getCocos2dxPackageName", "()Ljava/lang/String;")) { + jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID); + t.env->DeleteLocalRef(t.classID); + CCString *ret = new CCString(JniHelper::jstring2string(str).c_str()); + ret->autorelease(); + t.env->DeleteLocalRef(str); + + return ret->m_sString.c_str(); + } + + return 0; + } + + const char* getCurrentLanguageJNI() { + JniMethodInfo t; + + if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getCurrentLanguage", "()Ljava/lang/String;")) { + jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID); + t.env->DeleteLocalRef(t.classID); + CCString *ret = new CCString(JniHelper::jstring2string(str).c_str()); + ret->autorelease(); + t.env->DeleteLocalRef(str); + + return ret->m_sString.c_str(); + } + + return 0; + } + + void enableAccelerometerJNI() { + JniMethodInfo t; + + if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "enableAccelerometer", "()V")) { + t.env->CallStaticVoidMethod(t.classID, t.methodID); + t.env->DeleteLocalRef(t.classID); + } + } + + void disableAccelerometerJNI() { + JniMethodInfo t; + + if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "disableAccelerometer", "()V")) { + t.env->CallStaticVoidMethod(t.classID, t.methodID); + t.env->DeleteLocalRef(t.classID); + } + } +} diff --git a/cocos2dx/platform/android/jni/SensorJni.h b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h similarity index 67% rename from cocos2dx/platform/android/jni/SensorJni.h rename to cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h index 85baf79c4c..722e8a18ef 100644 --- a/cocos2dx/platform/android/jni/SensorJni.h +++ b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h @@ -21,14 +21,22 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#ifndef __ANDROID_SENSOR_JNI_H__ -#define __ANDROID_SENSOR_JNI_H__ +#ifndef __Java_org_cocos2dx_lib_Cocos2dxHelper_H__ +#define __Java_org_cocos2dx_lib_Cocos2dxHelper_H__ -extern "C" +#include -{ +typedef void (*EditTextCallback)(const char* pText, void* ctx); + +extern "C" { + extern const char * getApkPath(); + extern void showDialogJNI(const char * pszMsg, const char * pszTitle); + extern void showEditTextDialogJNI(const char* pszTitle, const char* pszContent, int nInputMode, int nInputFlag, int nReturnType, int nMaxLength, EditTextCallback pfEditTextCallback, void* ctx); + extern void terminateProcessJNI(); + extern const char * getCurrentLanguageJNI(); + extern const char * getPackageNameJNI(); extern void enableAccelerometerJNI(); extern void disableAccelerometerJNI(); } -#endif // __ANDROID_SENSOR_JNI_H__ +#endif diff --git a/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp new file mode 100644 index 0000000000..4f08e0f09b --- /dev/null +++ b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp @@ -0,0 +1,48 @@ +#include "text_input_node/CCIMEDispatcher.h" +#include "CCDirector.h" +#include "../CCApplication.h" +#include "platform/CCFileUtils.h" +#include "CCEventType.h" +#include "support/CCNotificationCenter.h" +#include "JniHelper.h" +#include + +using namespace cocos2d; + +extern "C" { + void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeRender(JNIEnv* env) { + cocos2d::CCDirector::sharedDirector()->mainLoop(); + } + + void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause() { + CCApplication::sharedApplication()->applicationDidEnterBackground(); + + CCNotificationCenter::sharedNotificationCenter()->postNotification(EVENT_COME_TO_BACKGROUND, NULL); + } + + void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume() { + if (CCDirector::sharedDirector()->getOpenGLView()) { + CCApplication::sharedApplication()->applicationWillEnterForeground(); + } + } + + void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInsertText(JNIEnv* env, jobject thiz, jstring text) { + const char* pszText = env->GetStringUTFChars(text, NULL); + cocos2d::CCIMEDispatcher::sharedDispatcher()->dispatchInsertText(pszText, strlen(pszText)); + env->ReleaseStringUTFChars(text, pszText); + } + + void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeDeleteBackward(JNIEnv* env, jobject thiz) { + cocos2d::CCIMEDispatcher::sharedDispatcher()->dispatchDeleteBackward(); + } + + jstring Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeGetContentText() { + JNIEnv * env = 0; + + if (JniHelper::getJavaVM()->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK || ! env) { + return 0; + } + const char * pszText = cocos2d::CCIMEDispatcher::sharedDispatcher()->getContentText(); + return env->NewStringUTF(pszText); + } +} diff --git a/cocos2dx/platform/android/jni/JniHelper.cpp b/cocos2dx/platform/android/jni/JniHelper.cpp index a4e6db6e4d..a2ed3c7f99 100644 --- a/cocos2dx/platform/android/jni/JniHelper.cpp +++ b/cocos2dx/platform/android/jni/JniHelper.cpp @@ -23,6 +23,8 @@ THE SOFTWARE. ****************************************************************************/ #include "JniHelper.h" #include +#include +#include #include #if 1 @@ -193,6 +195,26 @@ void JniHelper::setJavaVM(JavaVM *javaVM) m_psJavaVM = javaVM; } +AAssetManager* JniHelper::m_assetmanager = NULL; + +AAssetManager* JniHelper::getAssetManager() { + return m_assetmanager; +} + +void JniHelper::setAssetManager(AAssetManager* am) { + m_assetmanager = am; +} + +string JniHelper::m_externalAssetPath; + +const char* JniHelper::getExternalAssetPath() { + return m_externalAssetPath.c_str(); +} + +void JniHelper::setExternalAssetPath(const char * externalAssetPath) { + m_externalAssetPath = externalAssetPath; +} + jclass JniHelper::getClassID(const char *className, JNIEnv *env) { return getClassID_(className, env); diff --git a/cocos2dx/platform/android/jni/JniHelper.h b/cocos2dx/platform/android/jni/JniHelper.h index 7d716b2da0..f5c7e63020 100644 --- a/cocos2dx/platform/android/jni/JniHelper.h +++ b/cocos2dx/platform/android/jni/JniHelper.h @@ -27,6 +27,7 @@ THE SOFTWARE. #include #include #include "platform/CCPlatformMacros.h" +#include NS_CC_BEGIN @@ -42,6 +43,10 @@ class CC_DLL JniHelper public: static JavaVM* getJavaVM(); static void setJavaVM(JavaVM *javaVM); + static AAssetManager* getAssetManager(); + static void setAssetManager(AAssetManager* am); + static const char* getExternalAssetPath(); + static void setExternalAssetPath(const char* externalAssetPath); static jclass getClassID(const char *className, JNIEnv *env=0); static bool getStaticMethodInfo(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode); static bool getMethodInfo(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode); @@ -49,6 +54,8 @@ public: private: static JavaVM *m_psJavaVM; + static AAssetManager *m_assetmanager; + static std::string m_externalAssetPath; }; NS_CC_END diff --git a/cocos2dx/platform/android/jni/MessageJni.cpp b/cocos2dx/platform/android/jni/MessageJni.cpp deleted file mode 100644 index 36ef53fafb..0000000000 --- a/cocos2dx/platform/android/jni/MessageJni.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -#include "MessageJni.h" -#include "CCDirector.h" -#include "JniHelper.h" -#include "../CCApplication.h" -#include "platform/CCFileUtils.h" -#include "CCEventType.h" -#include "support/CCNotificationCenter.h" - -#include -#include - - -#if 0 -#define LOG_TAG "MessageJni" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) -#else -#define LOGD(...) -#endif - -using namespace cocos2d; - -extern "C" -{ - char *g_pApkPath; - - ////////////////////////////////////////////////////////////////////////// - // native renderer - ////////////////////////////////////////////////////////////////////////// - - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeRender(JNIEnv* env) - { - cocos2d::CCDirector::sharedDirector()->mainLoop(); - } - - // handle onPause and onResume - - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause() - { - CCApplication::sharedApplication()->applicationDidEnterBackground(); - - CCNotificationCenter::sharedNotificationCenter()->postNotification(EVENT_COME_TO_BACKGROUND, NULL); - } - - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume() - { - // Shared OpenGL View instance doesn't exist yet when Activity.onResume is first called - if (CCDirector::sharedDirector()->getOpenGLView()) - { - CCApplication::sharedApplication()->applicationWillEnterForeground(); - } - } - - void showMessageBoxJNI(const char * pszMsg, const char * pszTitle) - { - if (! pszMsg) - { - return; - } - - JniMethodInfo t; - if (JniHelper::getStaticMethodInfo(t - , "org/cocos2dx/lib/Cocos2dxActivity" - , "showMessageBox" - , "(Ljava/lang/String;Ljava/lang/String;)V")) - { - jstring stringArg1; - - if (! pszTitle) - { - stringArg1 = t.env->NewStringUTF(""); - } - else - { - stringArg1 = t.env->NewStringUTF(pszTitle); - } - - jstring stringArg2 = t.env->NewStringUTF(pszMsg); - t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1, stringArg2); - - t.env->DeleteLocalRef(stringArg1); - t.env->DeleteLocalRef(stringArg2); - t.env->DeleteLocalRef(t.classID); - } - } - - - ////////////////////////////////////////////////////////////////////////// - // terminate the process - ////////////////////////////////////////////////////////////////////////// - void terminateProcessJNI() - { - JniMethodInfo t; - - if (JniHelper::getStaticMethodInfo(t - , "org/cocos2dx/lib/Cocos2dxActivity" - , "terminateProcess" - , "()V")) - { - t.env->CallStaticVoidMethod(t.classID, t.methodID); - t.env->DeleteLocalRef(t.classID); - } - } - - ////////////////////////////////////////////////////////////////////////// - // set apk path - ////////////////////////////////////////////////////////////////////////// - void Java_org_cocos2dx_lib_Cocos2dxActivity_nativeSetPaths(JNIEnv* env, jobject thiz, jstring apkPath) - { - g_pApkPath = (char*)env->GetStringUTFChars(apkPath, NULL); - // don't release it, we will use it later - //env->ReleaseStringUTFChars(apkPath, str); - } - - char* getApkPath() - { - return g_pApkPath; - } -} diff --git a/cocos2dx/platform/android/jni/MessageJni.h b/cocos2dx/platform/android/jni/MessageJni.h deleted file mode 100644 index 0ecf5b48cd..0000000000 --- a/cocos2dx/platform/android/jni/MessageJni.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -#ifndef __ANDROID_MESSAGE_JNI_H__ -#define __ANDROID_MESSAGE_JNI_H__ - -extern "C" - -{ - extern void showMessageBoxJNI(const char * pszMsg, const char * pszTitle); - extern void terminateProcessJNI(); - extern char* getApkPath(); -} - -#endif // __ANDROID_MESSAGE_JNI_H__ diff --git a/cocos2dx/platform/android/jni/SensorJni.cpp b/cocos2dx/platform/android/jni/SensorJni.cpp deleted file mode 100644 index 3ffeaa17a4..0000000000 --- a/cocos2dx/platform/android/jni/SensorJni.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -#include "SensorJni.h" -#include "cocoa/CCGeometry.h" -#include "platform/android/CCAccelerometer.h" -#include "../CCEGLView.h" -#include "JniHelper.h" -#include -#include -#include "CCDirector.h" - -#if 0 -#define LOG_TAG "SensorJni" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) -#else -#define LOGD(...) -#endif - -using namespace cocos2d; - -extern "C" -{ - - ////////////////////////////////////////////////////////////////////////// - // handle accelerometer changes - ////////////////////////////////////////////////////////////////////////// - - void Java_org_cocos2dx_lib_Cocos2dxAccelerometer_onSensorChanged(JNIEnv* env, jobject thiz, jfloat x, jfloat y, jfloat z, jlong timeStamp) - { - // We need to invert to make it compatible with iOS. - CCDirector* pDirector = CCDirector::sharedDirector(); - pDirector->getAccelerometer()->update(x, y, z, timeStamp); - } - - void enableAccelerometerJNI() - { - JniMethodInfo t; - - if (JniHelper::getStaticMethodInfo(t, - "org/cocos2dx/lib/Cocos2dxActivity", - "enableAccelerometer", - "()V")) - { - t.env->CallStaticVoidMethod(t.classID, t.methodID); - t.env->DeleteLocalRef(t.classID); - } - } - - void disableAccelerometerJNI() - { - JniMethodInfo t; - - if (JniHelper::getStaticMethodInfo(t, - "org/cocos2dx/lib/Cocos2dxActivity", - "disableAccelerometer", - "()V")) - { - t.env->CallStaticVoidMethod(t.classID, t.methodID); - t.env->DeleteLocalRef(t.classID); - } - } -} diff --git a/cocos2dx/platform/android/jni/SystemInfoJni.cpp b/cocos2dx/platform/android/jni/SystemInfoJni.cpp deleted file mode 100644 index 5f5d7a921f..0000000000 --- a/cocos2dx/platform/android/jni/SystemInfoJni.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -#include "SystemInfoJni.h" -#include "JniHelper.h" -#include "cocoa/CCString.h" - -#include -#include - - -#if 0 -#define LOG_TAG "SystemInfoJni" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) -#else -#define LOGD(...) -#endif - -using namespace cocos2d; - -extern "C" -{ - const char* getPackageNameJNI() - { - JniMethodInfo t; - - if (JniHelper::getStaticMethodInfo(t, - "org/cocos2dx/lib/Cocos2dxActivity", - "getCocos2dxPackageName", - "()Ljava/lang/String;")) - { - jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID); - t.env->DeleteLocalRef(t.classID); - CCString *ret = new CCString(JniHelper::jstring2string(str).c_str()); - ret->autorelease(); - t.env->DeleteLocalRef(str); - - LOGD("package name %s", ret->m_sString.c_str()); - - return ret->m_sString.c_str(); - } - - return 0; - } - - ////////////////////////////////////////////////////////////////////////// - // handle get current language - ////////////////////////////////////////////////////////////////////////// - const char* getCurrentLanguageJNI() - { - JniMethodInfo t; - - if (JniHelper::getStaticMethodInfo(t - , "org/cocos2dx/lib/Cocos2dxActivity" - , "getCurrentLanguage" - , "()Ljava/lang/String;")) - { - jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID); - t.env->DeleteLocalRef(t.classID); - CCString *ret = new CCString(JniHelper::jstring2string(str).c_str()); - ret->autorelease(); - t.env->DeleteLocalRef(str); - - LOGD("language name %s", ret.c_str()); - - return ret->m_sString.c_str(); - } - - return 0; - } -} diff --git a/cocos2dx/platform/android/jni/SystemInfoJni.h b/cocos2dx/platform/android/jni/SystemInfoJni.h deleted file mode 100644 index 1d04430704..0000000000 --- a/cocos2dx/platform/android/jni/SystemInfoJni.h +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -#ifndef __ANDROID_SYSTEM_INFO_JNI_H__ -#define __ANDROID_SYSTEM_INFO_JNI_H__ - -#include - -extern "C" - -{ - extern const char* getCurrentLanguageJNI(); - extern const char* getPackageNameJNI(); -} - -#endif // __ANDROID_SYSTEM_INFO_JNI_H__ diff --git a/cocos2dx/platform/android/jni/TouchesJni.cpp b/cocos2dx/platform/android/jni/TouchesJni.cpp index 62ed575602..056d21c1b6 100644 --- a/cocos2dx/platform/android/jni/TouchesJni.cpp +++ b/cocos2dx/platform/android/jni/TouchesJni.cpp @@ -31,79 +31,60 @@ THE SOFTWARE. #include #include -#if 0 -#define LOG_TAG "NativeTouchesJni" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) -#else -#define LOGD(...) -#endif - using namespace cocos2d; -extern "C" -{ +extern "C" { + void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesBegin(JNIEnv * env, jobject thiz, jint id, jfloat x, jfloat y) { + cocos2d::CCDirector::sharedDirector()->getOpenGLView()->handleTouchesBegin(1, &id, &x, &y); + } -// handle touch event -void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesBegin(JNIEnv* env, jobject thiz, jint id, jfloat x, jfloat y) -{ - cocos2d::CCDirector::sharedDirector()->getOpenGLView()->handleTouchesBegin(1, &id, &x, &y); -} + void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesEnd(JNIEnv * env, jobject thiz, jint id, jfloat x, jfloat y) { + cocos2d::CCDirector::sharedDirector()->getOpenGLView()->handleTouchesEnd(1, &id, &x, &y); + } -void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesEnd(JNIEnv* env, jobject thiz, jint id, jfloat x, jfloat y) -{ - cocos2d::CCDirector::sharedDirector()->getOpenGLView()->handleTouchesEnd(1, &id, &x, &y); -} + void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesMove(JNIEnv * env, jobject thiz, jintArray ids, jfloatArray xs, jfloatArray ys) { + int size = env->GetArrayLength(ids); + jint id[size]; + jfloat x[size]; + jfloat y[size]; -void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesMove(JNIEnv* env, jobject thiz, jintArray ids, jfloatArray xs, jfloatArray ys) -{ - int size = env->GetArrayLength(ids); - jint id[size]; - jfloat x[size]; - jfloat y[size]; + env->GetIntArrayRegion(ids, 0, size, id); + env->GetFloatArrayRegion(xs, 0, size, x); + env->GetFloatArrayRegion(ys, 0, size, y); - env->GetIntArrayRegion(ids, 0, size, id); - env->GetFloatArrayRegion(xs, 0, size, x); - env->GetFloatArrayRegion(ys, 0, size, y); + cocos2d::CCDirector::sharedDirector()->getOpenGLView()->handleTouchesMove(size, id, x, y); + } - cocos2d::CCDirector::sharedDirector()->getOpenGLView()->handleTouchesMove(size, id, x, y); -} + void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesCancel(JNIEnv * env, jobject thiz, jintArray ids, jfloatArray xs, jfloatArray ys) { + int size = env->GetArrayLength(ids); + jint id[size]; + jfloat x[size]; + jfloat y[size]; -void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesCancel(JNIEnv* env, jobject thiz, jintArray ids, jfloatArray xs, jfloatArray ys) -{ - int size = env->GetArrayLength(ids); - jint id[size]; - jfloat x[size]; - jfloat y[size]; + env->GetIntArrayRegion(ids, 0, size, id); + env->GetFloatArrayRegion(xs, 0, size, x); + env->GetFloatArrayRegion(ys, 0, size, y); - env->GetIntArrayRegion(ids, 0, size, id); - env->GetFloatArrayRegion(xs, 0, size, x); - env->GetFloatArrayRegion(ys, 0, size, y); + cocos2d::CCDirector::sharedDirector()->getOpenGLView()->handleTouchesCancel(size, id, x, y); + } - cocos2d::CCDirector::sharedDirector()->getOpenGLView()->handleTouchesCancel(size, id, x, y); -} + #define KEYCODE_BACK 0x04 + #define KEYCODE_MENU 0x52 -#define KEYCODE_BACK 0x04 -#define KEYCODE_MENU 0x52 - -// handle keydown event - -jboolean Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeKeyDown(JNIEnv* env, jobject thiz, jint keyCode) -{ - CCDirector* pDirector = CCDirector::sharedDirector(); - switch (keyCode) - { - case KEYCODE_BACK: - if (pDirector->getKeypadDispatcher()->dispatchKeypadMSG(kTypeBackClicked)) - return JNI_TRUE; - break; - case KEYCODE_MENU: - if (pDirector->getKeypadDispatcher()->dispatchKeypadMSG(kTypeMenuClicked)) - return JNI_TRUE; - break; - default: + jboolean Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeKeyDown(JNIEnv * env, jobject thiz, jint keyCode) { + CCDirector* pDirector = CCDirector::sharedDirector(); + switch (keyCode) { + case KEYCODE_BACK: + if (pDirector->getKeypadDispatcher()->dispatchKeypadMSG(kTypeBackClicked)) + return JNI_TRUE; + break; + case KEYCODE_MENU: + if (pDirector->getKeypadDispatcher()->dispatchKeypadMSG(kTypeMenuClicked)) + return JNI_TRUE; + break; + default: + return JNI_FALSE; + } return JNI_FALSE; } - return JNI_FALSE; -} - } diff --git a/scripting/javascript/bindings/Android.mk b/scripting/javascript/bindings/Android.mk index d29233d8c3..1ecdfb1099 100644 --- a/scripting/javascript/bindings/Android.mk +++ b/scripting/javascript/bindings/Android.mk @@ -31,6 +31,6 @@ LOCAL_LDLIBS += -llog include $(BUILD_STATIC_LIBRARY) -$(call import-module,scripting/javascript/spidermonkey-android/android) +$(call import-module,scripting/javascript/spidermonkey-android) $(call import-module,cocos2dx) $(call import-module,external/chipmunk) diff --git a/scripting/javascript/spidermonkey-android/android/Android.mk b/scripting/javascript/spidermonkey-android/Android.mk similarity index 70% rename from scripting/javascript/spidermonkey-android/android/Android.mk rename to scripting/javascript/spidermonkey-android/Android.mk index 8a8844d692..fa9a8b6434 100644 --- a/scripting/javascript/spidermonkey-android/android/Android.mk +++ b/scripting/javascript/spidermonkey-android/Android.mk @@ -3,8 +3,8 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := spidermonkey_static LOCAL_MODULE_FILENAME := js_static -LOCAL_SRC_FILES := ../dist/lib/libjs_static.a -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../dist/include +LOCAL_SRC_FILES := ./lib/libjs_static.a +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_CPPFLAGS := -D__STDC_LIMIT_MACROS=1 LOCAL_EXPORT_CPPFLAGS := -D__STDC_LIMIT_MACROS=1 include $(PREBUILT_STATIC_LIBRARY) diff --git a/scripting/javascript/spidermonkey-android/dist/include/ds/BitArray.h b/scripting/javascript/spidermonkey-android/include/ds/BitArray.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/ds/BitArray.h rename to scripting/javascript/spidermonkey-android/include/ds/BitArray.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/gc/Barrier.h b/scripting/javascript/spidermonkey-android/include/gc/Barrier.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/gc/Barrier.h rename to scripting/javascript/spidermonkey-android/include/gc/Barrier.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/gc/Root.h b/scripting/javascript/spidermonkey-android/include/gc/Root.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/gc/Root.h rename to scripting/javascript/spidermonkey-android/include/gc/Root.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/gc/Statistics.h b/scripting/javascript/spidermonkey-android/include/gc/Statistics.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/gc/Statistics.h rename to scripting/javascript/spidermonkey-android/include/gc/Statistics.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/js-config.h b/scripting/javascript/spidermonkey-android/include/js-config.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/js-config.h rename to scripting/javascript/spidermonkey-android/include/js-config.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/js.msg b/scripting/javascript/spidermonkey-android/include/js.msg similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/js.msg rename to scripting/javascript/spidermonkey-android/include/js.msg diff --git a/scripting/javascript/spidermonkey-android/dist/include/js/HashTable.h b/scripting/javascript/spidermonkey-android/include/js/HashTable.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/js/HashTable.h rename to scripting/javascript/spidermonkey-android/include/js/HashTable.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/js/LegacyIntTypes.h b/scripting/javascript/spidermonkey-android/include/js/LegacyIntTypes.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/js/LegacyIntTypes.h rename to scripting/javascript/spidermonkey-android/include/js/LegacyIntTypes.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/js/MemoryMetrics.h b/scripting/javascript/spidermonkey-android/include/js/MemoryMetrics.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/js/MemoryMetrics.h rename to scripting/javascript/spidermonkey-android/include/js/MemoryMetrics.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/js/TemplateLib.h b/scripting/javascript/spidermonkey-android/include/js/TemplateLib.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/js/TemplateLib.h rename to scripting/javascript/spidermonkey-android/include/js/TemplateLib.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/js/Utility.h b/scripting/javascript/spidermonkey-android/include/js/Utility.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/js/Utility.h rename to scripting/javascript/spidermonkey-android/include/js/Utility.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/js/Vector.h b/scripting/javascript/spidermonkey-android/include/js/Vector.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/js/Vector.h rename to scripting/javascript/spidermonkey-android/include/js/Vector.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsalloc.h b/scripting/javascript/spidermonkey-android/include/jsalloc.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsalloc.h rename to scripting/javascript/spidermonkey-android/include/jsalloc.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsapi.h.REMOVED.git-id b/scripting/javascript/spidermonkey-android/include/jsapi.h.REMOVED.git-id similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsapi.h.REMOVED.git-id rename to scripting/javascript/spidermonkey-android/include/jsapi.h.REMOVED.git-id diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsatom.h b/scripting/javascript/spidermonkey-android/include/jsatom.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsatom.h rename to scripting/javascript/spidermonkey-android/include/jsatom.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsatom.tbl b/scripting/javascript/spidermonkey-android/include/jsatom.tbl similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsatom.tbl rename to scripting/javascript/spidermonkey-android/include/jsatom.tbl diff --git a/scripting/javascript/spidermonkey-android/dist/include/jscell.h b/scripting/javascript/spidermonkey-android/include/jscell.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jscell.h rename to scripting/javascript/spidermonkey-android/include/jscell.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsclass.h b/scripting/javascript/spidermonkey-android/include/jsclass.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsclass.h rename to scripting/javascript/spidermonkey-android/include/jsclass.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsclist.h b/scripting/javascript/spidermonkey-android/include/jsclist.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsclist.h rename to scripting/javascript/spidermonkey-android/include/jsclist.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jscpucfg.h b/scripting/javascript/spidermonkey-android/include/jscpucfg.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jscpucfg.h rename to scripting/javascript/spidermonkey-android/include/jscpucfg.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsdbgapi.h b/scripting/javascript/spidermonkey-android/include/jsdbgapi.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsdbgapi.h rename to scripting/javascript/spidermonkey-android/include/jsdbgapi.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsdhash.h b/scripting/javascript/spidermonkey-android/include/jsdhash.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsdhash.h rename to scripting/javascript/spidermonkey-android/include/jsdhash.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsfriendapi.h b/scripting/javascript/spidermonkey-android/include/jsfriendapi.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsfriendapi.h rename to scripting/javascript/spidermonkey-android/include/jsfriendapi.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsgc.h b/scripting/javascript/spidermonkey-android/include/jsgc.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsgc.h rename to scripting/javascript/spidermonkey-android/include/jsgc.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jshash.h b/scripting/javascript/spidermonkey-android/include/jshash.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jshash.h rename to scripting/javascript/spidermonkey-android/include/jshash.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jslock.h b/scripting/javascript/spidermonkey-android/include/jslock.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jslock.h rename to scripting/javascript/spidermonkey-android/include/jslock.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/json.h b/scripting/javascript/spidermonkey-android/include/json.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/json.h rename to scripting/javascript/spidermonkey-android/include/json.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsperf.h b/scripting/javascript/spidermonkey-android/include/jsperf.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsperf.h rename to scripting/javascript/spidermonkey-android/include/jsperf.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsprf.h b/scripting/javascript/spidermonkey-android/include/jsprf.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsprf.h rename to scripting/javascript/spidermonkey-android/include/jsprf.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsproto.tbl b/scripting/javascript/spidermonkey-android/include/jsproto.tbl similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsproto.tbl rename to scripting/javascript/spidermonkey-android/include/jsproto.tbl diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsproxy.h b/scripting/javascript/spidermonkey-android/include/jsproxy.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsproxy.h rename to scripting/javascript/spidermonkey-android/include/jsproxy.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsprvtd.h b/scripting/javascript/spidermonkey-android/include/jsprvtd.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsprvtd.h rename to scripting/javascript/spidermonkey-android/include/jsprvtd.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jspubtd.h b/scripting/javascript/spidermonkey-android/include/jspubtd.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jspubtd.h rename to scripting/javascript/spidermonkey-android/include/jspubtd.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jstypedarray.h b/scripting/javascript/spidermonkey-android/include/jstypedarray.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jstypedarray.h rename to scripting/javascript/spidermonkey-android/include/jstypedarray.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jstypes.h b/scripting/javascript/spidermonkey-android/include/jstypes.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jstypes.h rename to scripting/javascript/spidermonkey-android/include/jstypes.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsutil.h b/scripting/javascript/spidermonkey-android/include/jsutil.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsutil.h rename to scripting/javascript/spidermonkey-android/include/jsutil.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsval.h b/scripting/javascript/spidermonkey-android/include/jsval.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsval.h rename to scripting/javascript/spidermonkey-android/include/jsval.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsversion.h b/scripting/javascript/spidermonkey-android/include/jsversion.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsversion.h rename to scripting/javascript/spidermonkey-android/include/jsversion.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jswrapper.h b/scripting/javascript/spidermonkey-android/include/jswrapper.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jswrapper.h rename to scripting/javascript/spidermonkey-android/include/jswrapper.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/jsxdrapi.h b/scripting/javascript/spidermonkey-android/include/jsxdrapi.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/jsxdrapi.h rename to scripting/javascript/spidermonkey-android/include/jsxdrapi.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/mozilla/Assertions.h b/scripting/javascript/spidermonkey-android/include/mozilla/Assertions.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/mozilla/Assertions.h rename to scripting/javascript/spidermonkey-android/include/mozilla/Assertions.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/mozilla/Attributes.h b/scripting/javascript/spidermonkey-android/include/mozilla/Attributes.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/mozilla/Attributes.h rename to scripting/javascript/spidermonkey-android/include/mozilla/Attributes.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/mozilla/BloomFilter.h b/scripting/javascript/spidermonkey-android/include/mozilla/BloomFilter.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/mozilla/BloomFilter.h rename to scripting/javascript/spidermonkey-android/include/mozilla/BloomFilter.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/mozilla/FloatingPoint.h b/scripting/javascript/spidermonkey-android/include/mozilla/FloatingPoint.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/mozilla/FloatingPoint.h rename to scripting/javascript/spidermonkey-android/include/mozilla/FloatingPoint.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/mozilla/GuardObjects.h b/scripting/javascript/spidermonkey-android/include/mozilla/GuardObjects.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/mozilla/GuardObjects.h rename to scripting/javascript/spidermonkey-android/include/mozilla/GuardObjects.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/mozilla/HashFunctions.h b/scripting/javascript/spidermonkey-android/include/mozilla/HashFunctions.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/mozilla/HashFunctions.h rename to scripting/javascript/spidermonkey-android/include/mozilla/HashFunctions.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/mozilla/Likely.h b/scripting/javascript/spidermonkey-android/include/mozilla/Likely.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/mozilla/Likely.h rename to scripting/javascript/spidermonkey-android/include/mozilla/Likely.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/mozilla/LinkedList.h b/scripting/javascript/spidermonkey-android/include/mozilla/LinkedList.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/mozilla/LinkedList.h rename to scripting/javascript/spidermonkey-android/include/mozilla/LinkedList.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/mozilla/MSStdInt.h b/scripting/javascript/spidermonkey-android/include/mozilla/MSStdInt.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/mozilla/MSStdInt.h rename to scripting/javascript/spidermonkey-android/include/mozilla/MSStdInt.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/mozilla/RangedPtr.h b/scripting/javascript/spidermonkey-android/include/mozilla/RangedPtr.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/mozilla/RangedPtr.h rename to scripting/javascript/spidermonkey-android/include/mozilla/RangedPtr.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/mozilla/RefPtr.h b/scripting/javascript/spidermonkey-android/include/mozilla/RefPtr.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/mozilla/RefPtr.h rename to scripting/javascript/spidermonkey-android/include/mozilla/RefPtr.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/mozilla/Scoped.h b/scripting/javascript/spidermonkey-android/include/mozilla/Scoped.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/mozilla/Scoped.h rename to scripting/javascript/spidermonkey-android/include/mozilla/Scoped.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/mozilla/StandardInteger.h b/scripting/javascript/spidermonkey-android/include/mozilla/StandardInteger.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/mozilla/StandardInteger.h rename to scripting/javascript/spidermonkey-android/include/mozilla/StandardInteger.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/mozilla/Types.h b/scripting/javascript/spidermonkey-android/include/mozilla/Types.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/mozilla/Types.h rename to scripting/javascript/spidermonkey-android/include/mozilla/Types.h diff --git a/scripting/javascript/spidermonkey-android/dist/include/mozilla/Util.h b/scripting/javascript/spidermonkey-android/include/mozilla/Util.h similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/include/mozilla/Util.h rename to scripting/javascript/spidermonkey-android/include/mozilla/Util.h diff --git a/scripting/javascript/spidermonkey-android/dist/lib/libjs_static.a.REMOVED.git-id b/scripting/javascript/spidermonkey-android/lib/libjs_static.a.REMOVED.git-id similarity index 100% rename from scripting/javascript/spidermonkey-android/dist/lib/libjs_static.a.REMOVED.git-id rename to scripting/javascript/spidermonkey-android/lib/libjs_static.a.REMOVED.git-id From 01103c4cb13ae6a54ce797e0035c23bf92a39f92 Mon Sep 17 00:00:00 2001 From: Ed Bartley Date: Mon, 10 Sep 2012 10:48:34 -0400 Subject: [PATCH 005/181] Remove optimization of the mac debug build --- .../proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id index c3870bbc75..9d295bd4c5 100644 --- a/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -e5c62ad91fe1348bab31e77c3c5c0fac8421bcdf \ No newline at end of file +ad4668f42c383df963deb758e3c47a7ea750ed9b \ No newline at end of file From 696cdbaa8c1c39f0442153d2465c6206026ba38d Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 12 Sep 2012 16:55:56 -0700 Subject: [PATCH 006/181] Minor build fix due to merge fail. --- scripting/javascript/bindings/Android.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/scripting/javascript/bindings/Android.mk b/scripting/javascript/bindings/Android.mk index 1ecdfb1099..4e79ea930c 100644 --- a/scripting/javascript/bindings/Android.mk +++ b/scripting/javascript/bindings/Android.mk @@ -8,7 +8,6 @@ LOCAL_MODULE_FILENAME := libscriptingcore-spidermonkey LOCAL_SRC_FILES := ScriptingCore.cpp \ cocos2d_specifics.cpp \ - cocos2dx.cpp \ CCPhysicsSprite.cpp \ js_manual_conversions.cpp \ js_bindings_chipmunk_manual.cpp \ From 9418afacf90f692ef6ff35aa6bc07bbefb354c5d Mon Sep 17 00:00:00 2001 From: dualface Date: Thu, 13 Sep 2012 10:26:30 +0800 Subject: [PATCH 007/181] delete CCDirector after call CCDirector::purgeDirector() --- cocos2dx/CCDirector.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index a8c3144428..41b6361faf 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -73,21 +73,20 @@ NS_CC_BEGIN // XXX it shoul be a Director ivar. Move it there once support for multiple directors is added // singleton stuff -static CCDisplayLinkDirector s_SharedDirector; +static CCDisplayLinkDirector *s_SharedDirector = NULL; #define kDefaultFPS 60 // 60 frames per second extern const char* cocos2dVersion(void); CCDirector* CCDirector::sharedDirector(void) { - static bool s_bFirstUseDirector = true; - if (s_bFirstUseDirector) + if (!s_SharedDirector) { - s_bFirstUseDirector = false; - s_SharedDirector.init(); + s_SharedDirector = new CCDisplayLinkDirector(); + s_SharedDirector->init(); } - return &s_SharedDirector; + return s_SharedDirector; } CCDirector::CCDirector(void) @@ -162,7 +161,7 @@ bool CCDirector::init(void) CCDirector::~CCDirector(void) { - CCLOG("cocos2d: deallocing %p", this); + CCLOG("cocos2d: deallocing CCDirector %p", this); CC_SAFE_RELEASE(m_pFPSLabel); CC_SAFE_RELEASE(m_pSPFLabel); @@ -185,6 +184,8 @@ CCDirector::~CCDirector(void) CC_SAFE_DELETE(m_pLastUpdate); // delete fps string delete []m_pszFPS; + + s_SharedDirector = NULL; } void CCDirector::setGLDefaultValues(void) @@ -593,6 +594,7 @@ void CCDirector::purgeDirector() { // cleanup scheduler getScheduler()->unscheduleAllSelectors(); + getActionManager()->removeAllActions(); // don't release the event handlers // They are needed in case the director is run again @@ -643,6 +645,9 @@ void CCDirector::purgeDirector() // OpenGL view m_pobOpenGLView->end(); m_pobOpenGLView = NULL; + + // delete CCDirector + release(); } void CCDirector::setNextScene(void) From 4aa74d8f5e2688a3e71cb58acc1a44fee85b013d Mon Sep 17 00:00:00 2001 From: dualface Date: Thu, 13 Sep 2012 10:26:47 +0800 Subject: [PATCH 008/181] [Mac] fix CCLuaLog crash --- cocos2dx/platform/mac/CCCommon.mm | 2 +- cocos2dx/platform/mac/CCDirectorCaller.mm | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cocos2dx/platform/mac/CCCommon.mm b/cocos2dx/platform/mac/CCCommon.mm index 1ab9962628..088907e03c 100755 --- a/cocos2dx/platform/mac/CCCommon.mm +++ b/cocos2dx/platform/mac/CCCommon.mm @@ -47,7 +47,7 @@ void CCLog(const char * pszFormat, ...) void CCLuaLog(const char * pszFormat) { - CCLog(pszFormat); + CCLog("%s", pszFormat); } // ios no MessageBox, use CCLog instead diff --git a/cocos2dx/platform/mac/CCDirectorCaller.mm b/cocos2dx/platform/mac/CCDirectorCaller.mm index b6586544ed..dcd6befed2 100755 --- a/cocos2dx/platform/mac/CCDirectorCaller.mm +++ b/cocos2dx/platform/mac/CCDirectorCaller.mm @@ -59,10 +59,15 @@ static id s_sharedDirectorCaller; -(void) dealloc { s_sharedDirectorCaller = nil; - NSLog(@"cocos2d: deallocing CCDirectorCaller %@", self); + CCLOG("cocos2d: deallocing CCDirectorCaller %x", (unsigned int)self); if (displayLink) { CVDisplayLinkRelease(displayLink); } + + CCLOG("--------------------------------------------------------------------------------"); + CCLOG(""); + CCLOG(""); + CCLOG(""); [super dealloc]; } From f03c0caaf996707172798270c8c05ff939278131 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Thu, 13 Sep 2012 09:34:30 -0700 Subject: [PATCH 009/181] Added proper JNIEXPORT/JNICALL markers to android platform jni bindings. --- .../Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp | 2 +- .../jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp | 8 ++++---- .../jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp index be04763b95..e34fbbfbe8 100644 --- a/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp +++ b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp @@ -8,7 +8,7 @@ using namespace cocos2d; extern "C" { - void Java_org_cocos2dx_lib_Cocos2dxAccelerometer_onSensorChanged(JNIEnv* env, jobject thiz, jfloat x, jfloat y, jfloat z, jlong timeStamp) { + JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxAccelerometer_onSensorChanged(JNIEnv* env, jobject thiz, jfloat x, jfloat y, jfloat z, jlong timeStamp) { CCDirector* pDirector = CCDirector::sharedDirector(); pDirector->getAccelerometer()->update(x, y, z, timeStamp); } diff --git a/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp index 3d3ca973dc..49cf84c6b5 100644 --- a/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp +++ b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp @@ -21,7 +21,7 @@ using namespace cocos2d; extern "C" { const char * g_pApkPath; - void Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetApkPath(JNIEnv* env, jobject thiz, jstring apkPath) { + JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetApkPath(JNIEnv* env, jobject thiz, jstring apkPath) { g_pApkPath = env->GetStringUTFChars(apkPath, NULL); } @@ -29,7 +29,7 @@ extern "C" { return g_pApkPath; } - void Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetAssetManager(JNIEnv* env, jobject thiz, jobject java_assetmanager) { + JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetAssetManager(JNIEnv* env, jobject thiz, jobject java_assetmanager) { AAssetManager* assetmanager = AAssetManager_fromJava(env, java_assetmanager); if (assetmanager == NULL) { LOGD("ERROR: assetmanager == NULL"); @@ -39,7 +39,7 @@ extern "C" { cocos2d::JniHelper::setAssetManager(assetmanager); } - void Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetExternalAssetPath(JNIEnv* env, jobject thiz, jstring externalAssetPath) { + JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetExternalAssetPath(JNIEnv* env, jobject thiz, jstring externalAssetPath) { const char* externalAssetPathChars = env->GetStringUTFChars(externalAssetPath, NULL); cocos2d::JniHelper::setExternalAssetPath(externalAssetPathChars); env->ReleaseStringUTFChars(externalAssetPath, externalAssetPathChars); @@ -97,7 +97,7 @@ extern "C" { } } - void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetEditTextDialogResult(JNIEnv * env, jobject obj, jbyteArray text) { + JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetEditTextDialogResult(JNIEnv * env, jobject obj, jbyteArray text) { jsize size = env->GetArrayLength(text); if (size > 0) { diff --git a/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp index 4f08e0f09b..93916ad9f2 100644 --- a/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp +++ b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp @@ -10,33 +10,33 @@ using namespace cocos2d; extern "C" { - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeRender(JNIEnv* env) { + JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeRender(JNIEnv* env) { cocos2d::CCDirector::sharedDirector()->mainLoop(); } - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause() { + JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause() { CCApplication::sharedApplication()->applicationDidEnterBackground(); CCNotificationCenter::sharedNotificationCenter()->postNotification(EVENT_COME_TO_BACKGROUND, NULL); } - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume() { + JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume() { if (CCDirector::sharedDirector()->getOpenGLView()) { CCApplication::sharedApplication()->applicationWillEnterForeground(); } } - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInsertText(JNIEnv* env, jobject thiz, jstring text) { + JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInsertText(JNIEnv* env, jobject thiz, jstring text) { const char* pszText = env->GetStringUTFChars(text, NULL); cocos2d::CCIMEDispatcher::sharedDispatcher()->dispatchInsertText(pszText, strlen(pszText)); env->ReleaseStringUTFChars(text, pszText); } - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeDeleteBackward(JNIEnv* env, jobject thiz) { + JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeDeleteBackward(JNIEnv* env, jobject thiz) { cocos2d::CCIMEDispatcher::sharedDispatcher()->dispatchDeleteBackward(); } - jstring Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeGetContentText() { + JNIEXPORT jstring JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeGetContentText() { JNIEnv * env = 0; if (JniHelper::getJavaVM()->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK || ! env) { From c2a62875cff7d3359b22738d964d085e4bedd25c Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Thu, 13 Sep 2012 11:13:02 -0700 Subject: [PATCH 010/181] Added ANDROID_SCRIPTINGCORE_LOAD_SCRIPTS_FROM_EXTERNAL_ASSET_DIRECTORY flag, that allows to load from external assets directory instead of from internal apk assets directory. --- scripting/javascript/bindings/ScriptingCore.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripting/javascript/bindings/ScriptingCore.cpp b/scripting/javascript/bindings/ScriptingCore.cpp index d516ba38bd..478956727c 100644 --- a/scripting/javascript/bindings/ScriptingCore.cpp +++ b/scripting/javascript/bindings/ScriptingCore.cpp @@ -302,7 +302,15 @@ JSBool ScriptingCore::runScript(const char *path) cocos2d::CCFileUtils *futil = cocos2d::CCFileUtils::sharedFileUtils(); +#ifdef ANDROID_SCRIPTINGCORE_LOAD_SCRIPTS_FROM_EXTERNAL_ASSET_DIRECTORY + const char * externalAssetPath = cocos2d::JniHelper::getExternalAssetPath(); + + std::string fullPath = std::string(externalAssetPath) + std::string(path); + + const char *realPath = fullPath.c_str(); +#else const char *realPath = futil->fullPathFromRelativePath(path); +#endif if (!realPath) { CCLOG("!realPath. returning JS_FALSE"); From 6fbeacf750b2814cffc56dfe29b503c67cbce83b Mon Sep 17 00:00:00 2001 From: Walzer Date: Fri, 14 Sep 2012 16:33:54 +0800 Subject: [PATCH 011/181] issue #1404, add scripts for ci --- .../android/build-android-2.2-3.2-debug.sh | 24 +++++++++---------- .../android/build-android-2.2-3.2-release.sh | 24 +++++++++---------- .../mac/android/build-android-4.x-debug.sh | 24 +++++++++---------- .../mac/android/build-android-4.x-release.sh | 24 +++++++++---------- 4 files changed, 48 insertions(+), 48 deletions(-) diff --git a/tools/jenkins_scripts/mac/android/build-android-2.2-3.2-debug.sh b/tools/jenkins_scripts/mac/android/build-android-2.2-3.2-debug.sh index 3893270da5..e671ed7ad8 100755 --- a/tools/jenkins_scripts/mac/android/build-android-2.2-3.2-debug.sh +++ b/tools/jenkins_scripts/mac/android/build-android-2.2-3.2-debug.sh @@ -88,11 +88,11 @@ ROOT=$(pwd) IsTestCpp=1 #copy configuration files to target. -cp $ROOT/tools/JenkinsScript/ant.properties $ROOT/samples/TestCpp/proj.android -cp $ROOT/tools/JenkinsScript/build.xml $ROOT/samples/TestCpp/proj.android -cp $ROOT/tools/JenkinsScript/Mac/rootconfig-Mac.sh $ROOT/samples/TestCpp/proj.android +cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/TestCpp/proj.android +cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/TestCpp/proj.android +cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/TestCpp/proj.android cd samples/TestCpp/proj.android -sh rootconfig-Mac.sh TestCpp +sh rootconfig-mac.sh TestCpp sh build_native.sh #update android project configuration files @@ -103,22 +103,22 @@ antcompile IsTestCpp=0 -cp $ROOT/tools/JenkinsScript/ant.properties $ROOT/samples/HelloCpp/proj.android -cp $ROOT/tools/JenkinsScript/build.xml $ROOT/samples/HelloCpp/proj.android -cp $ROOT/tools/JenkinsScript/Mac/rootconfig-Mac.sh $ROOT/samples/HelloCpp/proj.android +cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/HelloCpp/proj.android +cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/HelloCpp/proj.android +cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/HelloCpp/proj.android cd ../../HelloCpp/proj.android -sh rootconfig-Mac.sh HelloCpp +sh rootconfig-mac.sh HelloCpp sh build_native.sh cd .. android update project -p proj.android cd proj.android antcompile -cp $ROOT/tools/JenkinsScript/ant.properties $ROOT/samples/HelloLua/proj.android -cp $ROOT/tools/JenkinsScript/build.xml $ROOT/samples/HelloLua/proj.android -cp $ROOT/tools/JenkinsScript/Mac/rootconfig-Mac.sh $ROOT/samples/HelloLua/proj.android +cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/HelloLua/proj.android +cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/HelloLua/proj.android +cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/HelloLua/proj.android cd ../../HelloLua/proj.android -sh rootconfig-Mac.sh HelloLua +sh rootconfig-mac.sh HelloLua sh build_native.sh cd .. android update project -p proj.android diff --git a/tools/jenkins_scripts/mac/android/build-android-2.2-3.2-release.sh b/tools/jenkins_scripts/mac/android/build-android-2.2-3.2-release.sh index 8bacaf29f1..f3362a662e 100755 --- a/tools/jenkins_scripts/mac/android/build-android-2.2-3.2-release.sh +++ b/tools/jenkins_scripts/mac/android/build-android-2.2-3.2-release.sh @@ -92,11 +92,11 @@ sed -i '' '14d' $CUR/ant.properties gsed -i "14 i\\key.store=$ANDROID_HOME/debug.keystore" $CUR/ant.properties cp $CUR/../debug.keystore $ANDROID_HOME -cp $ROOT/tools/JenkinsScript/ant.properties $ROOT/samples/TestCpp/proj.android -cp $ROOT/tools/JenkinsScript/build.xml $ROOT/samples/TestCpp/proj.android -cp $ROOT/tools/JenkinsScript/Mac/rootconfig-Mac.sh $ROOT/samples/TestCpp/proj.android +cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/TestCpp/proj.android +cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/TestCpp/proj.android +cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/TestCpp/proj.android cd samples/TestCpp/proj.android -sh rootconfig-Mac.sh TestCpp +sh rootconfig-mac.sh TestCpp sh build_native.sh #update android project configuration files @@ -107,22 +107,22 @@ antcompile IsTestCpp=0 -cp $ROOT/tools/JenkinsScript/ant.properties $ROOT/samples/HelloCpp/proj.android -cp $ROOT/tools/JenkinsScript/build.xml $ROOT/samples/HelloCpp/proj.android -cp $ROOT/tools/JenkinsScript/Mac/rootconfig-Mac.sh $ROOT/samples/HelloCpp/proj.android +cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/HelloCpp/proj.android +cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/HelloCpp/proj.android +cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/HelloCpp/proj.android cd ../../HelloCpp/proj.android -sh rootconfig-Mac.sh HelloCpp +sh rootconfig-mac.sh HelloCpp sh build_native.sh cd .. android update project -p proj.android cd proj.android antcompile -cp $ROOT/tools/JenkinsScript/ant.properties $ROOT/samples/HelloLua/proj.android -cp $ROOT/tools/JenkinsScript/build.xml $ROOT/samples/HelloLua/proj.android -cp $ROOT/tools/JenkinsScript/Mac/rootconfig-Mac.sh $ROOT/samples/HelloLua/proj.android +cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/HelloLua/proj.android +cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/HelloLua/proj.android +cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/HelloLua/proj.android cd ../../HelloLua/proj.android -sh rootconfig-Mac.sh HelloLua +sh rootconfig-mac.sh HelloLua sh build_native.sh cd .. android update project -p proj.android diff --git a/tools/jenkins_scripts/mac/android/build-android-4.x-debug.sh b/tools/jenkins_scripts/mac/android/build-android-4.x-debug.sh index 5d5c442af4..6cd7f43bbf 100755 --- a/tools/jenkins_scripts/mac/android/build-android-4.x-debug.sh +++ b/tools/jenkins_scripts/mac/android/build-android-4.x-debug.sh @@ -46,11 +46,11 @@ ROOT=$(pwd) IsTestCpp=1 #copy configuration files to target. -cp $ROOT/tools/JenkinsScript/ant.properties $ROOT/samples/TestCpp/proj.android -cp $ROOT/tools/JenkinsScript/build.xml $ROOT/samples/TestCpp/proj.android -cp $ROOT/tools/JenkinsScript/Mac/rootconfig-Mac.sh $ROOT/samples/TestCpp/proj.android +cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/TestCpp/proj.android +cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/TestCpp/proj.android +cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/TestCpp/proj.android cd samples/TestCpp/proj.android -sh rootconfig-Mac.sh TestCpp +sh rootconfig-mac.sh TestCpp sh build_native.sh #update android project configuration files @@ -61,22 +61,22 @@ antcompile IsTestCpp=0 -cp $ROOT/tools/JenkinsScript/ant.properties $ROOT/samples/HelloCpp/proj.android -cp $ROOT/tools/JenkinsScript/build.xml $ROOT/samples/HelloCpp/proj.android -cp $ROOT/tools/JenkinsScript/Mac/rootconfig-Mac.sh $ROOT/samples/HelloCpp/proj.android +cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/HelloCpp/proj.android +cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/HelloCpp/proj.android +cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/HelloCpp/proj.android cd ../../HelloCpp/proj.android -sh rootconfig-Mac.sh HelloCpp +sh rootconfig-mac.sh HelloCpp sh build_native.sh cd .. android update project -p proj.android cd proj.android antcompile -cp $ROOT/tools/JenkinsScript/ant.properties $ROOT/samples/HelloLua/proj.android -cp $ROOT/tools/JenkinsScript/build.xml $ROOT/samples/HelloLua/proj.android -cp $ROOT/tools/JenkinsScript/Mac/rootconfig-Mac.sh $ROOT/samples/HelloLua/proj.android +cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/HelloLua/proj.android +cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/HelloLua/proj.android +cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/HelloLua/proj.android cd ../../HelloLua/proj.android -sh rootconfig-Mac.sh HelloLua +sh rootconfig-mac.sh HelloLua sh build_native.sh cd .. android update project -p proj.android diff --git a/tools/jenkins_scripts/mac/android/build-android-4.x-release.sh b/tools/jenkins_scripts/mac/android/build-android-4.x-release.sh index 340b477315..2cac53da27 100755 --- a/tools/jenkins_scripts/mac/android/build-android-4.x-release.sh +++ b/tools/jenkins_scripts/mac/android/build-android-4.x-release.sh @@ -50,11 +50,11 @@ sed -i '' '14d' $CUR/ant.properties gsed -i "14 i\\key.store=$ANDROID_HOME/debug.keystore" $CUR/ant.properties cp $CUR/../debug.keystore $ANDROID_HOME -cp $ROOT/tools/JenkinsScript/ant.properties $ROOT/samples/TestCpp/proj.android -cp $ROOT/tools/JenkinsScript/build.xml $ROOT/samples/TestCpp/proj.android -cp $ROOT/tools/JenkinsScript/Mac/rootconfig-Mac.sh $ROOT/samples/TestCpp/proj.android +cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/TestCpp/proj.android +cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/TestCpp/proj.android +cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/TestCpp/proj.android cd samples/TestCpp/proj.android -sh rootconfig-Mac.sh TestCpp +sh rootconfig-mac.sh TestCpp sh build_native.sh #update android project configuration files @@ -65,22 +65,22 @@ antcompile IsTestCpp=0 -cp $ROOT/tools/JenkinsScript/ant.properties $ROOT/samples/HelloCpp/proj.android -cp $ROOT/tools/JenkinsScript/build.xml $ROOT/samples/HelloCpp/proj.android -cp $ROOT/tools/JenkinsScript/Mac/rootconfig-Mac.sh $ROOT/samples/HelloCpp/proj.android +cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/HelloCpp/proj.android +cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/HelloCpp/proj.android +cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/HelloCpp/proj.android cd ../../HelloCpp/proj.android -sh rootconfig-Mac.sh HelloCpp +sh rootconfig-mac.sh HelloCpp sh build_native.sh cd .. android update project -p proj.android cd proj.android antcompile -cp $ROOT/tools/JenkinsScript/ant.properties $ROOT/samples/HelloLua/proj.android -cp $ROOT/tools/JenkinsScript/build.xml $ROOT/samples/HelloLua/proj.android -cp $ROOT/tools/JenkinsScript/Mac/rootconfig-Mac.sh $ROOT/samples/HelloLua/proj.android +cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/HelloLua/proj.android +cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/HelloLua/proj.android +cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/HelloLua/proj.android cd ../../HelloLua/proj.android -sh rootconfig-Mac.sh HelloLua +sh rootconfig-mac.sh HelloLua sh build_native.sh cd .. android update project -p proj.android From bbb37a4d7cbe896fd74921325353c6faaca9a0c2 Mon Sep 17 00:00:00 2001 From: Walzer Date: Fri, 14 Sep 2012 16:41:41 +0800 Subject: [PATCH 012/181] issue #1404, case insensitive, oops --- .../jenkins_scripts/mac/{rootconfig-Mac.sh => rootconfig-maca.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/jenkins_scripts/mac/{rootconfig-Mac.sh => rootconfig-maca.sh} (100%) diff --git a/tools/jenkins_scripts/mac/rootconfig-Mac.sh b/tools/jenkins_scripts/mac/rootconfig-maca.sh similarity index 100% rename from tools/jenkins_scripts/mac/rootconfig-Mac.sh rename to tools/jenkins_scripts/mac/rootconfig-maca.sh From 7c744e785a303e5b47ebdcc3730efb1104af2ade Mon Sep 17 00:00:00 2001 From: Walzer Date: Fri, 14 Sep 2012 16:42:44 +0800 Subject: [PATCH 013/181] fixed #1404, tweak back to lower case :) --- .../jenkins_scripts/mac/{rootconfig-maca.sh => rootconfig-mac.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/jenkins_scripts/mac/{rootconfig-maca.sh => rootconfig-mac.sh} (100%) diff --git a/tools/jenkins_scripts/mac/rootconfig-maca.sh b/tools/jenkins_scripts/mac/rootconfig-mac.sh similarity index 100% rename from tools/jenkins_scripts/mac/rootconfig-maca.sh rename to tools/jenkins_scripts/mac/rootconfig-mac.sh From 2869aba7b49f3851247df169acbda0fc76de112f Mon Sep 17 00:00:00 2001 From: dualface Date: Fri, 14 Sep 2012 17:54:53 +0800 Subject: [PATCH 014/181] avoid unused memory alloc --- cocos2dx/CCDrawingPrimitives.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/cocos2dx/CCDrawingPrimitives.cpp b/cocos2dx/CCDrawingPrimitives.cpp index 085ba16c1b..0b07e47334 100644 --- a/cocos2dx/CCDrawingPrimitives.cpp +++ b/cocos2dx/CCDrawingPrimitives.cpp @@ -186,30 +186,35 @@ void ccDrawPoly( const CCPoint *poli, unsigned int numberOfPoints, bool closePol ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); - // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed - ccVertex2F* newPoli = new ccVertex2F[numberOfPoints]; - // iPhone and 32-bit machines optimization if( sizeof(CCPoint) == sizeof(ccVertex2F) ) + { glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, poli); + if( closePolygon ) + glDrawArrays(GL_LINE_LOOP, 0, (GLsizei) numberOfPoints); + else + glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) numberOfPoints); + } else { // Mac on 64-bit + // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed + ccVertex2F* newPoli = new ccVertex2F[numberOfPoints]; for( unsigned int i=0; i Date: Fri, 14 Sep 2012 18:00:11 +0800 Subject: [PATCH 015/181] ccDrawCircle() add scaleX and scaleY --- cocos2dx/CCDrawingPrimitives.cpp | 6 +++--- cocos2dx/CCDrawingPrimitives.h | 2 +- .../lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id | 2 +- tools/tolua++/CCDrawingPrimitives.pkg | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos2dx/CCDrawingPrimitives.cpp b/cocos2dx/CCDrawingPrimitives.cpp index 085ba16c1b..2aedaed958 100644 --- a/cocos2dx/CCDrawingPrimitives.cpp +++ b/cocos2dx/CCDrawingPrimitives.cpp @@ -247,7 +247,7 @@ void ccDrawSolidPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor4 CC_INCREMENT_GL_DRAWS(1); } -void ccDrawCircle( const CCPoint& center, float radius, float angle, unsigned int segments, bool drawLineToCenter) +void ccDrawCircle( const CCPoint& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY) { lazy_init(); @@ -263,8 +263,8 @@ void ccDrawCircle( const CCPoint& center, float radius, float angle, unsigned in for(unsigned int i = 0;i <= segments; i++) { float rads = i*coef; - GLfloat j = radius * cosf(rads + angle) + center.x; - GLfloat k = radius * sinf(rads + angle) + center.y; + GLfloat j = radius * cosf(rads + angle) * scaleX + center.x; + GLfloat k = radius * sinf(rads + angle) * scaleY + center.y; vertices[i*2] = j; vertices[i*2+1] = k; diff --git a/cocos2dx/CCDrawingPrimitives.h b/cocos2dx/CCDrawingPrimitives.h index ee328e43dc..5b1df8e0b8 100644 --- a/cocos2dx/CCDrawingPrimitives.h +++ b/cocos2dx/CCDrawingPrimitives.h @@ -88,7 +88,7 @@ void CC_DLL ccDrawPoly( const CCPoint *vertices, unsigned int numOfVertices, boo void CC_DLL ccDrawSolidPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor4F color ); /** draws a circle given the center, radius and number of segments. */ -void CC_DLL ccDrawCircle( const CCPoint& center, float radius, float angle, unsigned int segments, bool drawLineToCenter); +void CC_DLL ccDrawCircle( const CCPoint& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX = 1.0f, float scaleY = 1.0f); /** draws a quad bezier path @warning This function could be pretty slow. Use it only for debugging purposes. diff --git a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 6bcf2669e2..bc6ff70a17 100644 --- a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -6f56a41a68d8e682e9bd47bc0d7e6d1960608e8b \ No newline at end of file +a27fd7b26a6f47a97de7ed9dc7f1dc202ccb638d \ No newline at end of file diff --git a/tools/tolua++/CCDrawingPrimitives.pkg b/tools/tolua++/CCDrawingPrimitives.pkg index b894407850..084f7154dd 100644 --- a/tools/tolua++/CCDrawingPrimitives.pkg +++ b/tools/tolua++/CCDrawingPrimitives.pkg @@ -6,7 +6,7 @@ void ccDrawRect(CCPoint origin, CCPoint destination); void ccDrawSolidRect(CCPoint origin, CCPoint destination, ccColor4F color); void ccDrawPoly(const CCPoint *vertices, unsigned int numOfVertices, bool closePolygon); void ccDrawSolidPoly(const CCPoint* poli, unsigned int numberOfPoints, ccColor4F color); -void ccDrawCircle(CCPoint center, float radius, float angle, unsigned int segments, bool drawLineToCenter); +void ccDrawCircle(const CCPoint& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float xScale = 1.0f, float yScale = 1.0f); void ccDrawQuadBezier(CCPoint origin, CCPoint control, CCPoint destination, unsigned int segments); void ccDrawCubicBezier(CCPoint origin, CCPoint control1, CCPoint control2, CCPoint destination, unsigned int segments); void ccDrawCatmullRom(CCPointArray* arrayOfControlPoints, unsigned int segments); From 7c750dc9c5181f532d8f83625f45ce6711d0fb1e Mon Sep 17 00:00:00 2001 From: Donald Alan Morrison Date: Fri, 14 Sep 2012 15:26:38 -0700 Subject: [PATCH 016/181] Minor changes to comments. One integer literal changed to float literal. --- cocos2dx/CCDirector.cpp | 11 +++--- cocos2dx/CCDirector.h | 2 +- cocos2dx/base_nodes/CCNode.cpp | 2 +- cocos2dx/platform/CCApplicationProtocol.h | 2 +- cocos2dx/platform/CCEGLViewProtocol.h | 29 ++++++++------- cocos2dx/platform/CCFileUtils.h | 28 +++++++-------- cocos2dx/platform/CCImage.h | 36 +++++++++---------- cocos2dx/platform/CCPlatformConfig.h | 8 ++--- cocos2dx/platform/ios/CCApplication.h | 4 +-- cocos2dx/platform/ios/CCApplication.mm | 2 +- cocos2dx/platform/ios/CCEGLView.mm | 3 +- .../cocos2dx.xctemplate/Classes/AppDelegate.h | 10 +++--- .../Classes/HelloWorldScene.h | 8 ++--- 13 files changed, 68 insertions(+), 77 deletions(-) diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 9eb2ac492a..1d5f1e0831 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -136,7 +136,7 @@ bool CCDirector::init(void) m_pobOpenGLView = NULL; - m_fContentScaleFactor = 1; + m_fContentScaleFactor = 1.0f; m_bIsContentScaleSupported = false; // scheduler @@ -200,7 +200,7 @@ void CCDirector::setGLDefaultValues(void) glClearColor(0.0f, 0.0f, 0.0f, 1.0f); } -// Draw the SCene +// Draw the Scene void CCDirector::drawScene(void) { // calculate "global" dt @@ -290,16 +290,13 @@ void CCDirector::calculateDeltaTime(void) *m_pLastUpdate = now; } - -// m_pobOpenGLView - void CCDirector::setOpenGLView(CCEGLView *pobOpenGLView) { CCAssert(pobOpenGLView, "opengl view should not be null"); if (m_pobOpenGLView != pobOpenGLView) { - // because EAGLView is not kind of CCObject + // EAGLView is not a CCObject delete m_pobOpenGLView; // [openGLView_ release] m_pobOpenGLView = pobOpenGLView; @@ -942,7 +939,7 @@ CCAccelerometer* CCDirector::getAccelerometer() * implementation of DisplayLinkDirector **************************************************/ -// should we afford 4 types of director ?? +// should we implement 4 types of director ?? // I think DisplayLinkDirector is enough // so we now only support DisplayLinkDirector void CCDisplayLinkDirector::startAnimation(void) diff --git a/cocos2dx/CCDirector.h b/cocos2dx/CCDirector.h index 2407729e8a..5dc74ec0a6 100644 --- a/cocos2dx/CCDirector.h +++ b/cocos2dx/CCDirector.h @@ -83,7 +83,7 @@ and when to execute the Scenes. - setting the OpenGL pixel format (default on is RGB565) - setting the OpenGL buffer depth (default one is 0-bit) - setting the projection (default one is 3D) - - setting the orientation (default one is Protrait) + - setting the orientation (default one is Portrait) Since the CCDirector is a singleton, the standard way to use it is by calling: _ CCDirector::sharedDirector()->methodName(); diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 43d80de089..ac6fecc29f 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -681,7 +681,7 @@ void CCNode::sortAllChildren() { //CCAssert(0); // override me - // Only use- this function to draw your staff. + // Only use- this function to draw your stuff. // DON'T draw your stuff outside this method } diff --git a/cocos2dx/platform/CCApplicationProtocol.h b/cocos2dx/platform/CCApplicationProtocol.h index 76cadc8e05..6af58621a7 100644 --- a/cocos2dx/platform/CCApplicationProtocol.h +++ b/cocos2dx/platform/CCApplicationProtocol.h @@ -46,7 +46,7 @@ public: /** @brief Callback by CCDirector for limit FPS. - @interval The time, which expressed in second in second, between current frame and next. + @interval The time, expressed in seconds, between current frame and next. */ virtual void setAnimationInterval(double interval) = 0; diff --git a/cocos2dx/platform/CCEGLViewProtocol.h b/cocos2dx/platform/CCEGLViewProtocol.h index f0db5bf7f5..8c8c13c094 100644 --- a/cocos2dx/platform/CCEGLViewProtocol.h +++ b/cocos2dx/platform/CCEGLViewProtocol.h @@ -77,14 +77,14 @@ public: virtual CCPoint getVisibleOrigin() const; /** - * Set the design resolutin size. - * You can't use it with enableRetina together. + * Set the design resolution size. + * Behavior undefined when enableRetina == true. * @param width Design resolution width. * @param height Design resolution height. - * @param resolutionPolicy The resolution policy you need, there are: - * [1] kCCResolutionExactFit Fill screen, if the design resolution ratio of width and height is different from the screen resolution ratio, your game view will be stretched. - * [2] kCCResolutionNoBorder Full screen without black border, if the design resolution ratio of width and height is different from the screen resolution ratio, two areas of your game view will be cut. - * [3] kCCResolutionShowAll Full screen with black border, if the design resolution ratio of width and height is different from the screen resolution ratio, two black border will be shown on the screen; + * @param resolutionPolicy The resolution policy desired, you may choose: + * [1] kCCResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched. + * [2] kCCResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut. + * [3] kCCResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown. */ virtual void setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy); @@ -93,7 +93,7 @@ public: /** * Set content scale factor. - * @return If return true, it means the plaform supports retina display. + * @return If the return value is true, the plaform supports retina display mode. */ virtual bool setContentScaleFactor(float contentScaleFactor); @@ -113,30 +113,29 @@ public: */ virtual bool enableRetina(); - /** handle touch events by default, if you want to custom your handles, please override these functions */ + /** Touch events are handled by default; if you want to customize your handlers, please override these functions: */ virtual void handleTouchesBegin(int num, int ids[], float xs[], float ys[]); virtual void handleTouchesMove(int num, int ids[], float xs[], float ys[]); virtual void handleTouchesEnd(int num, int ids[], float xs[], float ys[]); virtual void handleTouchesCancel(int num, int ids[], float xs[], float ys[]); /** - * Get opengl view port rectangle. + * Get the opengl view port rectangle. */ const CCRect& getViewPortRect() const; /** - * Get the scale factor of horizontal direction. - * + * Get scale factor of the horizontal direction. */ float getScaleX() const; /** - * Get the scale factor of vertical direction. + * Get scale factor of the vertical direction. */ float getScaleY() const; /** - * Get whether the retina mode is enabled. + * Get retina mode status (on if true). */ bool isRetinaEnabled() const; private: @@ -145,9 +144,9 @@ private: protected: EGLTouchDelegate* m_pDelegate; - // real size of screen + // real screen size CCSize m_obScreenSize; - // resolution size, it is the size the app resources designed for + // resolution size, it is the size appropriate for the app resources. CCSize m_obDesignResolutionSize; // the view port size CCRect m_obViewPortRect; diff --git a/cocos2dx/platform/CCFileUtils.h b/cocos2dx/platform/CCFileUtils.h index 100bb1db46..59d858a945 100644 --- a/cocos2dx/platform/CCFileUtils.h +++ b/cocos2dx/platform/CCFileUtils.h @@ -45,20 +45,20 @@ public: void purgeCachedEntries(); /** @brief Get resource file data - @param[in] pszFileName The resource file name which contain the path - @param[in] pszMode The read mode of the file - @param[out] pSize If get the file data succeed the it will be the data size,or it will be 0 - @return if success,the pointer of data will be returned,or NULL is returned - @warning If you get the file data succeed,you must delete[] it after used. + @param[in] pszFileName The resource file name which contains the path. + @param[in] pszMode The read mode of the file. + @param[out] pSize If the file read operation succeeds, it will be the data size, otherwise 0. + @return Upon success, a pointer to the data is returned, otherwise NULL. + @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned. */ unsigned char* getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize); /** - @brief Get resource file data from zip file - @param[in] pszFileName The resource file name which contain the relative path of zip file - @param[out] pSize If get the file data succeed the it will be the data size,or it will be 0 - @return if success,the pointer of data will be returned,or NULL is returned - @warning If you get the file data succeed,you must delete[] it after used. + @brief Get resource file data from a zip file. + @param[in] pszFileName The resource file name which contains the relative path of the zip file. + @param[out] pSize If the file read operation succeeds, it will be the data size, otherwise 0. + @return Upon success, a pointer to the data is returned, otherwise NULL. + @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned. */ unsigned char* getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize); @@ -67,8 +67,8 @@ public: @param pszRelativePath The relative path of the file. @return The absolute path of the file. @warning We only add the ResourcePath before the relative path of the file. - If you have not set the ResourcePath,the function add "/NEWPLUS/TDA_DATA/UserData/" as default. - You can set ResourcePath by function void setResourcePath(const char *pszResourcePath); + If you have not set the ResourcePath, the function appends "/NEWPLUS/TDA_DATA/UserData/" by default. + You can set ResourcePath with void setResourcePath(const char *pszResourcePath); */ const char* fullPathFromRelativePath(const char *pszRelativePath); @@ -77,8 +77,8 @@ public: /// @endcond /** - @brief Set the resource directory,we will find resource relative to this directory - @param pszDirectoryName Relative path to root + @brief Set the resource directory; we will find resources relative to this directory. + @param pszDirectoryName Relative path to root. */ void setResourceDirectory(const char *pszDirectoryName); diff --git a/cocos2dx/platform/CCImage.h b/cocos2dx/platform/CCImage.h index bdabd97f66..310497a440 100644 --- a/cocos2dx/platform/CCImage.h +++ b/cocos2dx/platform/CCImage.h @@ -64,29 +64,29 @@ public: /** @brief Load the image from the specified path. - @param strPath the absolute file path - @param imageType the type of image, now only support tow types. - @return true if load correctly + @param strPath the absolute file path. + @param imageType the type of image, currently only supporting two types. + @return true if loaded correctly. */ bool initWithImageFile(const char * strPath, EImageFormat imageType = kFmtPng); /* @brief The same meaning as initWithImageFile, but it is thread safe. It is casued by loadImage() in CCTextureCache.cpp. - @param fullpath full path of the file - @param imageType the type of image, now only support tow types. - @return true if load correctly + @param fullpath full path of the file. + @param imageType the type of image, currently only supporting two types. + @return true if loaded correctly. */ bool initWithImageFileThreadSafe(const char *fullpath, EImageFormat imageType = kFmtPng); /** @brief Load image from stream buffer. - @warning kFmtRawData only support RGBA8888 - @param pBuffer stream buffer that hold the image data - @param nLength the length of data(managed in byte) - @param nWidth, nHeight, nBitsPerComponent are used for kFmtRawData - @return true if load correctly + @warning kFmtRawData only supports RGBA8888. + @param pBuffer stream buffer which holds the image data. + @param nLength data length expressed in (number of) bytes. + @param nWidth, nHeight, nBitsPerComponent are used for kFmtRawData. + @return true if loaded correctly. */ bool initWithImageData(void * pData, int nDataLen, @@ -97,11 +97,11 @@ public: /** @brief Create image with specified string. - @param pText the text which the image show, nil cause init fail - @param nWidth the image width, if 0, the width match the text's width - @param nHeight the image height, if 0, the height match the text's height + @param pText the text the image will show (cannot be nil). + @param nWidth the image width, if 0, the width will match the text's width. + @param nHeight the image height, if 0, the height will match the text's height. @param eAlignMask the test Alignment - @param pFontName the name of the font which use to draw the text. If nil, use the default system font. + @param pFontName the name of the font used to draw the text. If nil, use the default system font. @param nSize the font size, if 0, use the system default size. */ bool initWithString( @@ -119,9 +119,9 @@ public: bool isPremultipliedAlpha() { return m_bPreMulti; } /** - @brief Save the CCImage data to specified file with specified format. - @param pszFilePath the file's absolute path, including file subfix - @param bIsToRGB if the image is saved as RGB format + @brief Save CCImage data to the specified file, with specified format. + @param pszFilePath the file's absolute path, including file subfix. + @param bIsToRGB whether the image is saved as RGB format. */ bool saveToFile(const char *pszFilePath, bool bIsToRGB = true); diff --git a/cocos2dx/platform/CCPlatformConfig.h b/cocos2dx/platform/CCPlatformConfig.h index f1f3aaeaa6..882ae49e13 100644 --- a/cocos2dx/platform/CCPlatformConfig.h +++ b/cocos2dx/platform/CCPlatformConfig.h @@ -26,10 +26,7 @@ THE SOFTWARE. #define __CC_PLATFORM_CONFIG_H__ /** -Config of cocos2d-x project. - -There are config below: -build for which target platform +Config of cocos2d-x project, per target platform. */ ////////////////////////////////////////////////////////////////////////// @@ -106,10 +103,9 @@ build for which target platform // check user set platform #if ! CC_TARGET_PLATFORM - #error "Can not recognize the target platform, compling under a unsupported platform?" + #error "Cannot recognize the target platform; are you targeting an unsupported platform?" #endif -// Check the supportive of platform #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #pragma warning (disable:4127) #endif // CC_PLATFORM_WIN32 diff --git a/cocos2dx/platform/ios/CCApplication.h b/cocos2dx/platform/ios/CCApplication.h index 8b7e383c8f..74885cf795 100644 --- a/cocos2dx/platform/ios/CCApplication.h +++ b/cocos2dx/platform/ios/CCApplication.h @@ -44,14 +44,14 @@ public: int run(); /** - @brief Get current applicaiton instance. + @brief Get the current application instance. @return Current application instance pointer. */ static CCApplication* sharedApplication(); /** @brief Callback by CCDirector for limit FPS. - @interval The time, which expressed in second in second, between current frame and next. + @interval The time, expressed in seconds, between current frame and next. */ virtual void setAnimationInterval(double interval); diff --git a/cocos2dx/platform/ios/CCApplication.mm b/cocos2dx/platform/ios/CCApplication.mm index ff295f7ab5..9e2f2f4b6f 100644 --- a/cocos2dx/platform/ios/CCApplication.mm +++ b/cocos2dx/platform/ios/CCApplication.mm @@ -110,7 +110,7 @@ ccLanguageType CCApplication::getCurrentLanguage() TargetPlatform CCApplication::getTargetPlatform() { - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) // idiom for iOS <= 3.2, otherwise: [UIDevice userInterfaceIdiom] is faster. { return kTargetIpad; } diff --git a/cocos2dx/platform/ios/CCEGLView.mm b/cocos2dx/platform/ios/CCEGLView.mm index c672ad8ff4..68fb7d15cc 100644 --- a/cocos2dx/platform/ios/CCEGLView.mm +++ b/cocos2dx/platform/ios/CCEGLView.mm @@ -48,8 +48,7 @@ bool CCEGLView::isOpenGLReady() bool CCEGLView::setContentScaleFactor(float contentScaleFactor) { - // can not enable retina because have used resolution policy - assert(m_eResolutionPolicy == kResolutionUnKnown); + assert(m_eResolutionPolicy == kResolutionUnKnown); // cannot enable retina mode if ([[EAGLView sharedEGLView] respondsToSelector:@selector(setContentScaleFactor:)]) { diff --git a/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.h b/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.h index d02100efd0..3a7d36517a 100644 --- a/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.h +++ b/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.h @@ -14,7 +14,7 @@ /** @brief The cocos2d Application. -The reason for implement as private inheritance is to hide some interface call by CCDirector. +The reason to implement with private inheritance is to hide some interface details of CCDirector. */ class AppDelegate : private cocos2d::CCApplication { @@ -30,14 +30,14 @@ public: virtual bool applicationDidFinishLaunching(); /** - @brief The function be called when the application enter background - @param the pointer of the application + @brief The function is called when the application enters the background + @param the pointer of the application instance */ virtual void applicationDidEnterBackground(); /** - @brief The function be called when the application enter foreground - @param the pointer of the application + @brief The function is called when the application enters the foreground + @param the pointer of the application instance */ virtual void applicationWillEnterForeground(); }; diff --git a/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.h b/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.h index e202b8c2c3..82416bdc22 100644 --- a/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.h +++ b/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.h @@ -6,16 +6,16 @@ class HelloWorld : public cocos2d::CCLayer { public: - // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone - virtual bool init(); + // Method 'init' in cocos2d-x returns bool, instead of 'id' in cocos2d-iphone (an object pointer) + virtual bool init(); - // there's no 'id' in cpp, so we recommand to return the exactly class pointer + // there's no 'id' in cpp, so we recommend to return the class instance pointer static cocos2d::CCScene* scene(); // a selector callback void menuCloseCallback(CCObject* pSender); - // implement the "static node()" method manually + // preprocessor macro for "static create()" constructor ( node() deprecated ) CREATE_FUNC(HelloWorld); }; From b29f9a7f3bf6732aa33e3060dadb5b00cf2b96c5 Mon Sep 17 00:00:00 2001 From: Donald Alan Morrison Date: Fri, 14 Sep 2012 15:41:42 -0700 Subject: [PATCH 017/181] Missed one spelling error. --- cocos2dx/platform/CCEGLViewProtocol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/platform/CCEGLViewProtocol.h b/cocos2dx/platform/CCEGLViewProtocol.h index 8c8c13c094..bfba7c32f1 100644 --- a/cocos2dx/platform/CCEGLViewProtocol.h +++ b/cocos2dx/platform/CCEGLViewProtocol.h @@ -93,7 +93,7 @@ public: /** * Set content scale factor. - * @return If the return value is true, the plaform supports retina display mode. + * @return If the return value is true, the platform supports retina display mode. */ virtual bool setContentScaleFactor(float contentScaleFactor); From f4ddabb94277e53792c4f3608d0ed68b4577edba Mon Sep 17 00:00:00 2001 From: James Chen Date: Sat, 15 Sep 2012 15:36:31 +0800 Subject: [PATCH 018/181] Updated "ant.properties" for TestJavascript project since it will ignore 'assets/Images, assets/Fonts' folder. --- samples/TestJavascript/proj.android/ant.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/TestJavascript/proj.android/ant.properties b/samples/TestJavascript/proj.android/ant.properties index ce44c76b37..f8af38bfb4 100644 --- a/samples/TestJavascript/proj.android/ant.properties +++ b/samples/TestJavascript/proj.android/ant.properties @@ -1 +1 @@ -aapt.ignore.assets="!*.pvr.gz:!*.gz:!Images:!Fonts:!.svn:!.git:.*:_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~" +aapt.ignore.assets="!*.pvr.gz:!*.gz:!.svn:!.git:.*:_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~" From febafa6e82bbdc34f55b625f2e6535da1d5fda42 Mon Sep 17 00:00:00 2001 From: Nat Weiss Date: Sat, 15 Sep 2012 00:37:12 -0700 Subject: [PATCH 019/181] Fixes CCThread.cpp so it is not included for Mac builds. The Mac platform already has it's own CCThread.mm. --- cocos2dx/platform/CCThread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2dx/platform/CCThread.cpp b/cocos2dx/platform/CCThread.cpp index 7271c76ec3..b5342aa7e5 100644 --- a/cocos2dx/platform/CCThread.cpp +++ b/cocos2dx/platform/CCThread.cpp @@ -24,8 +24,8 @@ THE SOFTWARE. #include "CCThread.h" -// iOS already has a CCThread.mm -#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) +// iOS and Mac already has a CCThread.mm +#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS && CC_TARGET_PLATFORM != CC_PLATFORM_MAC) NS_CC_BEGIN From 9a042b805646e2d368dd426be270b0332e65f4fb Mon Sep 17 00:00:00 2001 From: Walzer Date: Sat, 15 Sep 2012 21:11:50 +0800 Subject: [PATCH 020/181] fix a potential memory leak in CCTextureCache::addImage. Thanks to Alexander Markevich. --- cocos2dx/textures/CCTextureCache.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 12551ad858..7daf06cd58 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -437,8 +437,15 @@ CCTexture2D * CCTextureCache::addImage(const char * path) CCImage image; unsigned long nSize = 0; unsigned char* pBuffer = CCFileUtils::sharedFileUtils()->getFileData(fullpath.c_str(), "rb", &nSize); - CC_BREAK_IF(! image.initWithImageData((void*)pBuffer, nSize, eImageFormat)); - CC_SAFE_DELETE_ARRAY(pBuffer); + if (! image.initWithImageData((void*)pBuffer, nSize, eImageFormat)) + { + CC_SAFE_DELETE_ARRAY(pBuffer); + break; + } + else + { + CC_SAFE_DELETE_ARRAY(pBuffer); + } texture = new CCTexture2D(); From 216ebab0e1c65077d468935d82869e8ff1a9eea2 Mon Sep 17 00:00:00 2001 From: Donald Alan Morrison Date: Sat, 15 Sep 2012 14:19:14 -0700 Subject: [PATCH 021/181] Minor English Spelling Corrections, etc. --- cocos2dx/CCCamera.h | 2 +- cocos2dx/CCDirector.cpp | 4 ++-- cocos2dx/CCDirector.h | 2 +- cocos2dx/CCDrawingPrimitives.cpp | 4 ++-- cocos2dx/CCDrawingPrimitives.h | 6 +++--- cocos2dx/CCScheduler.cpp | 10 +++++----- cocos2dx/CCScheduler.h | 8 ++++---- cocos2dx/platform/CCCommon.h | 2 +- cocos2dx/platform/CCEGLViewProtocol.cpp | 2 +- cocos2dx/platform/CCEGLViewProtocol.h | 2 +- cocos2dx/platform/CCFileUtilsCommon_cpp.h | 4 ++-- cocos2dx/platform/CCImage.h | 4 ++-- cocos2dx/platform/CCImageCommon_cpp.h | 12 ++++++------ cocos2dx/platform/CCPlatformConfig.h | 2 +- cocos2dx/platform/CCSAXParser.cpp | 2 +- cocos2dx/platform/android/CCApplication.h | 10 +++++----- cocos2dx/platform/android/CCGL.h | 2 +- cocos2dx/platform/android/CCImage.cpp | 2 +- cocos2dx/platform/ios/CCDirectorCaller.mm | 4 ++-- cocos2dx/platform/ios/CCFileUtils.mm | 2 +- cocos2dx/platform/ios/CCImage.mm | 2 +- cocos2dx/platform/ios/EAGLView.mm | 2 +- cocos2dx/platform/ios/FontLabel/ZAttributedString.m | 2 +- .../ios/Simulation/AccelerometerSimulation.h | 2 +- .../ios/Simulation/AccelerometerSimulation.m | 2 +- 25 files changed, 48 insertions(+), 48 deletions(-) diff --git a/cocos2dx/CCCamera.h b/cocos2dx/CCCamera.h index 310031146f..e38f6c478d 100644 --- a/cocos2dx/CCCamera.h +++ b/cocos2dx/CCCamera.h @@ -58,7 +58,7 @@ using the camera. - It doesn't work on batched nodes like CCSprite objects when they are parented to a CCSpriteBatchNode object. -- It is recommended to use it ONLY if you are going to create 3D effects. For 2D effecs, use the action CCFollow or position/scale/rotate. +- It is recommended to use it ONLY if you are going to create 3D effects. For 2D effects, use the action CCFollow or position/scale/rotate. */ class CC_DLL CCCamera : public CCObject diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index ff548c49ae..5b86564aad 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -70,7 +70,7 @@ using namespace std; unsigned int g_uNumberOfDraws = 0; NS_CC_BEGIN -// XXX it shoul be a Director ivar. Move it there once support for multiple directors is added +// XXX it should be a Director ivar. Move it there once support for multiple directors is added // singleton stuff static CCDisplayLinkDirector s_SharedDirector; @@ -814,7 +814,7 @@ bool CCDirector::enableRetinaDisplay(bool enabled) return true; } - // Already diabled? + // Already disabled? if (!enabled && m_fContentScaleFactor == 1) { return false; diff --git a/cocos2dx/CCDirector.h b/cocos2dx/CCDirector.h index 5dc74ec0a6..9cbc06d6b2 100644 --- a/cocos2dx/CCDirector.h +++ b/cocos2dx/CCDirector.h @@ -58,7 +58,7 @@ typedef enum { /// it calls "updateProjection" on the projection delegate. kCCDirectorProjectionCustom, - /// Detault projection is 3D projection + /// Default projection is 3D projection kCCDirectorProjectionDefault = kCCDirectorProjection3D, } ccDirectorProjection; diff --git a/cocos2dx/CCDrawingPrimitives.cpp b/cocos2dx/CCDrawingPrimitives.cpp index 085ba16c1b..b51bb83d3e 100644 --- a/cocos2dx/CCDrawingPrimitives.cpp +++ b/cocos2dx/CCDrawingPrimitives.cpp @@ -54,7 +54,7 @@ static void lazy_init( void ) if( ! s_bInitialized ) { // - // Position and 1 color passed as a uniform (to similate glColor4ub ) + // Position and 1 color passed as a uniform (to simulate glColor4ub ) // s_pShader = CCShaderCache::sharedShaderCache()->programForKey(kCCShader_Position_uColor); @@ -67,7 +67,7 @@ static void lazy_init( void ) } } -// When back to foreground on android, we want to it to inilialize again +// When back to foreground on android, we want to it to initialize again void ccDrawInit() { s_bInitialized = false; diff --git a/cocos2dx/CCDrawingPrimitives.h b/cocos2dx/CCDrawingPrimitives.h index ee328e43dc..da8311fce8 100644 --- a/cocos2dx/CCDrawingPrimitives.h +++ b/cocos2dx/CCDrawingPrimitives.h @@ -56,7 +56,7 @@ NS_CC_BEGIN class CCPointArray; -/** initlialize context */ +/** initialize context */ void CC_DLL ccDrawInit(); /** draws a point given x and y coordinate measured in points */ @@ -78,12 +78,12 @@ void CC_DLL ccDrawRect( CCPoint origin, CCPoint destination ); */ void CC_DLL ccDrawSolidRect( CCPoint origin, CCPoint destination, ccColor4F color ); -/** draws a poligon given a pointer to CCPoint coordiantes and the number of vertices measured in points. +/** draws a polygon given a pointer to CCPoint coordinates and the number of vertices measured in points. The polygon can be closed or open */ void CC_DLL ccDrawPoly( const CCPoint *vertices, unsigned int numOfVertices, bool closePolygon ); -/** draws a solid polygon given a pointer to CGPoint coordiantes, the number of vertices measured in points, and a color. +/** draws a solid polygon given a pointer to CGPoint coordinates, the number of vertices measured in points, and a color. */ void CC_DLL ccDrawSolidPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor4F color ); diff --git a/cocos2dx/CCScheduler.cpp b/cocos2dx/CCScheduler.cpp index 98004e49fb..e7ce2c8e23 100644 --- a/cocos2dx/CCScheduler.cpp +++ b/cocos2dx/CCScheduler.cpp @@ -375,7 +375,7 @@ void CCScheduler::priorityIn(tListEntry **ppList, CCObject *pTarget, int nPriori pListElement->next = pListElement->prev = NULL; pListElement->markedForDeletion = false; - // empey list ? + // empty list ? if (! *ppList) { DL_APPEND(*ppList, pListElement); @@ -763,7 +763,7 @@ void CCScheduler::update(float dt) dt *= m_fTimeScale; } - // Iterate all over the Updates selectors + // Iterate over all the Updates' selectors tListEntry *pEntry, *pTmp; // updates with priority < 0 @@ -799,7 +799,7 @@ void CCScheduler::update(float dt) } } - // Interate all over the custom selectors + // Iterate over all the custom selectors for (tHashSelectorEntry *elt = m_pHashForSelectors; elt != NULL; ) { m_pCurrentTarget = elt; @@ -838,7 +838,7 @@ void CCScheduler::update(float dt) } } - // Interate all over the script callbacks + // Iterate over all the script callbacks if (m_pScriptHandlerEntries) { for (int i = m_pScriptHandlerEntries->count() - 1; i >= 0; i--) @@ -855,7 +855,7 @@ void CCScheduler::update(float dt) } } - // delete all updates that are morked for deletion + // delete all updates that are marked for deletion // updates with priority < 0 DL_FOREACH_SAFE(m_pUpdatesNegList, pEntry, pTmp) { diff --git a/cocos2dx/CCScheduler.h b/cocos2dx/CCScheduler.h index d15cabc221..d342ca65e3 100644 --- a/cocos2dx/CCScheduler.h +++ b/cocos2dx/CCScheduler.h @@ -47,7 +47,7 @@ class CCSet; // // CCTimer // -/** @brief Light weight timer */ +/** @brief Light-weight timer */ class CC_DLL CCTimer : public CCObject { public: @@ -108,7 +108,7 @@ struct _hashUpdateEntry; class CCArray; -/** @brief Scheduler is responsible of triggering the scheduled callbacks. +/** @brief Scheduler is responsible for triggering the scheduled callbacks. You should not use NSTimer. Instead use this class. There are 2 different types of callbacks (selectors): @@ -142,9 +142,9 @@ public: /** The scheduled method will be called every 'interval' seconds. If paused is YES, then it won't be called until it is resumed. - If 'interval' is 0, it will be called every frame, but if so, it recommened to use 'scheduleUpdateForTarget:' instead. + If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead. If the selector is already scheduled, then only the interval parameter will be updated without re-scheduling it again. - repeat let the action be repeated repeat + 1 times, use kCCRepeatForever to let the action run continiously + repeat let the action be repeated repeat + 1 times, use kCCRepeatForever to let the action run continuously delay is the amount of time the action will wait before it'll start @since v0.99.3, repeat and delay added in v1.1 diff --git a/cocos2dx/platform/CCCommon.h b/cocos2dx/platform/CCCommon.h index 2082f16d6e..93a963a32f 100644 --- a/cocos2dx/platform/CCCommon.h +++ b/cocos2dx/platform/CCCommon.h @@ -53,7 +53,7 @@ void CC_DLL CCLuaLog(const char * pszFormat); void CC_DLL CCMessageBox(const char * pszMsg, const char * pszTitle); /** -@brief Enum the language type supportted now +@brief Enum the language type supported now */ typedef enum LanguageType { diff --git a/cocos2dx/platform/CCEGLViewProtocol.cpp b/cocos2dx/platform/CCEGLViewProtocol.cpp index cd6ea0fbe7..a4e6080377 100644 --- a/cocos2dx/platform/CCEGLViewProtocol.cpp +++ b/cocos2dx/platform/CCEGLViewProtocol.cpp @@ -91,7 +91,7 @@ void CCEGLViewProtocol::setDesignResolutionSize(float width, float height, Resol //setViewPortInPoints(0, 0,m_obScreenSize.width, m_obScreenSize.height); - // reset director's member vaviables to fit visible rect + // reset director's member variables to fit visible rect CCDirector::sharedDirector()->createStatsLabel(); CCDirector::sharedDirector()->m_obWinSizeInPoints = CCDirector::sharedDirector()->m_obWinSizeInPixels = getSize(); CCDirector::sharedDirector()->setGLDefaultValues(); diff --git a/cocos2dx/platform/CCEGLViewProtocol.h b/cocos2dx/platform/CCEGLViewProtocol.h index bfba7c32f1..aa03d423a6 100644 --- a/cocos2dx/platform/CCEGLViewProtocol.h +++ b/cocos2dx/platform/CCEGLViewProtocol.h @@ -36,7 +36,7 @@ public: CCEGLViewProtocol(); virtual ~CCEGLViewProtocol(); - /** Force destorying EGL view, subclass must implement this method. */ + /** Force destroying EGL view, subclass must implement this method. */ virtual void end() = 0; /** Get whether opengl render system is ready, subclass must implement this method. */ diff --git a/cocos2dx/platform/CCFileUtilsCommon_cpp.h b/cocos2dx/platform/CCFileUtilsCommon_cpp.h index 63efba2b5e..7e575eabf6 100644 --- a/cocos2dx/platform/CCFileUtilsCommon_cpp.h +++ b/cocos2dx/platform/CCFileUtilsCommon_cpp.h @@ -199,7 +199,7 @@ public: } else if (preState == SAX_ARRAY) { - CCAssert(! m_tArrayStack.empty(), "The state is worng!"); + CCAssert(! m_tArrayStack.empty(), "The state is wrong!"); CCArray* pPreArray = m_tArrayStack.top(); pPreArray->addObject(m_pArray); } @@ -305,7 +305,7 @@ public: { if (curState == SAX_DICT) { - CCAssert(!m_sCurKey.empty(), "not found key : "); + CCAssert(!m_sCurKey.empty(), "key not found : "); } m_sCurValue.append(pText->getCString()); diff --git a/cocos2dx/platform/CCImage.h b/cocos2dx/platform/CCImage.h index 310497a440..3deb5bd37e 100644 --- a/cocos2dx/platform/CCImage.h +++ b/cocos2dx/platform/CCImage.h @@ -71,7 +71,7 @@ public: bool initWithImageFile(const char * strPath, EImageFormat imageType = kFmtPng); /* - @brief The same meaning as initWithImageFile, but it is thread safe. It is casued by + @brief The same result as with initWithImageFile, but thread safe. It is caused by loadImage() in CCTextureCache.cpp. @param fullpath full path of the file. @param imageType the type of image, currently only supporting two types. @@ -120,7 +120,7 @@ public: /** @brief Save CCImage data to the specified file, with specified format. - @param pszFilePath the file's absolute path, including file subfix. + @param pszFilePath the file's absolute path, including file suffix. @param bIsToRGB whether the image is saved as RGB format. */ bool saveToFile(const char *pszFilePath, bool bIsToRGB = true); diff --git a/cocos2dx/platform/CCImageCommon_cpp.h b/cocos2dx/platform/CCImageCommon_cpp.h index f060ce9f9a..5b0a60e93d 100644 --- a/cocos2dx/platform/CCImageCommon_cpp.h +++ b/cocos2dx/platform/CCImageCommon_cpp.h @@ -40,7 +40,7 @@ NS_CC_BEGIN // premultiply alpha, or the effect will wrong when want to use other pixel format in CCTexture2D, // such as RGB888, RGB5A1 -#define CC_RGB_PREMULTIPLY_APLHA(vr, vg, vb, va) \ +#define CC_RGB_PREMULTIPLY_ALPHA(vr, vg, vb, va) \ (unsigned)(((unsigned)((unsigned char)(vr) * ((unsigned char)(va) + 1)) >> 8) | \ ((unsigned)((unsigned char)(vg) * ((unsigned char)(va) + 1) >> 8) << 8) | \ ((unsigned)((unsigned char)(vb) * ((unsigned char)(va) + 1) >> 8) << 16) | \ @@ -71,7 +71,7 @@ static void pngReadCallback(png_structp png_ptr, png_bytep data, png_size_t leng } ////////////////////////////////////////////////////////////////////////// -// Impliment CCImage +// Implement CCImage ////////////////////////////////////////////////////////////////////////// CCImage::CCImage() @@ -325,7 +325,7 @@ bool CCImage::_initWithPngData(void * pData, int nDatalen) { png_set_palette_to_rgb(png_ptr); } - // low-bit-depth grayscale iamges are to be expanded to 8 bits + // low-bit-depth grayscale images are to be expanded to 8 bits if (color_type == PNG_COLOR_TYPE_GRAY && m_nBitsPerComponent < 8) { png_set_expand_gray_1_2_4_to_8(png_ptr); @@ -376,7 +376,7 @@ bool CCImage::_initWithPngData(void * pData, int nDatalen) { for(unsigned int j = 0; j < rowbytes; j += 4) { - *tmp++ = CC_RGB_PREMULTIPLY_APLHA( row_pointers[i][j], row_pointers[i][j + 1], + *tmp++ = CC_RGB_PREMULTIPLY_ALPHA( row_pointers[i][j], row_pointers[i][j + 1], row_pointers[i][j + 2], row_pointers[i][j + 3] ); } } @@ -553,7 +553,7 @@ bool CCImage::_initWithTiffData(void* pData, int nDataLen) after invoking TIFFReadRGBAImageOriented for(int j = 0; j < m_nWidth * m_nHeight * 4; j += 4) { - *tmp++ = CC_RGB_PREMULTIPLY_APLHA( src[j], src[j + 1], + *tmp++ = CC_RGB_PREMULTIPLY_ALPHA( src[j], src[j + 1], src[j + 2], src[j + 3] ); } */ @@ -585,7 +585,7 @@ bool CCImage::_initWithRawData(void * pData, int nDatalen, int nWidth, int nHeig m_nWidth = (short)nWidth; m_bHasAlpha = true; - // only RGBA8888 surported + // only RGBA8888 supported int nBytesPerComponent = 4; int nSize = nHeight * nWidth * nBytesPerComponent; m_pData = new unsigned char[nSize]; diff --git a/cocos2dx/platform/CCPlatformConfig.h b/cocos2dx/platform/CCPlatformConfig.h index 882ae49e13..43b61e2a3a 100644 --- a/cocos2dx/platform/CCPlatformConfig.h +++ b/cocos2dx/platform/CCPlatformConfig.h @@ -44,7 +44,7 @@ Config of cocos2d-x project, per target platform. #define CC_PLATFORM_BLACKBERRY 7 #define CC_PLATFORM_MAC 8 -// Determine tartet platform by compile environment macro. +// Determine target platform by compile environment macro. #define CC_TARGET_PLATFORM CC_PLATFORM_UNKNOWN // iphone diff --git a/cocos2dx/platform/CCSAXParser.cpp b/cocos2dx/platform/CCSAXParser.cpp index cf0897a026..2dc1c8fd41 100644 --- a/cocos2dx/platform/CCSAXParser.cpp +++ b/cocos2dx/platform/CCSAXParser.cpp @@ -49,7 +49,7 @@ bool CCSAXParser::init(const char *pszEncoding) bool CCSAXParser::parse(const char* pXMLData, unsigned int uDataLength) { /* - * this initialize the library and check potential ABI mismatches + * this initializes the library and checks potential ABI mismatches * between the version it was compiled for and the actual shared * library used. */ diff --git a/cocos2dx/platform/android/CCApplication.h b/cocos2dx/platform/android/CCApplication.h index 8e42f45b9b..7fead7cdd0 100644 --- a/cocos2dx/platform/android/CCApplication.h +++ b/cocos2dx/platform/android/CCApplication.h @@ -15,8 +15,8 @@ public: virtual ~CCApplication(); /** - @brief Callback by CCDirector for limit FPS. - @interval The time, which expressed in second in second, between current frame and next. + @brief Callback by CCDirector to limit FPS. + @interval The time, expressed in seconds, between current frame and next. */ void setAnimationInterval(double interval); @@ -33,8 +33,8 @@ public: } Orientation; /** - @brief Callback by CCDirector for change device orientation. - @orientation The defination of orientation which CCDirector want change to. + @brief Callback by CCDirector to change device orientation. + @orientation The desired orientation. @return The actual orientation of the application. */ Orientation setOrientation(Orientation orientation); @@ -45,7 +45,7 @@ public: int run(); /** - @brief Get current applicaiton instance. + @brief Get current application instance. @return Current application instance pointer. */ static CCApplication* sharedApplication(); diff --git a/cocos2dx/platform/android/CCGL.h b/cocos2dx/platform/android/CCGL.h index b80308e0ad..aa690cd5cc 100644 --- a/cocos2dx/platform/android/CCGL.h +++ b/cocos2dx/platform/android/CCGL.h @@ -41,7 +41,7 @@ THE SOFTWARE. // normal process #include #include -// gl2.h don't define GLchar on Android +// gl2.h doesn't define GLchar on Android typedef char GLchar; //declare here while define in CCEGLView_android.cpp diff --git a/cocos2dx/platform/android/CCImage.cpp b/cocos2dx/platform/android/CCImage.cpp index 7c585947f7..8518543d2e 100644 --- a/cocos2dx/platform/android/CCImage.cpp +++ b/cocos2dx/platform/android/CCImage.cpp @@ -69,7 +69,7 @@ public: * this method call Cococs2dx.createBitmap()(java code) to create the bitmap, the java code * will call Java_org_cocos2dx_lib_Cocos2dxBitmap_nativeInitBitmapDC() to init the width, height * and data. - * use this appoach to decrease the jni call number + * use this approach to decrease the jni call number */ jstring jstrText = methodInfo.env->NewStringUTF(text); jstring jstrFont = methodInfo.env->NewStringUTF(pFontName); diff --git a/cocos2dx/platform/ios/CCDirectorCaller.mm b/cocos2dx/platform/ios/CCDirectorCaller.mm index 0852f8fb0a..b39373449e 100644 --- a/cocos2dx/platform/ios/CCDirectorCaller.mm +++ b/cocos2dx/platform/ios/CCDirectorCaller.mm @@ -66,7 +66,7 @@ static id s_sharedDirectorCaller; -(void) startMainLoop { - // CCDirector::setAnimationInterval() is called, we should invalide it first + // CCDirector::setAnimationInterval() is called, we should invalidate it first [displayLink invalidate]; displayLink = nil; @@ -77,7 +77,7 @@ static id s_sharedDirectorCaller; -(void) setAnimationInterval:(double)intervalNew { - // CCDirector::setAnimationInterval() is called, we should invalide it first + // CCDirector::setAnimationInterval() is called, we should invalidate it first [displayLink invalidate]; displayLink = nil; diff --git a/cocos2dx/platform/ios/CCFileUtils.mm b/cocos2dx/platform/ios/CCFileUtils.mm index 68a9ad64fd..5f5c62ac2a 100644 --- a/cocos2dx/platform/ios/CCFileUtils.mm +++ b/cocos2dx/platform/ios/CCFileUtils.mm @@ -264,7 +264,7 @@ CCArray* ccFileUtils_arrayWithContentsOfFileThreadSafe(const char* pFileName) unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize) { unsigned char * pBuffer = NULL; - CCAssert(pszFileName != NULL && pSize != NULL && pszMode != NULL, "Invaild parameters."); + CCAssert(pszFileName != NULL && pSize != NULL && pszMode != NULL, "Invalid parameters."); *pSize = 0; do { diff --git a/cocos2dx/platform/ios/CCImage.mm b/cocos2dx/platform/ios/CCImage.mm index 34cfbc4940..fd80592627 100644 --- a/cocos2dx/platform/ios/CCImage.mm +++ b/cocos2dx/platform/ios/CCImage.mm @@ -437,7 +437,7 @@ bool CCImage::_initWithRawData(void *pData, int nDatalen, int nWidth, int nHeigh m_nWidth = (short)nWidth; m_bHasAlpha = true; - // only RGBA8888 surported + // only RGBA8888 supported int nBytesPerComponent = 4; int nSize = nHeight * nWidth * nBytesPerComponent; m_pData = new unsigned char[nSize]; diff --git a/cocos2dx/platform/ios/EAGLView.mm b/cocos2dx/platform/ios/EAGLView.mm index 04b27fa72e..2f9ba0a360 100755 --- a/cocos2dx/platform/ios/EAGLView.mm +++ b/cocos2dx/platform/ios/EAGLView.mm @@ -577,7 +577,7 @@ static EAGLView *view = 0; /* If text can be selected, it can be marked. Marked text represents provisionally * inserted text that has yet to be confirmed by the user. It requires unique visual * treatment in its display. If there is any marked text, the selection, whether a - * caret or an extended range, always resides witihin. + * caret or an extended range, always resides within. * * Setting marked text either replaces the existing marked text or, if none is present, * inserts it from the current selection. */ diff --git a/cocos2dx/platform/ios/FontLabel/ZAttributedString.m b/cocos2dx/platform/ios/FontLabel/ZAttributedString.m index 20db287c55..485695f078 100644 --- a/cocos2dx/platform/ios/FontLabel/ZAttributedString.m +++ b/cocos2dx/platform/ios/FontLabel/ZAttributedString.m @@ -113,7 +113,7 @@ - (ZAttributedString *)attributedSubstringFromRange:(NSRange)aRange { if (NSMaxRange(aRange) > [_buffer length]) { - @throw [NSException exceptionWithName:NSRangeException reason:@"range was outisde of the attributed string" userInfo:nil]; + @throw [NSException exceptionWithName:NSRangeException reason:@"range was outside of the attributed string" userInfo:nil]; } ZMutableAttributedString *newStr = [self mutableCopy]; if (aRange.location > 0) { diff --git a/cocos2dx/platform/ios/Simulation/AccelerometerSimulation.h b/cocos2dx/platform/ios/Simulation/AccelerometerSimulation.h index 47297c39a1..6a96cfe944 100644 --- a/cocos2dx/platform/ios/Simulation/AccelerometerSimulation.h +++ b/cocos2dx/platform/ios/Simulation/AccelerometerSimulation.h @@ -24,7 +24,7 @@ @end -// override UIAccelerometer behaviour +// override UIAccelerometer behavior @interface UIAccelerometer (Simulation) + (UIAccelerometer *)sharedAccelerometer; @end diff --git a/cocos2dx/platform/ios/Simulation/AccelerometerSimulation.m b/cocos2dx/platform/ios/Simulation/AccelerometerSimulation.m index 2ff94fa02e..ce50529583 100644 --- a/cocos2dx/platform/ios/Simulation/AccelerometerSimulation.m +++ b/cocos2dx/platform/ios/Simulation/AccelerometerSimulation.m @@ -167,7 +167,7 @@ static AccelerometerSimulation *sharedAccelerometer = NULL; accObject = [UIAccelerationSimulation alloc]; isExiting = false; - // couldn't get the CFSocket version to work with UDP and runloop, so used Berkely sockets and a thread instead + // couldn't get the CFSocket version to work with UDP and runloop, so used Berkeley sockets and a thread instead udpSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); struct sockaddr_in sin; From 6816fb94fc9ef051012991a8d7da370044449b20 Mon Sep 17 00:00:00 2001 From: Donald Alan Morrison Date: Sat, 15 Sep 2012 15:12:28 -0700 Subject: [PATCH 022/181] A few more minor documentation changes. OK, enough for today! :-) --- cocos2dx/CCScheduler.h | 2 +- cocos2dx/actions/CCAction.h | 2 +- cocos2dx/actions/CCActionCatmullRom.cpp | 32 ++++++++++++------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cocos2dx/CCScheduler.h b/cocos2dx/CCScheduler.h index d342ca65e3..af3ed28958 100644 --- a/cocos2dx/CCScheduler.h +++ b/cocos2dx/CCScheduler.h @@ -142,7 +142,7 @@ public: /** The scheduled method will be called every 'interval' seconds. If paused is YES, then it won't be called until it is resumed. - If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead. + If 'interval' is 0, it will be called every frame, but if so, it's recommended to use 'scheduleUpdateForTarget:' instead. If the selector is already scheduled, then only the interval parameter will be updated without re-scheduling it again. repeat let the action be repeated repeat + 1 times, use kCCRepeatForever to let the action run continuously delay is the amount of time the action will wait before it'll start diff --git a/cocos2dx/actions/CCAction.h b/cocos2dx/actions/CCAction.h index 1e897146f3..3f9375a1c6 100644 --- a/cocos2dx/actions/CCAction.h +++ b/cocos2dx/actions/CCAction.h @@ -234,7 +234,7 @@ public: public: /** creates the action with a set boundary, It will work with no boundary if @param rect is equal to CCRectZero. - @deprecated: Please use create(CCNode*, const CCRect&) intead. This interface will be deprecated sooner or later. + @deprecated: Please use create(CCNode*, const CCRect&) instead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFollow* actionWithTarget(CCNode *pFollowedNode, const CCRect& rect = CCRectZero); /** creates the action with a set boundary, diff --git a/cocos2dx/actions/CCActionCatmullRom.cpp b/cocos2dx/actions/CCActionCatmullRom.cpp index 632cd160a6..6c06f8be59 100644 --- a/cocos2dx/actions/CCActionCatmullRom.cpp +++ b/cocos2dx/actions/CCActionCatmullRom.cpp @@ -26,7 +26,7 @@ * THE SOFTWARE. * * - * Orignal code by Radu Gruian: http://www.codeproject.com/Articles/30838/Overhauser-Catmull-Rom-Splines-for-Camera-Animatio.So + * Original code by Radu Gruian: http://www.codeproject.com/Articles/30838/Overhauser-Catmull-Rom-Splines-for-Camera-Animatio.So * * Adapted to cocos2d-x by Vit Valentin * @@ -96,12 +96,12 @@ CCPointArray::CCPointArray() :m_pControlPoints(NULL){} void CCPointArray::addControlPoint(CCPoint controlPoint) { - // should create a new object of CCPoint - // because developer always use this function like this + // should create a new object: CCPoint + // because developers are accustomed to using // addControlPoint(ccp(x, y)) - // passing controlPoint is a temple object - // and CCArray::addObject() will retain the passing object, so it - // should be an object created in heap + // which assumes controlPoint is a temporary struct + // but CCArray::addObject() will retain the passed object, so temp + // should be an object created in the heap. CCPoint *temp = new CCPoint(controlPoint.x, controlPoint.y); m_pControlPoints->addObject(temp); temp->release(); @@ -109,12 +109,12 @@ void CCPointArray::addControlPoint(CCPoint controlPoint) void CCPointArray::insertControlPoint(CCPoint &controlPoint, unsigned int index) { - // should create a new object of CCPoint - // because developer always use this function like this + // should create a new object: CCPoint + // because developers are accustomed to using // insertControlPoint(ccp(x, y)) - // passing controlPoint is a temple object - // and CCArray::insertObject() will retain the passing object, so it - // should be an object created in heap + // which assumes controlPoint is a temporary struct + // but CCArray::insertObject() will retain the passed object, so temp + // should be an object created in the heap. CCPoint *temp = new CCPoint(controlPoint.x, controlPoint.y); m_pControlPoints->insertObject(temp, index); temp->release(); @@ -130,12 +130,12 @@ CCPoint CCPointArray::getControlPointAtIndex(unsigned int index) void CCPointArray::replaceControlPoint(cocos2d::CCPoint &controlPoint, unsigned int index) { - // should create a new object of CCPoint - // because developer always use this function like this + // should create a new object: CCPoint + // because developers are accustomed to using // replaceControlPoint(ccp(x, y)) - // passing controlPoint is a temple object - // and CCArray::insertObject() will retain the passing object, so it - // should be an object created in heap + // which assumes controlPoint is a temporary struct + // but CCArray::insertObject() will retain the passed object, so temp + // should be an object created in the heap. CCPoint *temp = new CCPoint(controlPoint.x, controlPoint.y); m_pControlPoints->replaceObjectAtIndex(index, temp); temp->release(); From 53e4da5d5c8cbc85cfdf332e814409d5ab03d8ae Mon Sep 17 00:00:00 2001 From: Nat Weiss Date: Sat, 15 Sep 2012 15:59:15 -0700 Subject: [PATCH 023/181] Fixes a bug in the TMX parser which caused tileset images not to load on Android. --- cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp index 41a43e057d..ada929a961 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp @@ -453,7 +453,7 @@ void CCTMXMapInfo::startElement(void *ctx, const char *name, const char **atts) } else { - tileset->m_sSourceImage = m_sResources + "/" + imagename; + tileset->m_sSourceImage = m_sResources + (m_sResources.size() ? "/" : "") + imagename; } } else if(elementName == "data") From b8fad67ef43990350f24a4d1d203e0749812251f Mon Sep 17 00:00:00 2001 From: Walzer Date: Sun, 16 Sep 2012 10:18:06 +0800 Subject: [PATCH 024/181] Fix English syntax in CCDrawingPrimitives.cpp --- cocos2dx/CCDrawingPrimitives.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/CCDrawingPrimitives.cpp b/cocos2dx/CCDrawingPrimitives.cpp index b51bb83d3e..0053868c44 100644 --- a/cocos2dx/CCDrawingPrimitives.cpp +++ b/cocos2dx/CCDrawingPrimitives.cpp @@ -67,7 +67,7 @@ static void lazy_init( void ) } } -// When back to foreground on android, we want to it to initialize again +// When switching from backround to foreground on android, we want the params to be initialized again void ccDrawInit() { s_bInitialized = false; From c1ab4eab4872f4c0321a58632c700be361bafbd5 Mon Sep 17 00:00:00 2001 From: Walzer Date: Sun, 16 Sep 2012 16:13:54 +0800 Subject: [PATCH 025/181] fixed #1404, modify "ant release" to "ant debug" in mac-android-4.x-debug.sh --- .../jenkins_scripts/mac/android/build-android-4.x-debug.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/jenkins_scripts/mac/android/build-android-4.x-debug.sh b/tools/jenkins_scripts/mac/android/build-android-4.x-debug.sh index 6cd7f43bbf..525ef60562 100755 --- a/tools/jenkins_scripts/mac/android/build-android-4.x-debug.sh +++ b/tools/jenkins_scripts/mac/android/build-android-4.x-debug.sh @@ -10,7 +10,7 @@ antcompile() sed '/target=/s/=.*$/=android-14/' ant.properties > anttmp.properties cp anttmp.properties ant.properties rm anttmp.properties - ant release + ant debug compileresult=$[$compileresult+$?] if [ $IsTestCpp == 1 ] && [ $? == 0 ] then @@ -23,7 +23,7 @@ antcompile() sed '/target=/s/=.*$/=android-15/' ant.properties > anttmp.properties cp anttmp.properties ant.properties rm anttmp.properties - ant release + ant debug compileresult=$[$compileresult+$?] if [ $IsTestCpp == 1 ] && [ $? == 0 ] then @@ -93,4 +93,4 @@ else # git checkout -f # git clean -df -x exit 0 -fi \ No newline at end of file +fi From f475bcf10243f2580cccd9bef110398396cf1883 Mon Sep 17 00:00:00 2001 From: Walzer Date: Sun, 16 Sep 2012 16:21:42 +0800 Subject: [PATCH 026/181] CCString::stringWithContentsOfFile should call CCString::createWithContentsOfFile, but not CCString::create --- cocos2dx/cocoa/CCString.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/cocoa/CCString.cpp b/cocos2dx/cocoa/CCString.cpp index f522d11eec..f6ea6d8390 100644 --- a/cocos2dx/cocoa/CCString.cpp +++ b/cocos2dx/cocoa/CCString.cpp @@ -219,7 +219,7 @@ CCString* CCString::createWithFormat(const char* format, ...) CCString* CCString::stringWithContentsOfFile(const char* pszFileName) { - return CCString::create(pszFileName); + return CCString::createWithContentsOfFile(pszFileName); } CCString* CCString::createWithContentsOfFile(const char* pszFileName) From 44ccc40269c9d580da39263e2ef455f69d9418f4 Mon Sep 17 00:00:00 2001 From: Andre Rudlaff Date: Tue, 18 Sep 2012 00:48:52 +0200 Subject: [PATCH 027/181] [linux] use fontconfig to select system fonts This patch removes the hardcoded font paths from the linux project and uses fontconfig to find the best match for a given font-family The implementation also adds the possibility to load a font file from the applications resource directory --- cocos2dx/platform/linux/CCImage.cpp | 78 +++++++++++++++-------------- cocos2dx/proj.linux/.cproject | 1 + 2 files changed, 42 insertions(+), 37 deletions(-) diff --git a/cocos2dx/platform/linux/CCImage.cpp b/cocos2dx/platform/linux/CCImage.cpp index e9ea9daa2e..3b2493a2b3 100644 --- a/cocos2dx/platform/linux/CCImage.cpp +++ b/cocos2dx/platform/linux/CCImage.cpp @@ -3,12 +3,14 @@ #include #include #include +#include #include "platform/CCFileUtils.h" #include "platform/CCPlatformMacros.h" #define __CC_PLATFORM_IMAGE_CPP__ #include "platform/CCImageCommon_cpp.h" #include "platform/CCImage.h" +#include "platform/linux/CCApplication.h" #include "ft2build.h" #include "CCStdC.h" @@ -26,27 +28,13 @@ struct TextLine { wchar_t* text; }; -struct FontTableItem { - char* family_name; - char* style_name; - char* filename; -}; - -const int fontTableItems = 4; -const char* fontPath = "/usr/share/fonts/truetype/"; -FontTableItem fontsTable[fontTableItems] = { - { "Serif", "Medium", "freefont/FreeSerif.ttf" }, - { "Sans", "Medium", "freefont/FreeSans.ttf" }, - { "WenQuanYi Micro Hei", "Regular", "wqy/wqy-microhei.ttc" }, - { "WenQuanYi Zen Hei", "Regular", "wqy/wqy-zenhei.ttc" }, -}; - NS_CC_BEGIN class BitmapDC { public: BitmapDC() { libError = FT_Init_FreeType( &library ); + FcInit(); iInterval = szFont_kenning; m_pData = NULL; reset(); @@ -54,6 +42,7 @@ public: ~BitmapDC() { FT_Done_FreeType(library); + FcFini(); //data will be deleted by CCImage // if (m_pData) { // delete m_pData; @@ -238,27 +227,42 @@ public: return iRet; } - char* getFontFile(const char* family_name) { - char* ret = NULL; - for (int i=0; ifamily_name, family_name) == 0) { - size_t len = strlen(fontPath) + strlen(item->filename) + 1; - ret = (char*) malloc(len); - snprintf(ret, len, "%s%s", fontPath, item->filename); - break; - } - } + std::string getFontFile(const char* family_name) { + std::string fontPath = family_name; - // Return a default font , if font is not found - if (ret == NULL) { - FontTableItem* item = &fontsTable[0]; - size_t len = strlen(fontPath) + strlen(item->filename) + 1; - ret = (char*) malloc(len); - snprintf(ret, len, "%s%s", fontPath, item->filename); - } + // check if the parameter is a font file shipped with the application + if ( fontPath.find(".ttf") != std::string::npos ) { + fontPath = cocos2d::CCApplication::sharedApplication()->getResourceRootPath() + std::string("/") + fontPath; - return ret; + FILE *f = fopen(fontPath.c_str(), "r"); + if ( f ) { + fclose(f); + return fontPath; + } + } + + // use fontconfig to match the parameter against the fonts installed on the system + FcPattern *pattern = FcPatternBuild (0, FC_FAMILY, FcTypeString, family_name, (char *) 0); + FcConfigSubstitute(0, pattern, FcMatchPattern); + FcDefaultSubstitute(pattern); + + FcResult result; + FcPattern *font = FcFontMatch(0, pattern, &result); + if ( font ) { + FcChar8 *s = NULL; + if ( FcPatternGetString(font, FC_FILE, 0, &s) == FcResultMatch ) { + fontPath = (const char*)s; + + FcPatternDestroy(font); + FcPatternDestroy(pattern); + + return fontPath; + } + FcPatternDestroy(font); + } + FcPatternDestroy(pattern); + + return family_name; } bool getBitmap(const char *text, int nWidth, int nHeight, CCImage::ETextAlign eAlignMask, const char * pFontName, float fontSize) { @@ -276,9 +280,8 @@ public: return false; } do { - char* fontfile = getFontFile(pFontName); - iError = FT_New_Face( library, fontfile, 0, &face ); - free(fontfile); + std::string fontfile = getFontFile(pFontName); + iError = FT_New_Face( library, fontfile.c_str(), 0, &face ); if (iError) { //no valid font found use default @@ -393,6 +396,7 @@ public: } public: FT_Library library; + unsigned char *m_pData; int libError; vector vLines; diff --git a/cocos2dx/proj.linux/.cproject b/cocos2dx/proj.linux/.cproject index 363e1e83eb..15fc52aa60 100755 --- a/cocos2dx/proj.linux/.cproject +++ b/cocos2dx/proj.linux/.cproject @@ -79,6 +79,7 @@ From 394b64d61f5865b3d209de6d8b0f75efc89f44e1 Mon Sep 17 00:00:00 2001 From: Andre Rudlaff Date: Mon, 17 Sep 2012 02:31:05 +0200 Subject: [PATCH 028/181] [linux] fixed font rendering artifacts This patch fixes the black pixels around fonts when rendered using CCLabelTTF. see http://www.cocos2d-x.org/issues/706 This fix is for linux only, but may be applied to other platforms as well --- cocos2dx/platform/linux/CCImage.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cocos2dx/platform/linux/CCImage.cpp b/cocos2dx/platform/linux/CCImage.cpp index 3b2493a2b3..3c43180b6e 100644 --- a/cocos2dx/platform/linux/CCImage.cpp +++ b/cocos2dx/platform/linux/CCImage.cpp @@ -359,9 +359,7 @@ public: // m_pData[(iY * iMaxLineWidth + iX) * 4 + 0] = // bitmap.buffer[i * bitmap.width + j];//B - int iTemp = 0; - iTemp |= (cTemp ? 0xff : 0)<<24; - iTemp |= cTemp << 16 | cTemp << 8 | cTemp; + int iTemp = cTemp << 24 | cTemp << 16 | cTemp << 8 | cTemp; *(int*) &m_pData[(iY * iMaxLineWidth + iX) * 4 + 0] = iTemp; } } From 0845e08fd3953f73315291e0f798ba4630644620 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 17 Sep 2012 14:27:17 +0800 Subject: [PATCH 029/181] issue #1470:update CCBReader to support Cocosbuilder v2.1 beta0 --- extensions/CCBReader/CCBAnimationManager.cpp | 674 ++++++++++++++++++ extensions/CCBReader/CCBAnimationManager.h | 109 +++ extensions/CCBReader/CCBFileLoader.cpp | 2 +- extensions/CCBReader/CCBFileLoader.h | 3 +- extensions/CCBReader/CCBKeyframe.cpp | 61 ++ extensions/CCBReader/CCBKeyframe.h | 36 + extensions/CCBReader/CCBReader.cpp | 525 +++++++++++--- extensions/CCBReader/CCBReader.h | 304 +++++--- extensions/CCBReader/CCBSequence.cpp | 56 ++ extensions/CCBReader/CCBSequence.h | 37 + extensions/CCBReader/CCBSequenceProperty.cpp | 52 ++ extensions/CCBReader/CCBSequenceProperty.h | 34 + extensions/CCBReader/CCBValue.cpp | 132 ++++ extensions/CCBReader/CCBValue.h | 61 ++ .../CCBReader/CCControlButtonLoader.cpp | 10 +- extensions/CCBReader/CCData.cpp | 27 + extensions/CCBReader/CCData.h | 26 + .../CCNode+CCBRelativePositioning.cpp | 62 ++ .../CCBReader/CCNode+CCBRelativePositioning.h | 15 + extensions/CCBReader/CCNodeLoader.cpp | 420 ++++++++--- extensions/CCBReader/CCNodeLoader.h | 14 +- .../CocosBuilderTest/CocosBuilderTest.cpp | 5 +- .../HelloCocosBuilderLayer.cpp | 20 +- .../HelloCocosBuilderLayer.h | 6 +- .../Resources/ccb/burst-hd.png.REMOVED.git-id | 1 + .../ccb/burst-ipad.png.REMOVED.git-id | 1 + .../pub/res => }/flower.jpg.REMOVED.git-id | 0 .../markerfelt24shadow.fnt.REMOVED.git-id | 0 .../src/res/flower.jpg.REMOVED.git-id | 1 - .../res/markerfelt24shadow.fnt.REMOVED.git-id | 1 - .../simple/pub/fonts/Droid.ttf.REMOVED.git-id | 1 - .../simple/src/fonts/Droid.ttf.REMOVED.git-id | 1 - .../project.pbxproj.REMOVED.git-id | 2 +- 33 files changed, 2351 insertions(+), 348 deletions(-) create mode 100644 extensions/CCBReader/CCBAnimationManager.cpp create mode 100644 extensions/CCBReader/CCBAnimationManager.h create mode 100644 extensions/CCBReader/CCBKeyframe.cpp create mode 100644 extensions/CCBReader/CCBKeyframe.h create mode 100644 extensions/CCBReader/CCBSequence.cpp create mode 100644 extensions/CCBReader/CCBSequence.h create mode 100644 extensions/CCBReader/CCBSequenceProperty.cpp create mode 100644 extensions/CCBReader/CCBSequenceProperty.h create mode 100644 extensions/CCBReader/CCBValue.cpp create mode 100644 extensions/CCBReader/CCBValue.h create mode 100644 extensions/CCBReader/CCData.cpp create mode 100644 extensions/CCBReader/CCData.h create mode 100644 extensions/CCBReader/CCNode+CCBRelativePositioning.cpp create mode 100644 extensions/CCBReader/CCNode+CCBRelativePositioning.h create mode 100644 samples/TestCpp/Resources/ccb/burst-hd.png.REMOVED.git-id create mode 100644 samples/TestCpp/Resources/ccb/burst-ipad.png.REMOVED.git-id rename samples/TestCpp/Resources/ccb/{official/pub/res => }/flower.jpg.REMOVED.git-id (100%) rename samples/TestCpp/Resources/ccb/{official/pub/res => }/markerfelt24shadow.fnt.REMOVED.git-id (100%) delete mode 100644 samples/TestCpp/Resources/ccb/official/src/res/flower.jpg.REMOVED.git-id delete mode 100644 samples/TestCpp/Resources/ccb/official/src/res/markerfelt24shadow.fnt.REMOVED.git-id delete mode 100644 samples/TestCpp/Resources/ccb/simple/pub/fonts/Droid.ttf.REMOVED.git-id delete mode 100644 samples/TestCpp/Resources/ccb/simple/src/fonts/Droid.ttf.REMOVED.git-id diff --git a/extensions/CCBReader/CCBAnimationManager.cpp b/extensions/CCBReader/CCBAnimationManager.cpp new file mode 100644 index 0000000000..66624b80d6 --- /dev/null +++ b/extensions/CCBReader/CCBAnimationManager.cpp @@ -0,0 +1,674 @@ +#include "CCBAnimationManager.h" +#include "CCBSequence.h" +#include "CCBSequenceProperty.h" +#include "CCBReader.h" +#include "CCBKeyframe.h" +#include "CCNode+CCBRelativePositioning.h" +#include +#include + +using namespace cocos2d; +using namespace std; + +NS_CC_EXT_BEGIN + +// Implementation of CCBAinmationManager + +CCBAnimationManager::CCBAnimationManager() +: mSequences(NULL) +, mNodeSequences(NULL) +, mBaseValues(NULL) +, mAutoPlaySequenceId(0) +, mRootNode(NULL) +, mRootContainerSize(CCSizeZero) +, mDelegate(NULL) +, mRunningSequence(NULL) +{ + init(); +} + +bool CCBAnimationManager::init() +{ + mSequences = new CCArray(); + mNodeSequences = new CCDictionary(); + mBaseValues = new CCDictionary(); + + return true; +} + +CCBAnimationManager::~CCBAnimationManager() +{ + CCDictElement *pElement = NULL; + CCDICT_FOREACH(mNodeSequences, pElement) + { + CCNode *node = (CCNode*)pElement->getIntKey(); + node->release(); + } + + CCDICT_FOREACH(mBaseValues, pElement) + { + CCNode *node = (CCNode*)pElement->getIntKey(); + node->release(); + } + + mNodeSequences->release(); + mBaseValues->release(); + mSequences->release(); + setRootNode(NULL); + setDelegate(NULL); +} + +CCArray* CCBAnimationManager::getSequences() +{ + return mSequences; +} + +int CCBAnimationManager::getAutoPlaySequenceId() +{ + return mAutoPlaySequenceId; +} + +void CCBAnimationManager::setAutoPlaySequenceId(int autoPlaySequenceId) +{ + mAutoPlaySequenceId = autoPlaySequenceId; +} + +CCNode* CCBAnimationManager::getRootNode() +{ + return mRootNode; +} + +void CCBAnimationManager::setRootNode(CCNode *pRootNode) +{ + CC_SAFE_RELEASE(mRootNode); + mRootNode = pRootNode; + CC_SAFE_RETAIN(mRootNode); +} + +const CCSize& CCBAnimationManager::getRootContainerSize() +{ + return mRootContainerSize; +} + +void CCBAnimationManager::setRootContainerSize(const CCSize &rootContainerSize) +{ + mRootContainerSize.setSize(rootContainerSize.width, rootContainerSize.height); +} + +CCBAnimationManagerDelegate* CCBAnimationManager::getDelegate() +{ + return mDelegate; +} + +void CCBAnimationManager::setDelegate(CCBAnimationManagerDelegate *pDelegate) +{ + CC_SAFE_RELEASE(dynamic_cast(mDelegate)); + mDelegate = pDelegate; + CC_SAFE_RETAIN(dynamic_cast(mDelegate)); +} + +const char* CCBAnimationManager::getRunningSequenceName() +{ + return mRunningSequence->getName(); +} + +const CCSize& CCBAnimationManager::getContainerSize(CCNode *pNode) +{ + if (pNode) + { + return pNode->getContentSize(); + } + else + { + return mRootContainerSize; + } +} + +// refer to CCBReader::readNodeGraph() for data structure of pSeq +void CCBAnimationManager::addNode(CCNode *pNode, CCDictionary *pSeq) +{ + pNode->retain(); + + mNodeSequences->setObject(pSeq, (int)pNode); +} + +void CCBAnimationManager::setBaseValue(CCObject *pValue, CCNode *pNode, const char *pPropName) +{ + CCDictionary *props = (CCDictionary*)mBaseValues->objectForKey((int)pNode); + if (! props) + { + props = CCDictionary::create(); + mBaseValues->setObject(props, (int)pNode); + pNode->retain(); + } + + props->setObject(pValue, pPropName); +} + +CCObject* CCBAnimationManager::getBaseValue(CCNode *pNode, const char* pPropName) +{ + CCDictionary *props = (CCDictionary*)mBaseValues->objectForKey((int)pNode); + + return props->objectForKey(pPropName); +} + +int CCBAnimationManager::getSequenceId(const char* pSequenceName) +{ + CCObject *pElement = NULL; + string seqName(pSequenceName); + CCARRAY_FOREACH(mSequences, pElement) + { + CCBSequence *seq = (CCBSequence*)pElement; + if (seqName.compare(seq->getName()) == 0) + { + return seq->getSequenceId(); + } + } + return -1; +} + +CCBSequence* CCBAnimationManager::getSequence(int nSequenceId) +{ + CCObject *pElement = NULL; + CCARRAY_FOREACH(mSequences, pElement) + { + CCBSequence *seq = (CCBSequence*)pElement; + if (seq->getSequenceId() == nSequenceId) + { + return seq; + } + } + return NULL; +} + +// Refer to CCBReader::readKeyframe() for the real type of value +CCActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const char *pPropName, CCNode *pNode) +{ + float duration = pKeyframe1->getTime() - pKeyframe0->getTime(); + + if (strcmp(pPropName, "rotation") == 0) + { + CCBValue *value = (CCBValue*)pKeyframe1->getValue(); + return CCBRotateTo::create(duration, value->getFloatValue()); + } + else if (strcmp(pPropName, "opacity") == 0) + { + CCBValue *value = (CCBValue*)pKeyframe1->getValue(); + return CCFadeTo::create(duration, value->getByteValue()); + } + else if (strcmp(pPropName, "color") == 0) + { + ccColor3BWapper* color = (ccColor3BWapper*)pKeyframe1->getValue(); + ccColor3B c = color->getColor(); + + return CCTintTo::create(duration, c.r, c.g, c.b); + } + else if (strcmp(pPropName, "visible") == 0) + { + CCBValue *value = (CCBValue*)pKeyframe1->getValue(); + if (value->getBoolValue()) + { + return CCSequence::createWithTwoActions(CCDelayTime::create(duration), CCShow::create()); + } + else + { + return CCSequence::createWithTwoActions(CCDelayTime::create(duration), CCHide::create()); + } + } + else if (strcmp(pPropName, "displayFrame") == 0) + { + return CCSequence::createWithTwoActions(CCDelayTime::create(duration), + CCBSetSpriteFrame::create((CCSpriteFrame *)pKeyframe1->getValue())); + } + else if (strcmp(pPropName, "position") == 0) + { + // Get position type + CCArray *array = (CCArray*)getBaseValue(pNode, pPropName); + int type = ((CCBValue*)array->objectAtIndex(2))->getIntValue(); + + // Get relative position + CCArray *value = (CCArray*)pKeyframe1->getValue(); + float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue(); + float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue(); + + CCSize containerSize = getContainerSize(pNode->getParent()); + + CCPoint absPos = getAbsolutePosition(ccp(x,y), type, containerSize, pPropName); + + return CCMoveTo::create(duration, absPos); + } + else if (strcmp(pPropName, "scale") == 0) + { + // Get position type + CCArray *array = (CCArray*)getBaseValue(pNode, pPropName); + int type = ((CCBValue*)array->objectAtIndex(2))->getIntValue(); + + // Get relative scale + CCArray *value = (CCArray*)pKeyframe1->getValue(); + float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue(); + float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue(); + + if (type == kCCBScaleTypeMultiplyResolution) + { + float resolutionScale = CCBReader::getResolutionScale(); + x *= resolutionScale; + y *= resolutionScale; + } + + return CCScaleTo::create(duration, x, y); + } + else + { + CCLog("CCBReader: Failed to create animation for property: %s", pPropName); + } + + return NULL; +} + +void CCBAnimationManager::setAnimatedProperty(const char *pPropName, CCNode *pNode, CCObject *pValue, float fTweenDuraion) +{ + if (fTweenDuraion > 0) + { + // Create a fake keyframe to generate the action from + CCBKeyframe *kf1 = new CCBKeyframe(); + kf1->autorelease(); + kf1->setValue(pValue); + kf1->setTime(fTweenDuraion); + kf1->setEasingType(kCCBKeyframeEasingLinear); + + // Animate + CCActionInterval *tweenAction = getAction(NULL, kf1, pPropName, pNode); + pNode->runAction(tweenAction); + } + else + { + // Just set the value + + if (strcmp(pPropName, "position") == 0) + { + // Get position type + CCArray *array = (CCArray*)getBaseValue(pNode, pPropName); + int type = ((CCBValue*)array->objectAtIndex(2))->getIntValue(); + + // Get relative position + CCArray *value = (CCArray*)pValue; + float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue(); + float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue(); + + pNode->setPosition(getAbsolutePosition(ccp(x,y), type, getContainerSize(pNode->getParent()), pPropName)); + } + else if (strcmp(pPropName, "scale") == 0) + { + // Get position type + CCArray *array = (CCArray*)getBaseValue(pNode, pPropName); + int type = ((CCBValue*)array->objectAtIndex(2))->getIntValue(); + + // Get relative scale + CCArray *value = (CCArray*)pValue; + float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue(); + float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue(); + + setRelativeScale(pNode, x, y, type, pPropName); + } + else + { + // [node setValue:value forKey:name]; + + // TODO only handle rotation, opacity, + if (strcmp(pPropName, "rotation") == 0) + { + float rotate = ((CCBValue*)pValue)->getFloatValue(); + pNode->setRotation(rotate); + } + else if (strcmp(pPropName, "opacity") == 0) + { + int opacity = ((CCBValue*)pValue)->getByteValue(); + (dynamic_cast(pNode))->setOpacity(opacity); + } + else + { + CCAssert(false, "unsupported property now"); + } + } + } +} + +void CCBAnimationManager::setFirstFrame(CCNode *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration) +{ + CCArray *keyframes = pSeqProp->getKeyframes(); + + if (keyframes->count() == 0) + { + // Use base value (no animation) + CCObject *baseValue = getBaseValue(pNode, pSeqProp->getName()); + CCAssert(baseValue, "No baseValue found for property"); + setAnimatedProperty(pSeqProp->getName(), pNode, baseValue, fTweenDuration); + } + else + { + // Use first keyframe + CCBKeyframe *keyframe = (CCBKeyframe*)keyframes->objectAtIndex(0); + setAnimatedProperty(pSeqProp->getName(), pNode, keyframe->getValue(), fTweenDuration); + } +} + +CCActionInterval* CCBAnimationManager::getEaseAction(CCActionInterval *pAction, int nEasingType, float fEasingOpt) +{ + if (nEasingType == kCCBKeyframeEasingLinear || nEasingType == kCCBKeyframeEasingInstant) + { + return pAction; + } + else if (nEasingType == kCCBKeyframeEasingCubicIn) + { + return CCEaseIn::create(pAction, fEasingOpt); + } + else if (nEasingType == kCCBKeyframeEasingCubicOut) + { + return CCEaseInOut::create(pAction, fEasingOpt); + } + else if (nEasingType == kCCBKeyframeEasingCubicInOut) + { + return CCEaseInOut::create(pAction, fEasingOpt); + } + else if (nEasingType == kCCBKeyframeEasingBackIn) + { + return CCEaseBackIn::create(pAction); + } + else if (nEasingType == kCCBKeyframeEasingBackOut) + { + return CCEaseBackOut::create(pAction); + } + else if (nEasingType == kCCBKeyframeEasingBackInOut) + { + return CCEaseBackInOut::create(pAction); + } + else if (nEasingType == kCCBKeyframeEasingBounceIn) + { + return CCEaseBounceIn::create(pAction); + } + else if (nEasingType == kCCBKeyframeEasingBounceOut) + { + return CCEaseBackOut::create(pAction); + } + else if (nEasingType == kCCBKeyframeEasingBounceInOut) + { + return CCEaseBackInOut::create(pAction); + } + else if (nEasingType == kCCBKeyframeEasingElasticIn) + { + return CCEaseElasticIn::create(pAction, fEasingOpt); + } + else if (nEasingType == kCCBKeyframeEasingElasticOut) + { + return CCEaseElasticOut::create(pAction, fEasingOpt); + } + else if (nEasingType == kCCBKeyframeEasingElasticInOut) + { + return CCEaseElasticInOut::create(pAction, fEasingOpt); + } + else + { + CCLog("CCBReader: Unkown easing type %d", nEasingType); + return pAction; + } +} + +void CCBAnimationManager::runAction(CCNode *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration) +{ + CCArray *keyframes = pSeqProp->getKeyframes(); + int numKeyframes = keyframes->count(); + + if (numKeyframes > 1) + { + // Make an animation! + CCArray *actions = CCArray::create(); + + CCBKeyframe *keyframeFirst = (CCBKeyframe*)keyframes->objectAtIndex(0); + float timeFirst = keyframeFirst->getTime() + fTweenDuration; + + if (timeFirst > 0) + { + actions->addObject(CCDelayTime::create(timeFirst)); + } + + for (int i = 0; i < numKeyframes - 1; ++i) + { + CCBKeyframe *kf0 = (CCBKeyframe*)keyframes->objectAtIndex(i); + CCBKeyframe *kf1 = (CCBKeyframe*)keyframes->objectAtIndex(i+1); + + CCActionInterval *action = getAction(kf0, kf1, pSeqProp->getName(), pNode); + if (action) + { + // Apply easing + action = getEaseAction(action, kf0->getEasingType(), kf0->getEasingOpt()); + + actions->addObject(action); + } + } + + CCFiniteTimeAction *seq = CCSequence::create(actions); + pNode->runAction(seq); + } +} + +void CCBAnimationManager::runAnimations(int nSeqId, float fTweenDuration) +{ + CCAssert(nSeqId != -1, "Sequence id couldn't be found"); + + mRootNode->stopAllActions(); + + CCDictElement* pElement = NULL; + CCDICT_FOREACH(mNodeSequences, pElement) + { + CCNode *node = (CCNode*)pElement->getIntKey(); + node->stopAllActions(); + + // Refer to CCBReader::readKeyframe() for the real type of value + CCDictionary *seqs = (CCDictionary*)pElement->getObject(); + CCDictionary *seqNodeProps = (CCDictionary*)seqs->objectForKey(nSeqId); + + set seqNodePropNames; + + if (seqNodeProps) + { + // Reset nodes that have sequence node properties, and run actions on them + CCDictElement* pElement1 = NULL; + CCDICT_FOREACH(seqNodeProps, pElement1) + { + const char *propNmae = pElement1->getStrKey(); + CCBSequenceProperty *seqProp = (CCBSequenceProperty*)seqNodeProps->objectForKey(propNmae); + seqNodePropNames.insert(propNmae); + + setFirstFrame(node, seqProp, fTweenDuration); + runAction(node, seqProp, fTweenDuration); + } + } + + // Reset the nodes that may have been changed by other timelines + CCDictionary *nodeBaseValues = (CCDictionary*)mBaseValues->objectForKey(pElement->getIntKey()); + if (nodeBaseValues) + { + CCDictElement* pElement2 = NULL; + //CCLog("nodeBaseValues get value for key %d", pElement->getIntKey()); + CCDICT_FOREACH(nodeBaseValues, pElement2) + { + if (seqNodePropNames.find(pElement2->getStrKey()) != seqNodePropNames.end()) + { + CCObject *value = pElement2->getObject(); + + if (value) + { + setAnimatedProperty(pElement2->getStrKey(), node, value, fTweenDuration); + } + } + } + } + } + + // Make callback at end of sequence + CCBSequence *seq = getSequence(nSeqId); + CCAction *completeAction = CCSequence::createWithTwoActions(CCDelayTime::create(seq->getDuration() + fTweenDuration), + CCCallFunc::create(this, callfunc_selector(CCBAnimationManager::sequenceCompleted))); + mRootNode->runAction(completeAction); + + // Set the running scene + mRunningSequence = getSequence(nSeqId); +} + +void CCBAnimationManager::runAnimations(const char *pName, float fTweenDuration) +{ + int seqId = getSequenceId(pName); + runAnimations(seqId, fTweenDuration); +} + +void CCBAnimationManager::runAnimations(const char *pName) +{ + runAnimations(pName, 0); +} + +void CCBAnimationManager::debug() +{ + +} + +void CCBAnimationManager::sequenceCompleted() +{ + if (mDelegate) + { + mDelegate->completedAnimationSequenceNamed(mRunningSequence->getName()); + } + + int nextSeqId = mRunningSequence->getChainedSequenceId(); + mRunningSequence = NULL; + + if (nextSeqId != -1) + { + runAnimations(nextSeqId, 0); + } +} + +/************************************************************ + CCBSetSpriteFrame + ************************************************************/ + +CCBSetSpriteFrame* CCBSetSpriteFrame::create(CCSpriteFrame *pSpriteFrame) +{ + CCBSetSpriteFrame *ret = new CCBSetSpriteFrame(); + if (ret) + { + if (ret->initWithSpriteFrame(pSpriteFrame)) + { + ret->autorelease(); + } + else + { + CC_SAFE_DELETE(ret); + } + } + + return ret; +} + +bool CCBSetSpriteFrame::initWithSpriteFrame(CCSpriteFrame *pSpriteFrame) +{ + mSpriteFrame = pSpriteFrame; + CC_SAFE_RETAIN(mSpriteFrame); + + return true; +} + +CCBSetSpriteFrame::~CCBSetSpriteFrame() +{ + CC_SAFE_RELEASE_NULL(mSpriteFrame); +} + +CCObject* CCBSetSpriteFrame::copyWithZone(CCZone *pZone) +{ + CCZone *pNewZone = NULL; + CCBSetSpriteFrame *pRet = NULL; + + if (pZone && pZone->m_pCopyObject) { + pRet = (CCBSetSpriteFrame*) (pZone->m_pCopyObject); + } else { + pRet = new CCBSetSpriteFrame(); + pZone = pNewZone = new CCZone(pRet); + } + + pRet->initWithSpriteFrame(mSpriteFrame); + CCActionInstant::copyWithZone(pZone); + CC_SAFE_DELETE(pNewZone); + return pRet; +} + +void CCBSetSpriteFrame::update(float time) +{ + ((CCSprite*)m_pTarget)->setDisplayFrame(mSpriteFrame); +} + +/************************************************************ + CCBRotateTo + ************************************************************/ + +CCBRotateTo* CCBRotateTo::create(float fDuration, float fAngle) +{ + CCBRotateTo *ret = new CCBRotateTo(); + if (ret) + { + if (ret->initWithDuration(fDuration, fAngle)) + { + ret->autorelease(); + } + else + { + CC_SAFE_DELETE(ret); + } + } + + return ret; +} + +bool CCBRotateTo::initWithDuration(float fDuration, float fAngle) +{ + if (CCActionInterval::initWithDuration(fDuration)) + { + mDstAngle = fAngle; + + return true; + } + else + { + return false; + } +} + +CCObject* CCBRotateTo::copyWithZone(CCZone *pZone) +{ + CCZone *pNewZone = NULL; + CCBRotateTo *pRet = NULL; + + if (pZone && pZone->m_pCopyObject) { + pRet = (CCBRotateTo*) (pZone->m_pCopyObject); + } else { + pRet = new CCBRotateTo(); + pZone = pNewZone = new CCZone(pRet); + } + + pRet->initWithDuration(m_fDuration, mDstAngle); + CCActionInterval::copyWithZone(pZone); + CC_SAFE_DELETE(pNewZone); + return pRet; +} + +void CCBRotateTo::startWithTarget(CCNode *pNode) +{ + CCActionInterval::startWithTarget(pNode); + mStartAngle = m_pTarget->getRotation(); + mDiffAngle = mDstAngle - mStartAngle; +} + +void CCBRotateTo::update(float time) +{ + m_pTarget->setRotation(mStartAngle + mDstAngle * time); +} + +NS_CC_EXT_END diff --git a/extensions/CCBReader/CCBAnimationManager.h b/extensions/CCBReader/CCBAnimationManager.h new file mode 100644 index 0000000000..7bec78474b --- /dev/null +++ b/extensions/CCBReader/CCBAnimationManager.h @@ -0,0 +1,109 @@ +#ifndef __CCB_CCBANIMATION_MANAGER_H__ +#define __CCB_CCBANIMATION_MANAGER_H__ + +#include "cocos2d.h" +#include "ExtensionMacros.h" +#include "CCBSequence.h" +#include "CCBValue.h" +#include "CCBSequenceProperty.h" + +NS_CC_EXT_BEGIN + +class CCBAnimationManagerDelegate +{ +public: + virtual void completedAnimationSequenceNamed(const char *name) = 0; +}; + +class CCBAnimationManager : public cocos2d::CCObject +{ +private: + cocos2d::CCArray *mSequences; + cocos2d::CCDictionary *mNodeSequences; + cocos2d::CCDictionary *mBaseValues; + int mAutoPlaySequenceId; + + cocos2d::CCNode *mRootNode; + CCSize mRootContainerSize; + + CCBAnimationManagerDelegate *mDelegate; + CCBSequence *mRunningSequence; + +public: + CCBAnimationManager(); + ~CCBAnimationManager(); + + virtual bool init(); + + cocos2d::CCArray* getSequences(); + + int getAutoPlaySequenceId(); + void setAutoPlaySequenceId(int autoPlaySequenceId); + + cocos2d::CCNode* getRootNode(); + void setRootNode(cocos2d::CCNode* pRootNode); // retain + + const cocos2d::CCSize& getRootContainerSize(); + void setRootContainerSize(const cocos2d::CCSize &rootContainerSize); + + CCBAnimationManagerDelegate* getDelegate(); + void setDelegate(CCBAnimationManagerDelegate* pDelegate); // retain + + const char* getRunningSequenceName(); + + const CCSize& getContainerSize(cocos2d::CCNode* pNode); + + void addNode(cocos2d::CCNode *pNode, cocos2d::CCDictionary *pSeq); + void setBaseValue(cocos2d::CCObject *pValue, cocos2d::CCNode *pNode, const char *pPropName); + + void runAnimations(const char *pName, float fTweenDuration); + void runAnimations(const char *pName); + void runAnimations(int nSeqId, float fTweenDuraiton); + + void debug(); + +private: + cocos2d::CCObject* getBaseValue(cocos2d::CCNode *pNode, const char* pPropName); + int getSequenceId(const char* pSequenceName); + CCBSequence* getSequence(int nSequenceId); + cocos2d::CCActionInterval* getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const char *pPropName, cocos2d::CCNode *pNode); + void setAnimatedProperty(const char *pPropName, cocos2d::CCNode *pNode, cocos2d::CCObject *pValue, float fTweenDuraion); + void setFirstFrame(cocos2d::CCNode *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration); + cocos2d::CCActionInterval* getEaseAction(cocos2d::CCActionInterval *pAction, int nEasingType, float fEasingOpt); + void runAction(cocos2d::CCNode *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration); + void sequenceCompleted(); +}; + +class CCBSetSpriteFrame : public cocos2d::CCActionInstant +{ +private: + cocos2d::CCSpriteFrame *mSpriteFrame; + +public: + ~CCBSetSpriteFrame(); + + /** creates a Place action with a position */ + static CCBSetSpriteFrame* create(cocos2d::CCSpriteFrame *pSpriteFrame); + bool initWithSpriteFrame(cocos2d::CCSpriteFrame *pSpriteFrame); + virtual void update(float time); + virtual cocos2d::CCObject* copyWithZone(cocos2d::CCZone *pZone); +}; + +class CCBRotateTo : public cocos2d::CCActionInterval +{ +private: + float mStartAngle; + float mDstAngle; + float mDiffAngle; + +public: + static CCBRotateTo* create(float fDuration, float fAngle); + bool initWithDuration(float fDuration, float fAngle); + virtual void update(float time); + virtual cocos2d::CCObject* copyWithZone(cocos2d::CCZone *pZone); + virtual void startWithTarget(cocos2d::CCNode *pNode); +}; + +NS_CC_EXT_END + +#endif // __CCB_CCBANIMATION_MANAGER_H__ diff --git a/extensions/CCBReader/CCBFileLoader.cpp b/extensions/CCBReader/CCBFileLoader.cpp index 0a429f4631..dabe5c955c 100644 --- a/extensions/CCBReader/CCBFileLoader.cpp +++ b/extensions/CCBReader/CCBFileLoader.cpp @@ -8,7 +8,7 @@ NS_CC_EXT_BEGIN void CCBFileLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) { if(pPropertyName->compare(PROPERTY_CCBFILE) == 0) { - pNode->addChild(pCCBFileNode); + ((CCBFile*)pNode)->setCCBFileNode(pCCBFileNode); } else { CCNodeLoader::onHandlePropTypeCCBFile(pNode, pParent, pPropertyName, pCCBFileNode, pCCBReader); } diff --git a/extensions/CCBReader/CCBFileLoader.h b/extensions/CCBReader/CCBFileLoader.h index b614e38720..78bbf57f78 100644 --- a/extensions/CCBReader/CCBFileLoader.h +++ b/extensions/CCBReader/CCBFileLoader.h @@ -2,6 +2,7 @@ #define _CCB_CCBFILELOADER_H_ #include "CCNodeLoader.h" +#include "CCBReader.h" NS_CC_EXT_BEGIN @@ -14,7 +15,7 @@ class CCBFileLoader : public CCNodeLoader { CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCBFileLoader, loader); protected: - CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCNode); + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCBFile); virtual void onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader); }; diff --git a/extensions/CCBReader/CCBKeyframe.cpp b/extensions/CCBReader/CCBKeyframe.cpp new file mode 100644 index 0000000000..8b26314d0d --- /dev/null +++ b/extensions/CCBReader/CCBKeyframe.cpp @@ -0,0 +1,61 @@ +#include "CCBKeyframe.h" + +using namespace cocos2d; + +NS_CC_EXT_BEGIN + +CCBKeyframe::CCBKeyframe() +: mValue(NULL) +, mTime(0.0f) +, mEasingType(0) +, mEasingOpt(0.0f) +{} + +CCBKeyframe::~CCBKeyframe() +{ + CC_SAFE_RELEASE_NULL(mValue); +} + +CCObject* CCBKeyframe::getValue() +{ + return mValue; +} + +void CCBKeyframe::setValue(CCObject *pValue) +{ + CC_SAFE_RELEASE(mValue); + mValue = pValue; + CC_SAFE_RETAIN(mValue); +} + +float CCBKeyframe::getTime() +{ + return mTime; +} + +void CCBKeyframe::setTime(float fTime) +{ + mTime = fTime; +} + +int CCBKeyframe::getEasingType() +{ + return mEasingType; +} + +void CCBKeyframe::setEasingType(int nEasingType) +{ + mEasingType = nEasingType; +} + +float CCBKeyframe::getEasingOpt() +{ + return mEasingOpt; +} + +void CCBKeyframe::setEasingOpt(float fEasingOpt) +{ + mEasingOpt = fEasingOpt; +} + +NS_CC_EXT_END diff --git a/extensions/CCBReader/CCBKeyframe.h b/extensions/CCBReader/CCBKeyframe.h new file mode 100644 index 0000000000..6a53760551 --- /dev/null +++ b/extensions/CCBReader/CCBKeyframe.h @@ -0,0 +1,36 @@ +#ifndef __CCB_KEYFRAME_H__ +#define __CCB_KEYFRAME_H__ + +#include "cocos2d.h" +#include "ExtensionMacros.h" + +NS_CC_EXT_BEGIN + +class CCBKeyframe : public cocos2d::CCObject +{ +private: + cocos2d::CCObject *mValue; + float mTime; + int mEasingType; + float mEasingOpt; + +public: + CCBKeyframe(); + ~CCBKeyframe(); + + cocos2d::CCObject* getValue(); + void setValue(cocos2d::CCObject *pValue); // retain + + float getTime(); + void setTime(float fTime); + + int getEasingType(); + void setEasingType(int nEasingType); + + float getEasingOpt(); + void setEasingOpt(float fEasingOpt); +}; + +NS_CC_EXT_END + +#endif // __CCB_KEYFRAME_H__ diff --git a/extensions/CCBReader/CCBReader.cpp b/extensions/CCBReader/CCBReader.cpp index 22b956d0df..a2c44f90df 100644 --- a/extensions/CCBReader/CCBReader.cpp +++ b/extensions/CCBReader/CCBReader.cpp @@ -7,6 +7,11 @@ #include "CCNodeLoaderListener.h" #include "CCBMemberVariableAssigner.h" #include "CCBSelectorResolver.h" +#include "CCData.h" +#include "CCBAnimationManager.h" +#include "CCBSequenceProperty.h" +#include "CCBKeyframe.h" +#include "CCBValue.h" #include @@ -14,35 +19,67 @@ #include #endif +using namespace std; USING_NS_CC; NS_CC_EXT_BEGIN; -CCBReader::CCBReader(CCNodeLoaderLibrary * pCCNodeLoaderLibrary, CCBMemberVariableAssigner * pCCBMemberVariableAssigner, CCBSelectorResolver * pCCBSelectorResolver, CCNodeLoaderListener * pCCNodeLoaderListener) { - this->mRootNode = NULL; - this->mRootCCBReader = true; +/************************************************************************* + Implementation of CCBFile + *************************************************************************/ +CCBFile::CCBFile():mCCBFileNode(NULL) {} + +CCBFile* CCBFile::create() +{ + CCBFile *ret = new CCBFile(); + + if (ret) + { + ret->autorelease(); + } + + return ret; +} + +CCNode* CCBFile::getCCBFileNode() +{ + return mCCBFileNode; +} + +void CCBFile::setCCBFileNode(CCNode *pNode) +{ + CC_SAFE_RELEASE(mCCBFileNode); + mCCBFileNode = pNode; + CC_SAFE_RETAIN(mCCBFileNode); +} + +/************************************************************************* + Implementation of CCBReader + *************************************************************************/ + +CCBReader::CCBReader(CCNodeLoaderLibrary * pCCNodeLoaderLibrary, CCBMemberVariableAssigner * pCCBMemberVariableAssigner, CCBSelectorResolver * pCCBSelectorResolver, CCNodeLoaderListener * pCCNodeLoaderListener) +: mData(NULL) +, mBytes(NULL) +, mCurrentByte(-1) +, mCurrentBit(-1) +, mOwner(NULL) +, mActionManager(NULL) +{ this->mCCNodeLoaderLibrary = pCCNodeLoaderLibrary; this->mCCNodeLoaderLibrary->retain(); this->mCCBMemberVariableAssigner = pCCBMemberVariableAssigner; this->mCCBSelectorResolver = pCCBSelectorResolver; this->mCCNodeLoaderListener = pCCNodeLoaderListener; - - this->mResolutionScale = 1; - -#ifdef __CC_PLATFORM_IOS - /* iPad */ - if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - this->mResolutionScale = 2; - } -#endif } -CCBReader::CCBReader(CCBReader * pCCBReader) { - this->mRootNode = NULL; - this->mRootCCBReader = false; - - /* Borrow data from the 'parent' CCBReader. */ - this->mResolutionScale = pCCBReader->mResolutionScale; +CCBReader::CCBReader(CCBReader * pCCBReader) +: mData(NULL) +, mBytes(NULL) +, mCurrentByte(-1) +, mCurrentBit(-1) +, mOwner(NULL) +, mActionManager(NULL) +{ this->mLoadedSpriteSheets = pCCBReader->mLoadedSpriteSheets; this->mCCNodeLoaderLibrary = pCCBReader->mCCNodeLoaderLibrary; this->mCCNodeLoaderLibrary->retain(); @@ -52,26 +89,68 @@ CCBReader::CCBReader(CCBReader * pCCBReader) { this->mCCNodeLoaderListener = pCCBReader->mCCNodeLoaderListener; } +CCBReader::CCBReader() +: mData(NULL) +, mBytes(NULL) +, mCurrentByte(-1) +, mCurrentBit(-1) +, mOwner(NULL) +, mActionManager(NULL) +, mCCNodeLoaderLibrary(NULL) +, mCCNodeLoaderListener(NULL) +, mCCBMemberVariableAssigner(NULL) +, mCCBSelectorResolver(NULL) +{} + CCBReader::~CCBReader() { - CC_SAFE_DELETE_ARRAY(this->mBytes); + CC_SAFE_RELEASE_NULL(mOwner); + CC_SAFE_RELEASE_NULL(mData); this->mCCNodeLoaderLibrary->release(); - /* Clear string cache. */ + // Clear string cache. std::vector::iterator stringCacheIterator; for (stringCacheIterator = this->mStringCache.begin(); stringCacheIterator != this->mStringCache.end(); stringCacheIterator++) { (*stringCacheIterator)->release(); } this->mStringCache.clear(); - if(this->mRootCCBReader) { - /* Clear loaded spritesheets. */ - this->mLoadedSpriteSheets.clear(); - } + setAnimationManager(NULL); } -CCString * CCBReader::getCCBRootPath() { - return this->mCCBRootPath; +bool CCBReader::initWithData(CCData *pData, CCObject *pOwner) +{ + // Setup action manager + CCBAnimationManager *pActionManager = new CCBAnimationManager(); + setAnimationManager(pActionManager); + pActionManager->release(); + + // Setup byte array + mData = pData; + CC_SAFE_RETAIN(mData); + mBytes = mData->getBytes(); + mCurrentByte = 0; + mCurrentBit = 0; + + mOwner = pOwner; + CC_SAFE_RETAIN(mOwner); + + // Setup resolution scale and container size + mActionManager->setRootContainerSize(CCDirector::sharedDirector()->getWinSize()); + + return true; +} + +CCBAnimationManager* CCBReader::getAnimationManager() +{ + return mActionManager; +} + +void CCBReader::setAnimationManager(CCBAnimationManager *pAnimationManager) +{ + CC_SAFE_RELEASE(mActionManager); + mActionManager = pAnimationManager; + CC_SAFE_RETAIN(mActionManager); } CCBMemberVariableAssigner * CCBReader::getCCBMemberVariableAssigner() { @@ -82,50 +161,105 @@ CCBSelectorResolver * CCBReader::getCCBSelectorResolver() { return this->mCCBSelectorResolver; } -float CCBReader::getResolutionScale() { - return this->mResolutionScale; +set& CCBReader::getAnimatedProperties() +{ + return mAnimatedProps; } -CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner) { - return this->readNodeGraphFromFile(pCCBRootPath, pCCBFileName, pOwner, CCDirector::sharedDirector()->getWinSize()); +set& CCBReader::getLoadedSpriteSheet() +{ + return mLoadedSpriteSheets; } -CCNode * CCBReader::readNodeGraphFromFile(CCString * pCCBRootPath, CCString * pCCBFileName, CCObject * pOwner) { - return this->readNodeGraphFromFile(pCCBRootPath, pCCBFileName, pOwner, CCDirector::sharedDirector()->getWinSize()); +CCObject* CCBReader::getOwner() +{ + return mOwner; } -CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize) { - return this->readNodeGraphFromFile(CCString::create(pCCBRootPath), CCString::create(pCCBFileName), pOwner, pRootContainerSize); +CCNode* CCBReader::readNodeGraphFromFile(const char *pCCBFileName) +{ + return this->readNodeGraphFromFile(pCCBFileName, NULL); } -CCNode * CCBReader::readNodeGraphFromFile(CCString * pCCBRootPath, CCString * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize) { - this->mCCBRootPath = pCCBRootPath; - this->mCCBRootPath->retain(); +CCNode* CCBReader::readNodeGraphFromFile(const char* pCCBFileName, CCObject* pOwner) +{ + return this->readNodeGraphFromFile(pCCBFileName, pOwner, CCDirector::sharedDirector()->getWinSize()); +} - CCString * ccbFullFilePath = CCBReader::concat(pCCBRootPath, pCCBFileName); +CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCObject *pOwner, const CCSize &parentSize) +{ + return this->readNodeGraphFromFile(pCCBFileName, pOwner, parentSize, NULL); +} - const char * path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(ccbFullFilePath->getCString()); +CCNode* CCBReader::readNodeGraphFromFile(const char *pCCBFileName, CCObject *pOwner, CCBAnimationManager **ppAnimationManager) +{ + return this->readNodeGraphFromFile(pCCBFileName, pOwner, CCDirector::sharedDirector()->getWinSize(), ppAnimationManager); +} - unsigned long size = 0; - this->mBytes = CCFileUtils::sharedFileUtils()->getFileData(path, "rb", &size); +CCNode* CCBReader::readNodeGraphFromFile(const char *pCCBFileName, CCObject *pOwner, const CCSize &parentSize, CCBAnimationManager **ppAnimationManager) +{ + const char *pPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pCCBFileName); + unsigned long size; - this->mCurrentByte = 0; - this->mCurrentBit = 0; + unsigned char * pBytes = CCFileUtils::sharedFileUtils()->getFileData(pPath, "rb", &size); + CCData *data = new CCData(pBytes, size); - this->mOwner = pOwner; - CC_SAFE_RETAIN(this->mOwner); - this->mRootContainerSize = pRootContainerSize; + CCNode *ret = this->readNodeGraphFromData(data, pOwner, parentSize, ppAnimationManager); + + data->release(); + + return ret; +} - CCNode * node = NULL; - if(this->readHeader() && this->readStringCache()) { - node = this->readNodeGraph(); +CCNode* CCBReader::readNodeGraphFromData(CCData *pData, CCObject *pOwner, const CCSize &parentSize) +{ + return this->readNodeGraphFromData(pData, pOwner, parentSize, NULL); +} + +CCNode* CCBReader::readNodeGraphFromData(CCData *pData, CCObject *pOwner, const CCSize &parentSize, CCBAnimationManager **ppAnimationManager) +{ + initWithData(pData, pOwner); + mActionManager->setRootContainerSize(parentSize); + + CCNode *pNodeGraph = readFileWithCleanUp(true); + + if (pNodeGraph && mActionManager->getAutoPlaySequenceId() != -1) + { + // Auto play animations + mActionManager->runAnimations(mActionManager->getAutoPlaySequenceId(), 0); } + + // Return action manager by reference + if (ppAnimationManager) + { + *ppAnimationManager = mActionManager; + } + + return pNodeGraph; +} - CC_SAFE_RELEASE(this->mOwner); - CC_SAFE_RELEASE(this->mCCBRootPath); - CC_SAFE_RELEASE(this->mRootNode); +CCScene* CCBReader::createSceneWithNodeGraphFromFile(const char *pCCBFileName) +{ + return createSceneWithNodeGraphFromFile(pCCBFileName, NULL); +} - return node; +CCScene* CCBReader::createSceneWithNodeGraphFromFile(const char *pCCBFileName, CCObject *pOwner) +{ + return createSceneWithNodeGraphFromFile(pCCBFileName, pOwner, CCDirector::sharedDirector()->getWinSize()); +} + +CCScene* CCBReader::createSceneWithNodeGraphFromFile(const char *pCCBFileName, CCObject *pOwner, const CCSize &parentSize) +{ + return createSceneWithNodeGraphFromFile(pCCBFileName, pOwner, parentSize, NULL); +} + +CCScene* CCBReader::createSceneWithNodeGraphFromFile(const char *pCCBFileName, CCObject *pOwner, const CCSize &parentSize, CCBAnimationManager **ppAnimationManager) +{ + CCNode *pNode = readNodeGraphFromFile(pCCBFileName, pOwner, parentSize, ppAnimationManager); + CCScene *pScene = CCScene::create(); + pScene->addChild(pNode); + + return pScene; } bool CCBReader::readHeader() { @@ -152,6 +286,44 @@ bool CCBReader::readHeader() { return true; } +void CCBReader::cleanUpNodeGraph(CCNode *pNode) +{ + pNode->setUserObject(NULL); + + CCObject *pChild = NULL; + CCARRAY_FOREACH(pNode->getChildren(), pChild) + { + cleanUpNodeGraph((CCNode*)pChild); + } +} + +CCNode* CCBReader::readFileWithCleanUp(bool bCleanUp) +{ + if (! readHeader()) + { + return NULL; + } + + if (! readStringCache()) + { + return NULL; + } + + if (! readSequences()) + { + return NULL; + } + + CCNode *pNode = readNodeGraph(); + + if (bCleanUp) + { + cleanUpNodeGraph(pNode); + } + + return pNode; +} + bool CCBReader::readStringCache() { int numStrings = this->readInt(false); @@ -281,26 +453,104 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) { /* Read class name. */ CCString * className = this->readCachedString(); + // Read assignment type and name int memberVarAssignmentType = this->readInt(false); CCString * memberVarAssignmentName; if(memberVarAssignmentType != kCCBTargetTypeNone) { memberVarAssignmentName = this->readCachedString(); } - CCNodeLoader * ccNodeLoader = this->mCCNodeLoaderLibrary->getCCNodeLoader(className); - CCNode * node = ccNodeLoader->loadCCNode(pParent, this); - - /* Set root node, if not set yet. */ - if(this->mRootNode == NULL) { - this->mRootNode = node; - this->mRootNode->retain(); + CCNodeLoader *ccNodeLoader = this->mCCNodeLoaderLibrary->getCCNodeLoader(className); + if (! ccNodeLoader) + { + CCLog("no corresponding node loader for %s", className->getCString()); + return NULL; } + CCNode *node = ccNodeLoader->loadCCNode(pParent, this); + + // Set root node + if (! mActionManager->getRootNode()) + { + mActionManager->setRootNode(node); + } + + // Read animated properties + CCDictionary *seqs = CCDictionary::create(); + + int numSequence = readInt(false); + for (int i = 0; i < numSequence; ++i) + { + int seqId = readInt(false); + CCDictionary *seqNodeProps = CCDictionary::create(); + + int numProps = readInt(false); + + for (int j = 0; j < numProps; ++j) + { + CCBSequenceProperty *seqProp = new CCBSequenceProperty(); + seqProp->autorelease(); + + seqProp->setName(readCachedString()->getCString()); + seqProp->setType(readInt(false)); + mAnimatedProps.insert(seqProp->getName()); + + int numKeyframes = readInt(false); + + for (int k = 0; k < numKeyframes; ++k) + { + CCBKeyframe *keyframe = readKeyframe(seqProp->getType()); + + seqProp->getKeyframes()->addObject(keyframe); + } + + seqNodeProps->setObject(seqProp, seqProp->getName()); + } + + seqs->setObject(seqNodeProps, seqId); + } + + if (seqs->count() > 0) + { + mActionManager->addNode(node, seqs); + } + + // Read properties + ccNodeLoader->parseProperties(node, pParent, this); + + // Handle sub ccb files (remove middle node) + if (dynamic_cast(node)) + { + CCBFile *ccbFileNode = (CCBFile*)node; + + CCNode *embeddedNode = ccbFileNode->getCCBFileNode(); + embeddedNode->setPosition(ccbFileNode->getPosition()); + embeddedNode->setRotation(ccbFileNode->getRotation()); + embeddedNode->setScale(ccbFileNode->getScale()); + embeddedNode->setTag(ccbFileNode->getTag()); + embeddedNode->setVisible(true); + embeddedNode->ignoreAnchorPointForPosition(ccbFileNode->isIgnoreAnchorPointForPosition()); + + ccbFileNode->setCCBFileNode(NULL); + + node = embeddedNode; + } + +#ifdef CCB_ENABLE_JAVASCRIPT + /* + if (memberVarAssignmentType && memberVarAssignmentName && ![memberVarAssignmentName isEqualToString:@""]) + { + [[JSCocoa sharedController] setObject:node withName:memberVarAssignmentName]; + }*/ +#else if(memberVarAssignmentType != kCCBTargetTypeNone) { CCObject * target = NULL; - if(memberVarAssignmentType == kCCBTargetTypeDocumentRoot) { - target = this->mRootNode; - } else if(memberVarAssignmentType == kCCBTargetTypeOwner) { + if(memberVarAssignmentType == kCCBTargetTypeDocumentRoot) + { + target = mActionManager->getRootNode(); + } + else if(memberVarAssignmentType == kCCBTargetTypeOwner) + { target = this->mOwner; } @@ -318,6 +568,7 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) { } } } +#endif // CCB_ENABLE_JAVASCRIPT /* Read and add children. */ int numChildren = this->readInt(false); @@ -326,6 +577,7 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) { node->addChild(child); } + // Call onNodeLoaded CCNodeLoaderListener * nodeAsCCNodeLoaderListener = dynamic_cast(node); if(nodeAsCCNodeLoaderListener != NULL) { nodeAsCCNodeLoaderListener->onNodeLoaded(node, ccNodeLoader); @@ -336,34 +588,118 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) { return node; } +CCBKeyframe* CCBReader::readKeyframe(int type) +{ + CCBKeyframe *keyframe = new CCBKeyframe(); + keyframe->autorelease(); + + keyframe->setTime(readFloat()); + + int easingType = readInt(false); + float easingOpt = 0; + CCObject *value = NULL; + + if (easingType == kCCBKeyframeEasingCubicIn + || easingType == kCCBKeyframeEasingCubicOut + || easingType == kCCBKeyframeEasingCubicInOut + || easingType == kCCBKeyframeEasingElasticIn + || easingType == kCCBKeyframeEasingElasticOut + || easingType == kCCBKeyframeEasingElasticInOut) + { + easingOpt = readFloat(); + } + keyframe->setEasingType(easingType); + keyframe->setEasingOpt(easingOpt); + + if (type == kCCBPropTypeCheck) + { + value = CCBValue::create(readBool()); + } + else if (type == kCCBPropTypeByte) + { + value = CCBValue::create(readByte()); + } + else if (type == kCCBPropTypeColor3) + { + int r = readByte(); + int g = readByte(); + int b = readByte(); + + ccColor3B c = ccc3(r,g,b); + value = ccColor3BWapper::create(c); + } + else if (type == kCCBPropTypeDegrees) + { + value = CCBValue::create(readFloat()); + } + else if (type == kCCBPropTypeScaleLock || type == kCCBPropTypePosition) + { + float a = readFloat(); + float b = readFloat(); + + value = CCArray::create(CCBValue::create(a), + CCBValue::create(b), + NULL); + } + else if (type == kCCBPropTypeSpriteFrame) + { + CCString *spriteSheet = readCachedString(); + CCString *spriteFile = readCachedString(); + + CCSpriteFrame* spriteFrame; + CCString empty(""); + if (spriteSheet->isEqual(&empty)) + { + CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage(spriteFile->getCString()); + CCRect bounds = CCRectMake(0, 0, texture->getContentSize().width, texture->getContentSize().height); + spriteFrame = CCSpriteFrame::createWithTexture(texture, bounds); + } + else + { + CCSpriteFrameCache* frameCache = CCSpriteFrameCache::sharedSpriteFrameCache(); + + // Load the sprite sheet only if it is not loaded + if (mLoadedSpriteSheets.find(spriteSheet->getCString()) == mLoadedSpriteSheets.end()) + { + frameCache->addSpriteFramesWithFile(spriteSheet->getCString()); + mLoadedSpriteSheets.insert(spriteSheet->getCString()); + } + + spriteFrame = frameCache->spriteFrameByName(spriteFile->getCString()); + } + value = spriteFrame; + } + + keyframe->setValue(value); + + return keyframe; +} + CCNode * CCBReader::readNodeGraph() { return this->readNodeGraph(NULL); } -CCObject * CCBReader::getOwner() { - return this->mOwner; -} - -CCNode * CCBReader::getRootNode() { - return this->mRootNode; -} - -CCSize CCBReader::getContainerSize(CCNode * pNode) { - if(pNode) { - return pNode->getContentSize(); - } else { - return this->mRootContainerSize; +bool CCBReader::readSequences() +{ + CCArray *sequences = mActionManager->getSequences(); + + int numSeqs = readInt(false); + + for (int i = 0; i < numSeqs; i++) + { + CCBSequence *seq = new CCBSequence(); + seq->autorelease(); + + seq->setDuration(readFloat()); + seq->setName(readCachedString()->getCString()); + seq->setSequenceId(readInt(false)); + seq->setChainedSequenceId(readInt(true)); + + sequences->addObject(seq); } -} - -bool CCBReader::isSpriteSheetLoaded(CCString * pSpriteSheet) { - return this->mLoadedSpriteSheets.find(pSpriteSheet->m_sString) != this->mLoadedSpriteSheets.end(); -} - -void CCBReader::addLoadedSpriteSheet(CCString * pSpriteSheet) { - // Since std::set will copy the string from pSpriteSheet, we needn't to retain 'pSpriteSheet'. - // pSpriteSheet->retain(); - this->mLoadedSpriteSheets.insert(pSpriteSheet->m_sString); + + mActionManager->setAutoPlaySequenceId(readInt(true)); + return true; } CCString * CCBReader::lastPathComponent(CCString * pPath) { @@ -413,4 +749,21 @@ bool CCBReader::endsWith(CCString * pString, CCString * pEnding) { } } +/************************************************************************ + Static functions + ************************************************************************/ + +float CCBReader::getResolutionScale() +{ + // Init resolution scale + if (CCApplication::sharedApplication()->getTargetPlatform() == kTargetIpad) + { + return 2; + } + else + { + return 1; + } +} + NS_CC_EXT_END; diff --git a/extensions/CCBReader/CCBReader.h b/extensions/CCBReader/CCBReader.h index a2bd2f4cce..534e2198dc 100644 --- a/extensions/CCBReader/CCBReader.h +++ b/extensions/CCBReader/CCBReader.h @@ -3,6 +3,8 @@ #include "cocos2d.h" #include "ExtensionMacros.h" +#include +#include #define CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(T, METHOD) static T * METHOD() { \ T * ptr = new T(); \ @@ -24,66 +26,107 @@ return NULL; \ } -#define kCCBVersion 2 +#define kCCBVersion 3 -#define kCCBPropTypePosition 0 -#define kCCBPropTypeSize 1 -#define kCCBPropTypePoint 2 -#define kCCBPropTypePointLock 3 -#define kCCBPropTypeScaleLock 4 -#define kCCBPropTypeDegrees 5 -#define kCCBPropTypeInteger 6 -#define kCCBPropTypeFloat 7 -#define kCCBPropTypeFloatVar 8 -#define kCCBPropTypeCheck 9 -#define kCCBPropTypeSpriteFrame 10 -#define kCCBPropTypeTexture 11 -#define kCCBPropTypeByte 12 -#define kCCBPropTypeColor3 13 -#define kCCBPropTypeColor4FVar 14 -#define kCCBPropTypeFlip 15 -#define kCCBPropTypeBlendFunc 16 -#define kCCBPropTypeFntFile 17 -#define kCCBPropTypeText 18 -#define kCCBPropTypeFontTTF 19 -#define kCCBPropTypeIntegerLabeled 20 -#define kCCBPropTypeBlock 21 -#define kCCBPropTypeAnimation 22 -#define kCCBPropTypeCCBFile 23 -#define kCCBPropTypeString 24 -#define kCCBPropTypeBlockCCControl 25 -#define kCCBPropTypeFloatScale 26 +enum { + kCCBPropTypePosition = 0, + kCCBPropTypeSize, + kCCBPropTypePoint, + kCCBPropTypePointLock, + kCCBPropTypeScaleLock, + kCCBPropTypeDegrees, + kCCBPropTypeInteger, + kCCBPropTypeFloat, + kCCBPropTypeFloatVar, + kCCBPropTypeCheck, + kCCBPropTypeSpriteFrame, + kCCBPropTypeTexture, + kCCBPropTypeByte, + kCCBPropTypeColor3, + kCCBPropTypeColor4FVar, + kCCBPropTypeFlip, + kCCBPropTypeBlendmode, + kCCBPropTypeFntFile, + kCCBPropTypeText, + kCCBPropTypeFontTTF, + kCCBPropTypeIntegerLabeled, + kCCBPropTypeBlock, + kCCBPropTypeAnimation, + kCCBPropTypeCCBFile, + kCCBPropTypeString, + kCCBPropTypeBlockCCControl, + kCCBPropTypeFloatScale +}; -#define kCCBFloat0 0 -#define kCCBFloat1 1 -#define kCCBFloatMinus1 2 -#define kCCBFloat05 3 -#define kCCBFloatInteger 4 -#define kCCBFloatFull 5 +enum { + kCCBFloat0 = 0, + kCCBFloat1, + kCCBFloatMinus1, + kCCBFloat05, + kCCBFloatInteger, + kCCBFloatFull +}; -#define kCCBPlatformAll 0 -#define kCCBPlatformIOS 1 -#define kCCBPlatformMac 2 +enum { + kCCBPlatformAll = 0, + kCCBPlatformIOS, + kCCBPlatformMac +}; -#define kCCBTargetTypeNone 0 -#define kCCBTargetTypeDocumentRoot 1 -#define kCCBTargetTypeOwner 2 +enum { + kCCBTargetTypeNone = 0, + kCCBTargetTypeDocumentRoot = 1, + kCCBTargetTypeOwner = 2, +}; -#define kCCBPositionTypeRelativeBottomLeft 0 -#define kCCBPositionTypeRelativeTopLeft 1 -#define kCCBPositionTypeRelativeTopRight 2 -#define kCCBPositionTypeRelativeBottomRight 3 -#define kCCBPositionTypePercent 4 +enum +{ + kCCBKeyframeEasingInstant, + + kCCBKeyframeEasingLinear, + + kCCBKeyframeEasingCubicIn, + kCCBKeyframeEasingCubicOut, + kCCBKeyframeEasingCubicInOut, + + kCCBKeyframeEasingElasticIn, + kCCBKeyframeEasingElasticOut, + kCCBKeyframeEasingElasticInOut, + + kCCBKeyframeEasingBounceIn, + kCCBKeyframeEasingBounceOut, + kCCBKeyframeEasingBounceInOut, + + kCCBKeyframeEasingBackIn, + kCCBKeyframeEasingBackOut, + kCCBKeyframeEasingBackInOut, +}; -#define kCCBSizeTypeAbsolute 0 -#define kCCBSizeTypePercent 1 -#define kCCBSizeTypeRelativeContainer 2 -#define kCCBSizeTypeHorizontalPercent 3 -#define kCCBSzieTypeVerticalPercent 4 +enum +{ + kCCBPositionTypeRelativeBottomLeft, + kCCBPositionTypeRelativeTopLeft, + kCCBPositionTypeRelativeTopRight, + kCCBPositionTypeRelativeBottomRight, + kCCBPositionTypePercent, + kCCBPositionTypeMultiplyResolution, +}; +enum +{ + kCCBSizeTypeAbsolute, + kCCBSizeTypePercent, + kCCBSizeTypeRelativeContainer, + kCCBSizeTypeHorizontalPercent, + kCCBSizeTypeVerticalPercent, + kCCBSizeTypeMultiplyResolution, +}; -#define kCCBScaleTypeAbsolute 0 -#define kCCBScaleTypeMultiplyResolution 1 +enum +{ + kCCBScaleTypeAbsolute, + kCCBScaleTypeMultiplyResolution +}; USING_NS_CC; NS_CC_EXT_BEGIN @@ -93,83 +136,120 @@ NS_CC_EXT_BEGIN * @{ */ +class CCBFile : public CCNode +{ +private: + CCNode *mCCBFileNode; + +public: + CCBFile(); + + static CCBFile* create(); + + CCNode* getCCBFileNode(); + void setCCBFileNode(CCNode *pNode); // retain +}; + /* Forward declaration. */ class CCNodeLoader; class CCNodeLoaderLibrary; class CCNodeLoaderListener; class CCBMemberVariableAssigner; class CCBSelectorResolver; +class CCBAnimationManager; +class CCData; +class CCBKeyframe; /** * @brief Parse CCBI file which is generated by CocosBuilder */ -class CCBReader : public CCObject { - private: - CCString * mCCBRootPath; - bool mRootCCBReader; - - unsigned char * mBytes; - int mCurrentByte; - int mCurrentBit; - CCObject * mOwner; - CCNode * mRootNode; - CCSize mRootContainerSize; - float mResolutionScale; - - CCNodeLoaderLibrary * mCCNodeLoaderLibrary; - CCNodeLoaderListener * mCCNodeLoaderListener; - CCBMemberVariableAssigner * mCCBMemberVariableAssigner; - CCBSelectorResolver * mCCBSelectorResolver; - - std::vector mStringCache; - std::set mLoadedSpriteSheets; - - public: - CCBReader(CCNodeLoaderLibrary * pCCNodeLoaderLibrary, CCBMemberVariableAssigner * pCCBMemberVariableAssigner = NULL, CCBSelectorResolver * pCCBSelectorResolver = NULL, CCNodeLoaderListener * pCCNodeLoaderListener = NULL); - CCBReader(CCBReader * pCCBReader); - virtual ~CCBReader(); +class CCBReader : public CCObject +{ +private: + CCData *mData; + unsigned char *mBytes; + int mCurrentByte; + int mCurrentBit; - CCNode * readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner = NULL); - CCNode * readNodeGraphFromFile(CCString * pCCBRootPath, CCString * pCCBFileName, CCObject * pOwner = NULL); - CCNode * readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize); - CCNode * readNodeGraphFromFile(CCString * pCCBRootPath, CCString * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize); + std::vector mStringCache; + std::set mLoadedSpriteSheets; + + CCObject *mOwner; + + CCBAnimationManager *mActionManager; + std::set mAnimatedProps; - CCBMemberVariableAssigner * getCCBMemberVariableAssigner(); - CCBSelectorResolver * getCCBSelectorResolver(); + CCNodeLoaderLibrary *mCCNodeLoaderLibrary; + CCNodeLoaderListener *mCCNodeLoaderListener; + CCBMemberVariableAssigner *mCCBMemberVariableAssigner; + CCBSelectorResolver *mCCBSelectorResolver; - CCString * getCCBRootPath(); - CCObject * getOwner(); - CCNode * getRootNode(); - CCSize getContainerSize(CCNode * pNode); - float getResolutionScale(); +public: + CCBReader(CCNodeLoaderLibrary *pCCNodeLoaderLibrary, CCBMemberVariableAssigner *pCCBMemberVariableAssigner = NULL, CCBSelectorResolver *pCCBSelectorResolver = NULL, CCNodeLoaderListener *pCCNodeLoaderListener = NULL); + CCBReader(CCBReader *pCCBReader); + virtual ~CCBReader(); + CCBReader(); + + bool initWithData(CCData *pData, CCObject *pOwner); + + CCNode* readNodeGraphFromFile(const char *pCCBFileName); + CCNode* readNodeGraphFromFile(const char *pCCBFileName, CCObject *pOwner); + CCNode* readNodeGraphFromFile(const char *pCCBFileName, CCObject *pOwner, const CCSize &parentSize); + CCNode* readNodeGraphFromFile(const char *pCCBFileName, CCObject *pOwner, CCBAnimationManager **ppAnimationManager); + CCNode* readNodeGraphFromFile(const char *pCCBFileName, CCObject *pOwner, const CCSize &parentSize, CCBAnimationManager **ppAnimationManager); + + CCNode* readNodeGraphFromData(CCData *pData, CCObject *pOwner, const CCSize &parentSize, CCBAnimationManager **ppAnimationManager); + CCNode* readNodeGraphFromData(CCData *pData, CCObject *pOwner, const CCSize &parentSize); + + CCScene* createSceneWithNodeGraphFromFile(const char *pCCBFileName); + CCScene* createSceneWithNodeGraphFromFile(const char *pCCBFileName, CCObject *pOwner); + CCScene* createSceneWithNodeGraphFromFile(const char *pCCBFileName, CCObject *pOwner, const CCSize &parentSize); + CCScene* createSceneWithNodeGraphFromFile(const char *pCCBFileName, CCObject *pOwner, CCBAnimationManager **ppAnimationManager); + CCScene* createSceneWithNodeGraphFromFile(const char *pCCBFileName, CCObject *pOwner, const CCSize &parentSize, CCBAnimationManager **ppAnimationManager); - bool isSpriteSheetLoaded(CCString * pSpriteSheet); - void addLoadedSpriteSheet(CCString * pSpriteSheet); + CCBMemberVariableAssigner* getCCBMemberVariableAssigner(); + CCBSelectorResolver* getCCBSelectorResolver(); + + CCBAnimationManager* getAnimationManager(); + void setAnimationManager(CCBAnimationManager *pAnimationManager); + + // Used in CCNodeLoader::parseProperties() + std::set& getAnimatedProperties(); + std::set& getLoadedSpriteSheet(); + CCObject* getOwner(); - /* Utility methods. */ - static CCString * lastPathComponent(CCString * pString); - static CCString * deletePathExtension(CCString * pString); - static CCString * toLowerCase(CCString * pCCString); - static bool endsWith(CCString * pString, CCString * pEnding); - static CCString * concat(CCString * pStringA, CCString * pStringB); + /* Utility methods. */ + static CCString* lastPathComponent(CCString * pString); + static CCString* deletePathExtension(CCString * pString); + static CCString* toLowerCase(CCString * pCCString); + static bool endsWith(CCString * pString, CCString * pEnding); + static CCString* concat(CCString * pStringA, CCString * pStringB); - /* Parse methods. */ - int readInt(bool pSigned); - unsigned char readByte(); - bool readBool(); - float readFloat(); - CCString * readCachedString(); + /* Parse methods. */ + int readInt(bool pSigned); + unsigned char readByte(); + bool readBool(); + float readFloat(); + CCString* readCachedString(); + + static float getResolutionScale(); + + CCNode* readFileWithCleanUp(bool bCleanUp); + +private: + void cleanUpNodeGraph(CCNode *pNode); + bool readSequences(); + CCBKeyframe* readKeyframe(int type); + + bool readHeader(); + bool readStringCache(); + void readStringCacheEntry(); + CCNode* readNodeGraph(); + CCNode* readNodeGraph(CCNode * pParent); - private: - bool readHeader(); - bool readStringCache(); - void readStringCacheEntry(); - CCNode * readNodeGraph(); - CCNode * readNodeGraph(CCNode * pParent); - - bool getBit(); - void alignBits(); - CCString * readUTF8(); + bool getBit(); + void alignBits(); + CCString* readUTF8(); }; // end of effects group diff --git a/extensions/CCBReader/CCBSequence.cpp b/extensions/CCBReader/CCBSequence.cpp new file mode 100644 index 0000000000..f0cd797c29 --- /dev/null +++ b/extensions/CCBReader/CCBSequence.cpp @@ -0,0 +1,56 @@ +#include "CCBSequence.h" + +using namespace cocos2d; +using namespace std; + + +NS_CC_EXT_BEGIN + +CCBSequence::CCBSequence() +: mDuration(0.0f) +, mName("") +, mSequenceId(0) +, mChainedSequenceId(0) +{} + +float CCBSequence::getDuration() +{ + return mDuration; +} + +void CCBSequence::setDuration(float fDuration) +{ + mDuration = fDuration; +} + +const char* CCBSequence::getName() +{ + return mName.c_str(); +} + +void CCBSequence::setName(const char *pName) +{ + mName = pName; +} + +int CCBSequence::getSequenceId() +{ + return mSequenceId; +} + +void CCBSequence::setSequenceId(int nSequenceId) +{ + mSequenceId = nSequenceId; +} + +int CCBSequence::getChainedSequenceId() +{ + return mChainedSequenceId; +} + +void CCBSequence::setChainedSequenceId(int nChainedSequenceId) +{ + mChainedSequenceId = nChainedSequenceId; +} + +NS_CC_EXT_END \ No newline at end of file diff --git a/extensions/CCBReader/CCBSequence.h b/extensions/CCBReader/CCBSequence.h new file mode 100644 index 0000000000..55a4a8013a --- /dev/null +++ b/extensions/CCBReader/CCBSequence.h @@ -0,0 +1,37 @@ +#ifndef __CCB_CCSEQUENCE_H__ +#define __CCB_CCSEQUENCE_H__ + +#include "cocos-ext.h" +#include + +NS_CC_EXT_BEGIN + +class CCBSequence : public cocos2d::CCObject +{ +private: + float mDuration; + std::string mName; + int mSequenceId; + int mChainedSequenceId; + +public: + CCBSequence(); + + float getDuration(); + void setDuration(float fDuration); + + const char* getName(); + void setName(const char *pName); + + int getSequenceId(); + void setSequenceId(int nSequenceId); + + int getChainedSequenceId(); + void setChainedSequenceId(int nChainedSequenceId); +}; + + +NS_CC_EXT_END + + +#endif // __CCB_CCSEQUENCE_H__ diff --git a/extensions/CCBReader/CCBSequenceProperty.cpp b/extensions/CCBReader/CCBSequenceProperty.cpp new file mode 100644 index 0000000000..956b6d9410 --- /dev/null +++ b/extensions/CCBReader/CCBSequenceProperty.cpp @@ -0,0 +1,52 @@ +#include "CCBSequenceProperty.h" + +using namespace cocos2d; +using namespace std; + +NS_CC_EXT_BEGIN + +CCBSequenceProperty::CCBSequenceProperty() +: mName("") +, mType(0) +{ + init(); +} + +bool CCBSequenceProperty::init() +{ + mKeyframes = new CCArray(); + + return true; +} + +CCBSequenceProperty::~CCBSequenceProperty() +{ + CC_SAFE_RELEASE_NULL(mKeyframes); +} + +const char* CCBSequenceProperty::getName() +{ + return mName.c_str(); +} + +void CCBSequenceProperty::setName(const char *pName) +{ + mName = pName; +} + +int CCBSequenceProperty::getType() +{ + return mType; +} + +void CCBSequenceProperty::setType(int nType) +{ + mType = nType; +} + +CCArray* CCBSequenceProperty::getKeyframes() +{ + return mKeyframes; +} + +NS_CC_EXT_END diff --git a/extensions/CCBReader/CCBSequenceProperty.h b/extensions/CCBReader/CCBSequenceProperty.h new file mode 100644 index 0000000000..4e790eeff4 --- /dev/null +++ b/extensions/CCBReader/CCBSequenceProperty.h @@ -0,0 +1,34 @@ +#ifndef __CCB_SEQUENCE_PROPERTY_H__ +#define __CCB_SEQUENCE_PROPERTY_H__ + +#include "cocos2d.h" +#include "ExtensionMacros.h" +#include "CCBKeyframe.h" + +NS_CC_EXT_BEGIN + +class CCBSequenceProperty : public cocos2d::CCObject +{ +private: + std::string mName; + int mType; + CCArray *mKeyframes; + +public: + CCBSequenceProperty(); + ~CCBSequenceProperty(); + + virtual bool init(); + + const char* getName(); + void setName(const char* pName); + + int getType(); + void setType(int nType); + + CCArray* getKeyframes(); +}; + +NS_CC_EXT_END + +#endif // __CCB_SEQUENCE_PROPERTY_H__ diff --git a/extensions/CCBReader/CCBValue.cpp b/extensions/CCBReader/CCBValue.cpp new file mode 100644 index 0000000000..a4a72ad9f8 --- /dev/null +++ b/extensions/CCBReader/CCBValue.cpp @@ -0,0 +1,132 @@ +#include "CCBValue.h" + +using namespace cocos2d; + +NS_CC_EXT_BEGIN + +// Implementation of ccColor3BWapper + +ccColor3BWapper* ccColor3BWapper::create(const cocos2d::ccColor3B& color) +{ + ccColor3BWapper *ret = new ccColor3BWapper(); + if (ret) + { + ret->color.r = color.r; + ret->color.g = color.g; + ret->color.b = color.b; + + ret->autorelease(); + } + + return ret; +} + +const ccColor3B& ccColor3BWapper::getColor() +{ + return color; +} + +// Implementation of CCBValue + +CCBValue* CCBValue::create(int nValue) +{ + CCBValue *ret = new CCBValue(); + if (ret) + { + ret->mValue.nValue = nValue; + ret->mType = kIntValue; + ret->autorelease(); + } + + return ret; +} + +CCBValue* CCBValue::create(float fValue) +{ + CCBValue *ret = new CCBValue(); + if (ret) + { + ret->mValue.fValue = fValue; + ret->mType = kFloatValue; + ret->autorelease(); + } + + return ret; +} + +CCBValue* CCBValue::create(bool vValue) +{ + CCBValue *ret = new CCBValue(); + if (ret) + { + ret->mValue.nValue = vValue ? 1 : 0; + ret->mType = kBoolValue; + ret->autorelease(); + } + + return ret; +} + +CCBValue* CCBValue::create(unsigned char byte) +{ + CCBValue *ret = new CCBValue(); + if (ret) + { + ret->mValue.nValue = byte; + ret->mType = kUnsignedCharValue; + ret->autorelease(); + } + + return ret; +} + +CCBValue* CCBValue::create(const void *pPointer) +{ + CCBValue *ret = new CCBValue(); + if (ret) + { + ret->mValue.pointer = pPointer; + ret->mType = kPointerValue; + ret->autorelease(); + } + + return ret; +} + +int CCBValue::getIntValue() +{ + CCLog("type is %d", mType); + assert(mType == kIntValue); + + return mValue.nValue; +} + +float CCBValue::getFloatValue() +{ + assert(mType == kFloatValue); + + return mValue.fValue; +} + +bool CCBValue::getBoolValue() +{ + assert(mType == kBoolValue); + + return mValue.nValue == 1 ? true : false; +} + +unsigned char CCBValue::getByteValue() +{ + assert(mType = kUnsignedCharValue); + + return (unsigned char)(mValue.nValue); +} + +const void* CCBValue::getPointer() +{ + assert(mType == kPointerValue); + + return mValue.pointer; +} + +NS_CC_EXT_END diff --git a/extensions/CCBReader/CCBValue.h b/extensions/CCBReader/CCBValue.h new file mode 100644 index 0000000000..2e760eb765 --- /dev/null +++ b/extensions/CCBReader/CCBValue.h @@ -0,0 +1,61 @@ +#ifndef __CCB_VALUE_H__ +#define __CCB_VALUE_H__ + +#include "cocos2d.h" +#include "ExtensionMacros.h" + +/* + These classes are wrapper of basic types, such as ccColor3B + */ + +NS_CC_EXT_BEGIN + +class ccColor3BWapper : public cocos2d::CCObject +{ +private: + cocos2d::ccColor3B color; + +public: + static ccColor3BWapper* create(const cocos2d::ccColor3B& color); + + const cocos2d::ccColor3B& getColor(); +}; + +enum +{ + kIntValue, + kFloatValue, + kPointerValue, + kBoolValue, + kUnsignedCharValue, +}; + +class CCBValue : public cocos2d::CCObject +{ +private: + union + { + int nValue; + float fValue; + const void *pointer; + } mValue; + + int mType; + +public: + static CCBValue* create(int nValue); + static CCBValue* create(bool bValue); + static CCBValue* create(float fValue); + static CCBValue* create(unsigned char byte); + static CCBValue* create(const void *pPointer); + + int getIntValue(); + float getFloatValue(); + bool getBoolValue(); + unsigned char getByteValue(); + const void* getPointer(); +}; + +NS_CC_EXT_END + +#endif // __CCB_VALUE_H__ diff --git a/extensions/CCBReader/CCControlButtonLoader.cpp b/extensions/CCBReader/CCControlButtonLoader.cpp index 821cd51d2e..4c439cbed0 100644 --- a/extensions/CCBReader/CCControlButtonLoader.cpp +++ b/extensions/CCBReader/CCControlButtonLoader.cpp @@ -6,21 +6,21 @@ NS_CC_EXT_BEGIN; #define PROPERTY_ZOOMONTOUCHDOWN "zoomOnTouchDown" #define PROPERTY_TITLE_NORMAL "title|1" #define PROPERTY_TITLE_HIGHLIGHTED "title|2" -#define PROPERTY_TITLE_DISABLED "title|4" +#define PROPERTY_TITLE_DISABLED "title|3" #define PROPERTY_TITLECOLOR_NORMAL "titleColor|1" #define PROPERTY_TITLECOLOR_HIGHLIGHTED "titleColor|2" -#define PROPERTY_TITLECOLOR_DISABLED "titleColor|4" +#define PROPERTY_TITLECOLOR_DISABLED "titleColor|3" #define PROPERTY_TITLETTF_NORMAL "titleTTF|1" #define PROPERTY_TITLETTF_HIGHLIGHTED "titleTTF|2" -#define PROPERTY_TITLETTF_DISABLED "titleTTF|4" +#define PROPERTY_TITLETTF_DISABLED "titleTTF|3" #define PROPERTY_TITLETTFSIZE_NORMAL "titleTTFSize|1" #define PROPERTY_TITLETTFSIZE_HIGHLIGHTED "titleTTFSize|2" -#define PROPERTY_TITLETTFSIZE_DISABLED "titleTTFSize|4" +#define PROPERTY_TITLETTFSIZE_DISABLED "titleTTFSize|3" #define PROPERTY_LABELANCHORPOINT "labelAnchorPoint" #define PROPERTY_PREFEREDSIZE "preferedSize" // TODO Should be "preferredSize". This is a typo in cocos2d-iphone, cocos2d-x and CocosBuilder! #define PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL "backgroundSpriteFrame|1" #define PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED "backgroundSpriteFrame|2" -#define PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED "backgroundSpriteFrame|4" +#define PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED "backgroundSpriteFrame|3" void CCControlButtonLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader) { if(pPropertyName->compare(PROPERTY_ZOOMONTOUCHDOWN) == 0) { diff --git a/extensions/CCBReader/CCData.cpp b/extensions/CCBReader/CCData.cpp new file mode 100644 index 0000000000..92d0402402 --- /dev/null +++ b/extensions/CCBReader/CCData.cpp @@ -0,0 +1,27 @@ +#include "CCData.h" + +NS_CC_EXT_BEGIN + +CCData::CCData(unsigned char *pBytes, const unsigned long nSize) +: m_pBytes(pBytes) +, m_nSize(nSize) +{} + +CCData::CCData(CCData *pData) +{ + m_nSize = pData->m_nSize; + m_pBytes = new unsigned char[m_nSize]; + memcpy(m_pBytes, pData->m_pBytes, m_nSize); +} + +CCData::~CCData() +{ + CC_SAFE_DELETE_ARRAY(m_pBytes); +} + +unsigned char* CCData::getBytes() +{ + return m_pBytes; +} + +NS_CC_EXT_END diff --git a/extensions/CCBReader/CCData.h b/extensions/CCBReader/CCData.h new file mode 100644 index 0000000000..68814ca7be --- /dev/null +++ b/extensions/CCBReader/CCData.h @@ -0,0 +1,26 @@ + +#ifndef __CCB_CCDATA_H__ +#define __CCB_CCDATA_H__ + +#include "cocos2d.h" +#include "cocos-ext.h" + +NS_CC_EXT_BEGIN + +class CCData : public cocos2d::CCObject +{ +public: + CCData(unsigned char *pBytes, const unsigned long nSize); + CCData(CCData *pData); + ~CCData(); + + unsigned char* getBytes(); + +private: + unsigned char* m_pBytes; + unsigned long m_nSize; +}; + +NS_CC_EXT_END + +#endif // __CCB_CCDATA_H__ diff --git a/extensions/CCBReader/CCNode+CCBRelativePositioning.cpp b/extensions/CCBReader/CCNode+CCBRelativePositioning.cpp new file mode 100644 index 0000000000..ddfc9a1976 --- /dev/null +++ b/extensions/CCBReader/CCNode+CCBRelativePositioning.cpp @@ -0,0 +1,62 @@ +#include "CCNode+CCBRelativePositioning.h" +#include "CCBReader.h" + +using namespace cocos2d; + +NS_CC_EXT_BEGIN + +CCPoint getAbsolutePosition(const CCPoint &pt, int nType, const CCSize &containerSize, const char *pPropName) +{ + CCPoint absPt = ccp(0,0); + if (nType == kCCBPositionTypeRelativeBottomLeft) + { + absPt = pt; + } + else if (nType == kCCBPositionTypeRelativeTopLeft) + { + absPt.x = pt.x; + absPt.y = containerSize.height - pt.y; + } + else if (nType == kCCBPositionTypeRelativeTopRight) + { + absPt.x = containerSize.width - pt.x; + absPt.y = containerSize.height - pt.y; + } + else if (nType == kCCBPositionTypeRelativeBottomRight) + { + absPt.x = containerSize.width - pt.x; + absPt.y = pt.y; + } + else if (nType == kCCBPositionTypePercent) + { + absPt.x = (int)(containerSize.width * pt.x / 100.0f); + absPt.y = (int)(containerSize.height * pt.y / 100.0f); + } + else if (nType == kCCBPositionTypeMultiplyResolution) + { + float resolutionScale = CCBReader::getResolutionScale(); + + absPt.x = pt.x * resolutionScale; + absPt.y = pt.y * resolutionScale; + } + + return absPt; +} + +void setRelativeScale(CCNode *pNode, float fScaleX, float fScaleY, int nType, const char* pPropName) +{ + CCAssert(pNode, "pNode should not be null"); + + if (nType == kCCBScaleTypeMultiplyResolution) + { + float resolutionScale = CCBReader::getResolutionScale(); + + fScaleX *= resolutionScale; + fScaleY *= resolutionScale; + } + + pNode->setScaleX(fScaleX); + pNode->setScaleY(fScaleY); +} + +NS_CC_EXT_END diff --git a/extensions/CCBReader/CCNode+CCBRelativePositioning.h b/extensions/CCBReader/CCNode+CCBRelativePositioning.h new file mode 100644 index 0000000000..066fb6202c --- /dev/null +++ b/extensions/CCBReader/CCNode+CCBRelativePositioning.h @@ -0,0 +1,15 @@ +#ifndef __CCB_CCNODE_RELATIVEPOSITIONING_H__ +#define __CCB_CCNODE_RELATIVEPOSITIONING_H__ + +#include "cocos2d.h" +#include "ExtensionMacros.h" + +NS_CC_EXT_BEGIN + +extern cocos2d::CCPoint getAbsolutePosition(const cocos2d::CCPoint &pt, int nType, const cocos2d::CCSize &containerSize, const char *pPropName); + +extern void setRelativeScale(cocos2d::CCNode *pNode, float fScaleX, float fScaleY, int nType, const char* pPropName); + +NS_CC_EXT_END + +#endif // __CCB_CCNODE_RELATIVEPOSITIONING_H__ diff --git a/extensions/CCBReader/CCNodeLoader.cpp b/extensions/CCBReader/CCNodeLoader.cpp index 01c4b7d0f8..227798f697 100644 --- a/extensions/CCBReader/CCNodeLoader.cpp +++ b/extensions/CCBReader/CCNodeLoader.cpp @@ -1,6 +1,10 @@ #include "CCNodeLoader.h" #include "CCBSelectorResolver.h" #include "CCBMemberVariableAssigner.h" +#include "CCBAnimationManager.h" +#include "CCData.h" + +using namespace std; USING_NS_CC; @@ -9,14 +13,18 @@ NS_CC_EXT_BEGIN CCNode * CCNodeLoader::loadCCNode(CCNode * pParent, CCBReader * pCCBReader) { CCNode * ccNode = this->createCCNode(pParent, pCCBReader); - this->parseProperties(ccNode, pParent, pCCBReader); + //this->parseProperties(ccNode, pParent, pCCBReader); return ccNode; } void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - int propertyCount = pCCBReader->readInt(false); + int numRegularProps = pCCBReader->readInt(false); + int numExturaProps = pCCBReader->readInt(false); + int propertyCount = numRegularProps + numExturaProps; + for(int i = 0; i < propertyCount; i++) { + bool isExtraProp = (i >= numRegularProps); int type = pCCBReader->readInt(false); CCString * propertyName = pCCBReader->readCachedString(); @@ -24,37 +32,72 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * bool setProp = false; int platform = pCCBReader->readByte(); - if(platform == kCCBPlatformAll) { + if(platform == kCCBPlatformAll) + { setProp = true; } #ifdef __CC_PLATFORM_IOS - if(platform == kCCBPlatformIOS) { + if(platform == kCCBPlatformIOS) + { setProp = true; } #elif defined(__CC_PLATFORM_MAC) - if(platform == kCCBPlatformMac) { + if(platform == kCCBPlatformMac) + { setProp = true; } #endif + + // Forward properties for sub ccb files + if (dynamic_cast(pNode) != NULL) + { + CCBFile *ccbNode = (CCBFile*)pNode; + if (ccbNode->getCCBFileNode() && isExtraProp) + { + pNode = ccbNode->getCCBFileNode(); + + // Skip properties that doesn't have a value to override + CCArray *extraPropsNames = (CCArray*)pNode->getUserObject(); + setProp &= extraPropsNames->containsObject(propertyName); + } + } + else if (isExtraProp && pNode == pCCBReader->getAnimationManager()->getRootNode()) + { + CCArray *extraPropsNames = (CCArray*)pNode->getUserObject(); + if (! extraPropsNames) + { + extraPropsNames = CCArray::create(); + pNode->setUserObject(extraPropsNames); + } + + extraPropsNames->addObject(propertyName); + } - switch(type) { - case kCCBPropTypePosition: { - CCPoint position = this->parsePropTypePosition(pNode, pParent, pCCBReader); - if(setProp) { + switch(type) + { + case kCCBPropTypePosition: + { + CCPoint position = this->parsePropTypePosition(pNode, pParent, pCCBReader, propertyName->getCString()); + if (setProp) + { this->onHandlePropTypePosition(pNode, pParent, propertyName, position, pCCBReader); } break; } - case kCCBPropTypePoint: { + case kCCBPropTypePoint: + { CCPoint point = this->parsePropTypePoint(pNode, pParent, pCCBReader); - if(setProp) { + if (setProp) + { this->onHandlePropTypePoint(pNode, pParent, propertyName, point, pCCBReader); } break; } - case kCCBPropTypePointLock: { + case kCCBPropTypePointLock: + { CCPoint pointLock = this->parsePropTypePointLock(pNode, pParent, pCCBReader); - if(setProp) { + if (setProp) + { this->onHandlePropTypePointLock(pNode, pParent, propertyName, pointLock, pCCBReader); } break; @@ -66,102 +109,129 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * } break; } - case kCCBPropTypeScaleLock: { - float * scaleLock = this->parsePropTypeScaleLock(pNode, pParent, pCCBReader); - if(setProp) { + case kCCBPropTypeScaleLock: + { + float * scaleLock = this->parsePropTypeScaleLock(pNode, pParent, pCCBReader, propertyName->getCString()); + if(setProp) + { this->onHandlePropTypeScaleLock(pNode, pParent, propertyName, scaleLock, pCCBReader); } CC_SAFE_DELETE_ARRAY(scaleLock); break; } - case kCCBPropTypeFloat: { + case kCCBPropTypeFloat: + { float f = this->parsePropTypeFloat(pNode, pParent, pCCBReader); - if(setProp) { + if(setProp) + { this->onHandlePropTypeFloat(pNode, pParent, propertyName, f, pCCBReader); } break; } - case kCCBPropTypeDegrees: { - float degrees = this->parsePropTypeDegrees(pNode, pParent, pCCBReader); - if(setProp) { + case kCCBPropTypeDegrees: + { + float degrees = this->parsePropTypeDegrees(pNode, pParent, pCCBReader, propertyName->getCString()); + if(setProp) + { this->onHandlePropTypeDegrees(pNode, pParent, propertyName, degrees, pCCBReader); } break; } - case kCCBPropTypeFloatScale: { + case kCCBPropTypeFloatScale: + { float floatScale = this->parsePropTypeFloatScale(pNode, pParent, pCCBReader); - if(setProp) { + if(setProp) + { this->onHandlePropTypeFloatScale(pNode, pParent, propertyName, floatScale, pCCBReader); } break; } - case kCCBPropTypeInteger: { + case kCCBPropTypeInteger: + { int integer = this->parsePropTypeInteger(pNode, pParent, pCCBReader); - if(setProp) { + if(setProp) + { this->onHandlePropTypeInteger(pNode, pParent, propertyName, integer, pCCBReader); } break; } - case kCCBPropTypeIntegerLabeled: { + case kCCBPropTypeIntegerLabeled: + { int integerLabeled = this->parsePropTypeIntegerLabeled(pNode, pParent, pCCBReader); - if(setProp) { + if(setProp) + { this->onHandlePropTypeIntegerLabeled(pNode, pParent, propertyName, integerLabeled, pCCBReader); } break; } - case kCCBPropTypeFloatVar: { + case kCCBPropTypeFloatVar: + { float * floatVar = this->parsePropTypeFloatVar(pNode, pParent, pCCBReader); - if(setProp) { + if(setProp) + { this->onHandlePropTypeFloatVar(pNode, pParent, propertyName, floatVar, pCCBReader); } CC_SAFE_DELETE_ARRAY(floatVar); break; } - case kCCBPropTypeCheck: { - bool check = this->parsePropTypeCheck(pNode, pParent, pCCBReader); - if(setProp) { + case kCCBPropTypeCheck: + { + bool check = this->parsePropTypeCheck(pNode, pParent, pCCBReader, propertyName->getCString()); + if(setProp) + { this->onHandlePropTypeCheck(pNode, pParent, propertyName, check, pCCBReader); } break; } case kCCBPropTypeSpriteFrame: { - CCSpriteFrame * ccSpriteFrame = this->parsePropTypeSpriteFrame(pNode, pParent, pCCBReader); - if(setProp) { + CCSpriteFrame * ccSpriteFrame = this->parsePropTypeSpriteFrame(pNode, pParent, pCCBReader, propertyName->getCString()); + if(setProp) + { this->onHandlePropTypeSpriteFrame(pNode, pParent, propertyName, ccSpriteFrame, pCCBReader); } break; } - case kCCBPropTypeAnimation: { + case kCCBPropTypeAnimation: + { CCAnimation * ccAnimation = this->parsePropTypeAnimation(pNode, pParent, pCCBReader); - if(setProp) { + if(setProp) + { this->onHandlePropTypeAnimation(pNode, pParent, propertyName, ccAnimation, pCCBReader); } break; } - case kCCBPropTypeTexture: { + case kCCBPropTypeTexture: + { CCTexture2D * ccTexture2D = this->parsePropTypeTexture(pNode, pParent, pCCBReader); - if(setProp) { + if(setProp) + { this->onHandlePropTypeTexture(pNode, pParent, propertyName, ccTexture2D, pCCBReader); } break; } - case kCCBPropTypeByte: { - unsigned char byte = this->parsePropTypeByte(pNode, pParent, pCCBReader); - if(setProp) { + case kCCBPropTypeByte: + { + unsigned char byte = this->parsePropTypeByte(pNode, pParent, pCCBReader, propertyName->getCString()); + if(setProp) + { this->onHandlePropTypeByte(pNode, pParent, propertyName, byte, pCCBReader); } break; } - case kCCBPropTypeColor3: { - ccColor3B color3B = this->parsePropTypeColor3(pNode, pParent, pCCBReader); - if(setProp) { + case kCCBPropTypeColor3: + { + ccColor3B color3B = this->parsePropTypeColor3(pNode, pParent, pCCBReader, propertyName->getCString()); + if(setProp) + { this->onHandlePropTypeColor3(pNode, pParent, propertyName, color3B, pCCBReader); } break; } - case kCCBPropTypeColor4FVar: { + case kCCBPropTypeColor4FVar: + { ccColor4F * color4FVar = this->parsePropTypeColor4FVar(pNode, pParent, pCCBReader); - if(setProp) { + if(setProp) + { this->onHandlePropTypeColor4FVar(pNode, pParent, propertyName, color4FVar, pCCBReader); } CC_SAFE_DELETE_ARRAY(color4FVar); @@ -175,16 +245,20 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * CC_SAFE_DELETE_ARRAY(flip); break; } - case kCCBPropTypeBlendFunc: { + case kCCBPropTypeBlendmode: + { ccBlendFunc blendFunc = this->parsePropTypeBlendFunc(pNode, pParent, pCCBReader); - if(setProp) { + if(setProp) + { this->onHandlePropTypeBlendFunc(pNode, pParent, propertyName, blendFunc, pCCBReader); } break; } - case kCCBPropTypeFntFile: { + case kCCBPropTypeFntFile: + { CCString * fntFile = this->parsePropTypeFntFile(pNode, pParent, pCCBReader); - if(setProp) { + if(setProp) + { this->onHandlePropTypeFntFile(pNode, pParent, propertyName, fntFile, pCCBReader); } break; @@ -240,43 +314,64 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * } } -CCPoint CCNodeLoader::parsePropTypePosition(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { +CCPoint CCNodeLoader::parsePropTypePosition(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName) { float x = pCCBReader->readFloat(); float y = pCCBReader->readFloat(); int type = pCCBReader->readInt(false); - CCSize containerSize = pCCBReader->getContainerSize(pParent); + CCSize containerSize = pCCBReader->getAnimationManager()->getContainerSize(pParent); - switch (type) { - case kCCBPositionTypeRelativeBottomLeft: { + switch (type) + { + case kCCBPositionTypeRelativeBottomLeft: + { /* Nothing. */ break; } - case kCCBPositionTypeRelativeTopLeft: { + case kCCBPositionTypeRelativeTopLeft: + { y = containerSize.height - y; break; } - case kCCBPositionTypeRelativeTopRight: { + case kCCBPositionTypeRelativeTopRight: + { x = containerSize.width - x; y = containerSize.height - y; break; } - case kCCBPositionTypeRelativeBottomRight: { + case kCCBPositionTypeRelativeBottomRight: + { x = containerSize.width - x; break; } - case kCCBPositionTypePercent: { + case kCCBPositionTypePercent: + { x = (int)(containerSize.width * x / 100.0f); y = (int)(containerSize.height * y / 100.0f); break; } + case kCCBPositionTypeMultiplyResolution: + { + x *= CCBReader::getResolutionScale(); + y *= CCBReader::getResolutionScale(); + } + } + + if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end()) + { + CCArray *baseValue = CCArray::create(CCBValue::create(x), + CCBValue::create(y), + CCBValue::create(type), + NULL); + pCCBReader->getAnimationManager()->setBaseValue(baseValue, pNode, pPropertyName); } return CCPoint(x, y); } -CCPoint CCNodeLoader::parsePropTypePoint(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { +CCPoint CCNodeLoader::parsePropTypePoint(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) +{ float x = pCCBReader->readFloat(); float y = pCCBReader->readFloat(); @@ -296,31 +391,44 @@ CCSize CCNodeLoader::parsePropTypeSize(CCNode * pNode, CCNode * pParent, CCBRead int type = pCCBReader->readInt(false); - CCSize containerSize = pCCBReader->getContainerSize(pParent); + CCSize containerSize = pCCBReader->getAnimationManager()->getContainerSize(pParent); - switch (type) { - case kCCBSizeTypeAbsolute: { + switch (type) + { + case kCCBSizeTypeAbsolute: + { /* Nothing. */ break; } - case kCCBSizeTypeRelativeContainer: { + case kCCBSizeTypeRelativeContainer: + { width = containerSize.width - width; height = containerSize.height - height; break; } - case kCCBSizeTypePercent: { + case kCCBSizeTypePercent: + { width = (int)(containerSize.width * width / 100.0f); height = (int)(containerSize.height * height / 100.0f); break; } - case kCCBSizeTypeHorizontalPercent: { + case kCCBSizeTypeHorizontalPercent: + { width = (int)(containerSize.width * width / 100.0f); break; } - case kCCBSzieTypeVerticalPercent: { + case kCCBSizeTypeVerticalPercent: + { height = (int)(containerSize.height * height / 100.0f); break; } + case kCCBSizeTypeMultiplyResolution: + { + float resolutionScale = CCBReader::getResolutionScale(); + + width *= resolutionScale; + height *= resolutionScale; + } default: break; } @@ -328,13 +436,14 @@ CCSize CCNodeLoader::parsePropTypeSize(CCNode * pNode, CCNode * pParent, CCBRead return CCSize(width, height); } -float * CCNodeLoader::parsePropTypeScaleLock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { +float * CCNodeLoader::parsePropTypeScaleLock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName) { float x = pCCBReader->readFloat(); float y = pCCBReader->readFloat(); int type = pCCBReader->readInt(false); - if(type == kCCBScaleTypeMultiplyResolution) { + if (type == kCCBScaleTypeMultiplyResolution) + { x *= pCCBReader->getResolutionScale(); y *= pCCBReader->getResolutionScale(); } @@ -342,6 +451,15 @@ float * CCNodeLoader::parsePropTypeScaleLock(CCNode * pNode, CCNode * pParent, C float * scaleLock = new float[2]; scaleLock[0] = x; scaleLock[1] = y; + + if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end()) + { + CCArray *baseValue = CCArray::create(CCBValue::create(x), + CCBValue::create(y), + CCBValue::create(type), + NULL); + pCCBReader->getAnimationManager()->setBaseValue(baseValue, pNode, pPropertyName); + } return scaleLock; } @@ -350,31 +468,43 @@ float CCNodeLoader::parsePropTypeFloat(CCNode * pNode, CCNode * pParent, CCBRead return pCCBReader->readFloat(); } -float CCNodeLoader::parsePropTypeDegrees(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - return pCCBReader->readFloat(); +float CCNodeLoader::parsePropTypeDegrees(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName) { + float ret = pCCBReader->readFloat(); + if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end()) + { + CCBValue *value = CCBValue::create(ret); + pCCBReader->getAnimationManager()->setBaseValue(value, pNode, pPropertyName); + } + + return ret; } -float CCNodeLoader::parsePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { +float CCNodeLoader::parsePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) +{ float f = pCCBReader->readFloat(); int type = pCCBReader->readInt(false); - if(type == kCCBScaleTypeMultiplyResolution) { + if(type == kCCBScaleTypeMultiplyResolution) + { f *= pCCBReader->getResolutionScale(); } return f; } -int CCNodeLoader::parsePropTypeInteger(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { +int CCNodeLoader::parsePropTypeInteger(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) +{ return pCCBReader->readInt(true); } -int CCNodeLoader::parsePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { +int CCNodeLoader::parsePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) +{ return pCCBReader->readInt(true); } -float * CCNodeLoader::parsePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { +float * CCNodeLoader::parsePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) +{ float f = pCCBReader->readFloat(); float fVar = pCCBReader->readFloat(); @@ -385,39 +515,57 @@ float * CCNodeLoader::parsePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CC return arr; } -bool CCNodeLoader::parsePropTypeCheck(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - return pCCBReader->readBool(); +bool CCNodeLoader::parsePropTypeCheck(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName) +{ + bool ret = pCCBReader->readBool(); + + if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end()) + { + CCBValue *value = CCBValue::create(ret); + pCCBReader->getAnimationManager()->setBaseValue(value, pNode, pPropertyName); + } + + return ret; } -CCSpriteFrame * CCNodeLoader::parsePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { +CCSpriteFrame * CCNodeLoader::parsePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName) +{ CCString * spriteSheet = pCCBReader->readCachedString(); CCString * spriteFile = pCCBReader->readCachedString(); - CCSpriteFrame * spriteFrame; - if(spriteSheet == NULL || spriteSheet->length() == 0) { - if(spriteFile == NULL || spriteFile->length() == 0) { - return NULL; + CCLog("sprite file %s", spriteFile->getCString()); + CCLog("sprite sheet %s", spriteSheet->getCString()); + + CCSpriteFrame *spriteFrame = NULL; + if (spriteFile->length() != 0) + { + if (spriteSheet->length() == 0) + { + CCTexture2D * texture = CCTextureCache::sharedTextureCache()->addImage(spriteFile->getCString()); + CCRect bounds = CCRectMake(0, 0, texture->getContentSize().width, texture->getContentSize().height); + spriteFrame = CCSpriteFrame::createWithTexture(texture, bounds); } - - CCString * spriteFilePath = CCBReader::concat(pCCBReader->getCCBRootPath(), spriteFile); - - CCTexture2D * texture = CCTextureCache::sharedTextureCache()->addImage(spriteFilePath->getCString()); - CCRect bounds = CCRectMake(0, 0, texture->getContentSize().width, texture->getContentSize().height); - spriteFrame = CCSpriteFrame::createWithTexture(texture, bounds); - } else { - CCSpriteFrameCache * frameCache = CCSpriteFrameCache::sharedSpriteFrameCache(); - - CCString * spriteSheetPath = CCBReader::concat(pCCBReader->getCCBRootPath(), spriteSheet); - - /* Load the sprite sheet only if it is not loaded. */ - if(!pCCBReader->isSpriteSheetLoaded(spriteSheetPath)) { - frameCache->addSpriteFramesWithFile(spriteSheetPath->getCString()); - pCCBReader->addLoadedSpriteSheet(spriteSheetPath); + else + { + CCSpriteFrameCache * frameCache = CCSpriteFrameCache::sharedSpriteFrameCache(); + + // Load the sprite sheet only if it is not loaded + if (pCCBReader->getLoadedSpriteSheet().find(spriteSheet->getCString()) == pCCBReader->getLoadedSpriteSheet().end()) + { + frameCache->addSpriteFramesWithFile(spriteSheet->getCString()); + pCCBReader->getLoadedSpriteSheet().insert(spriteSheet->getCString()); + } + + spriteFrame = frameCache->spriteFrameByName(spriteFile->getCString()); } - spriteFrame = frameCache->spriteFrameByName(spriteFile->getCString()); + if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end()) + { + pCCBReader->getAnimationManager()->setBaseValue(spriteFrame, pNode, pPropertyName); + } } + return spriteFrame; } @@ -435,7 +583,8 @@ CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pPar animation = CCBReader::lastPathComponent(animation); animationFile = CCBReader::lastPathComponent(animationFile); - if(animation != NULL && animation->compare("") != 0) { + if (animation != NULL && animation->compare("") != 0) + { CCAnimationCache * animationCache = CCAnimationCache::sharedAnimationCache(); animationCache->addAnimationsWithFile(animationFile->getCString()); @@ -445,21 +594,41 @@ CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pPar } CCTexture2D * CCNodeLoader::parsePropTypeTexture(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - CCString * spriteFile = CCBReader::concat(pCCBReader->getCCBRootPath(), pCCBReader->readCachedString()); - - return CCTextureCache::sharedTextureCache()->addImage(spriteFile->getCString()); + CCString * spriteFile = pCCBReader->readCachedString(); + + if (spriteFile->compare("") != 0) + { + return CCTextureCache::sharedTextureCache()->addImage(spriteFile->getCString()); + } + else + { + return NULL; + } } -unsigned char CCNodeLoader::parsePropTypeByte(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - return pCCBReader->readByte(); +unsigned char CCNodeLoader::parsePropTypeByte(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName) +{ + unsigned char ret = pCCBReader->readByte(); + + if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end()) + { + pCCBReader->getAnimationManager()->setBaseValue(CCBValue::create(ret), pNode, pPropertyName); + } + + return ret; } -ccColor3B CCNodeLoader::parsePropTypeColor3(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { +ccColor3B CCNodeLoader::parsePropTypeColor3(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName) { unsigned char red = pCCBReader->readByte(); unsigned char green = pCCBReader->readByte(); unsigned char blue = pCCBReader->readByte(); ccColor3B color = { red, green, blue }; + if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end()) + { + ccColor3BWapper *value = ccColor3BWapper::create(color); + pCCBReader->getAnimationManager()->setBaseValue(value, pNode, pPropertyName); + } return color; } @@ -498,7 +667,8 @@ bool * CCNodeLoader::parsePropTypeFlip(CCNode * pNode, CCNode * pParent, CCBRead return arr; } -ccBlendFunc CCNodeLoader::parsePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { +ccBlendFunc CCNodeLoader::parsePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) +{ int source = pCCBReader->readInt(false); int destination = pCCBReader->readInt(false); @@ -509,10 +679,9 @@ ccBlendFunc CCNodeLoader::parsePropTypeBlendFunc(CCNode * pNode, CCNode * pParen return blendFunc; } -CCString * CCNodeLoader::parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - CCString * fntFile = pCCBReader->readCachedString(); - - return CCBReader::concat(pCCBReader->getCCBRootPath(), fntFile); +CCString * CCNodeLoader::parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) +{ + return pCCBReader->readCachedString(); } CCString * CCNodeLoader::parsePropTypeString(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { @@ -526,13 +695,16 @@ CCString * CCNodeLoader::parsePropTypeText(CCNode * pNode, CCNode * pParent, CCB CCString * CCNodeLoader::parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { CCString * fontTTF = pCCBReader->readCachedString(); - CCString * ttfEnding = CCString::create(".ttf"); + // CCString * ttfEnding = CCString::create(".ttf"); + // Fix me if it is wrong /* If the fontTTF comes with the ".ttf" extension, prepend the absolute path. * System fonts come without the ".ttf" extension and do not need the path prepended. */ + /* if(CCBReader::endsWith(CCBReader::toLowerCase(fontTTF), ttfEnding)){ fontTTF = CCBReader::concat(pCCBReader->getCCBRootPath(), fontTTF); } + */ return fontTTF; } @@ -544,7 +716,7 @@ BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, C if(selectorTarget != kCCBTargetTypeNone) { CCObject * target = NULL; if(selectorTarget == kCCBTargetTypeDocumentRoot) { - target = pCCBReader->getRootNode(); + target = pCCBReader->getAnimationManager()->getRootNode(); } else if(selectorTarget == kCCBTargetTypeOwner) { target = pCCBReader->getOwner(); } @@ -594,7 +766,7 @@ BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, C if(selectorTarget != kCCBTargetTypeNone) { CCObject * target = NULL; if(selectorTarget == kCCBTargetTypeDocumentRoot) { - target = pCCBReader->getRootNode(); + target = pCCBReader->getAnimationManager()->getRootNode(); } else if(selectorTarget == kCCBTargetTypeOwner) { target = pCCBReader->getOwner(); } @@ -642,13 +814,29 @@ CCNode * CCNodeLoader::parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CC /* Change path extension to .ccbi. */ CCString * ccbFileWithoutPathExtension = CCBReader::deletePathExtension(ccbFileName); - CCString * ccbiFileName = CCBReader::concat(ccbFileWithoutPathExtension, CCString::create(".ccbi")); - + ccbFileName = CCBReader::concat(ccbFileWithoutPathExtension, CCString::create(".ccbi")); + + // Load sub file + const char *path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(ccbFileName->getCString()); CCBReader * ccbReader = new CCBReader(pCCBReader); ccbReader->autorelease(); - CCNode * ccbFileNode = ccbReader->readNodeGraphFromFile(pCCBReader->getCCBRootPath(), ccbiFileName, pCCBReader->getOwner(), pParent->getContentSize()); + unsigned long size; + + unsigned char * pBytes = CCFileUtils::sharedFileUtils()->getFileData(path, "rb", &size); + CCData *data = new CCData(pBytes, size); + ccbReader->initWithData(data, pCCBReader->getOwner()); + data->release(); + ccbReader->getAnimationManager()->setRootContainerSize(pParent->getContentSize()); + CCNode * ccbFileNode = ccbReader->readFileWithCleanUp(false); + + if (ccbFileNode && ccbReader->getAnimationManager()->getAutoPlaySequenceId() != -1) + { + // Auto play animations + ccbReader->getAnimationManager()->runAnimations(ccbReader->getAnimationManager()->getAutoPlaySequenceId(), 0); + } + return ccbFileNode; } diff --git a/extensions/CCBReader/CCNodeLoader.h b/extensions/CCBReader/CCNodeLoader.h index 53d06bc1ea..175e96f0aa 100644 --- a/extensions/CCBReader/CCNodeLoader.h +++ b/extensions/CCBReader/CCNodeLoader.h @@ -50,23 +50,23 @@ class CCNodeLoader : public CCObject { protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCNode); - virtual CCPoint parsePropTypePosition(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual CCPoint parsePropTypePosition(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName); virtual CCPoint parsePropTypePoint(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual CCPoint parsePropTypePointLock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual CCSize parsePropTypeSize(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); - virtual float * parsePropTypeScaleLock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual float * parsePropTypeScaleLock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName); virtual float parsePropTypeFloat(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); - virtual float parsePropTypeDegrees(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual float parsePropTypeDegrees(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName); virtual float parsePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual int parsePropTypeInteger(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual int parsePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual float * parsePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); - virtual bool parsePropTypeCheck(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); - virtual CCSpriteFrame * parsePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual bool parsePropTypeCheck(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName); + virtual CCSpriteFrame * parsePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName); virtual CCAnimation * parsePropTypeAnimation(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual CCTexture2D * parsePropTypeTexture(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); - virtual unsigned char parsePropTypeByte(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); - virtual ccColor3B parsePropTypeColor3(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual unsigned char parsePropTypeByte(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName); + virtual ccColor3B parsePropTypeColor3(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName); virtual ccColor4F * parsePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual bool * parsePropTypeFlip(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual ccBlendFunc parsePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); diff --git a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp index 5f74e49ec7..66c0c4834b 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp +++ b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp @@ -37,10 +37,11 @@ void CocosBuilderTestScene::runThisTest() { /* Create an autorelease CCBReader. */ cocos2d::extension::CCBReader * ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary); - ccbReader->autorelease(); /* Read a ccbi file. */ - CCNode * node = ccbReader->readNodeGraphFromFile("ccb/official/pub/", "ccb/HelloCocosBuilder.ccbi", this); + CCNode * node = ccbReader->readNodeGraphFromFile("HelloCocosBuilder.ccbi", this); + + ccbReader->release(); if(node != NULL) { this->addChild(node); diff --git a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp index eda4e260c8..224f8ca466 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp +++ b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp @@ -26,7 +26,7 @@ void HelloCocosBuilderLayer::openTest(const char * pCCBFileName, const char * pC /* Create an autorelease CCNodeLoaderLibrary. */ CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary(); - ccNodeLoaderLibrary->registerCCNodeLoader("TestHeaderLayer", TestHeaderLayerLoader::loader()); + ccNodeLoaderLibrary->registerCCNodeLoader("TestHeader", TestHeaderLayerLoader::loader()); if(pCCNodeName != NULL && pCCNodeLoader != NULL) { ccNodeLoaderLibrary->registerCCNodeLoader(pCCNodeName, pCCNodeLoader); } @@ -40,7 +40,7 @@ void HelloCocosBuilderLayer::openTest(const char * pCCBFileName, const char * pC // the owner will cause lblTestTitle to be set by the CCBReader. // lblTestTitle is in the TestHeader.ccbi, which is referenced // from each of the test scenes. - CCNode * node = ccbReader->readNodeGraphFromFile("ccb/official/pub/", pCCBFileName, this); + CCNode * node = ccbReader->readNodeGraphFromFile(pCCBFileName, this); this->mTestTitleLabelTTF->setString(pCCBFileName); @@ -60,7 +60,7 @@ void HelloCocosBuilderLayer::openTest(const char * pCCBFileName, const char * pC void HelloCocosBuilderLayer::onNodeLoaded(cocos2d::CCNode * pNode, cocos2d::extension::CCNodeLoader * pNodeLoader) { - CCRotateBy * ccRotateBy = CCRotateBy::create(0.5f, 10); + CCRotateBy * ccRotateBy = CCRotateBy::create(20.0f, 360); CCRepeatForever * ccRepeatForever = CCRepeatForever::create(ccRotateBy); this->mBurstSprite->runAction(ccRepeatForever); } @@ -74,7 +74,7 @@ SEL_CCControlHandler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(CCObj CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onMenuTestClicked", HelloCocosBuilderLayer::onMenuTestClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onSpriteTestClicked", HelloCocosBuilderLayer::onSpriteTestClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onButtonTestClicked", HelloCocosBuilderLayer::onButtonTestClicked); - CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onLabelTestClicked", HelloCocosBuilderLayer::onLabelTestClicked); + //CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onLabelTestClicked", HelloCocosBuilderLayer::onLabelTestClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onParticleSystemTestClicked", HelloCocosBuilderLayer::onParticleSystemTestClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onScrollViewTestClicked", HelloCocosBuilderLayer::onScrollViewTestClicked); @@ -90,25 +90,25 @@ bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(CCObject * pTarget, CCStr void HelloCocosBuilderLayer::onMenuTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - this->openTest("ccb/MenuTest.ccbi", "MenuTestLayer", MenuTestLayerLoader::loader()); + this->openTest("TestMenus.ccbi", "TestMenus", MenuTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onSpriteTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - this->openTest("ccb/SpriteTest.ccbi", "SpriteTestLayer", SpriteTestLayerLoader::loader()); + this->openTest("TestSprites.ccbi", "TestSprites", SpriteTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onButtonTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - this->openTest("ccb/ButtonTest.ccbi", "ButtonTestLayer", ButtonTestLayerLoader::loader()); + this->openTest("TestButtons.ccbi", "TestButtons", ButtonTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onLabelTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - this->openTest("ccb/LabelTest.ccbi", "LabelTestLayer", LabelTestLayerLoader::loader()); + this->openTest("TestLabels.ccbi", "TestLabels", LabelTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onParticleSystemTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - this->openTest("ccb/ParticleSystemTest.ccbi", "ParticleSystemTestLayer", ParticleSystemTestLayerLoader::loader()); + this->openTest("TestParticleSystems.ccbi", "TestParticleSystems", ParticleSystemTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onScrollViewTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - this->openTest("ccb/ScrollViewTest.ccbi", "ScrollViewTestLayer", ScrollViewTestLayerLoader::loader()); + this->openTest("TestScrollViews.ccbi", "TestScrollViews", ScrollViewTestLayerLoader::loader()); } \ No newline at end of file diff --git a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h index 16920d8875..3f1a427f02 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h +++ b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h @@ -15,10 +15,10 @@ * http://www.cocoabuilder.com/archive/xcode/265549-crash-in-virtual-method-call.html */ class HelloCocosBuilderLayer - : public cocos2d::CCLayer - , public cocos2d::extension::CCBSelectorResolver +: public cocos2d::CCLayer +, public cocos2d::extension::CCBSelectorResolver , public cocos2d::extension::CCBMemberVariableAssigner - , public cocos2d::extension::CCNodeLoaderListener +, public cocos2d::extension::CCNodeLoaderListener { public: CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(HelloCocosBuilderLayer, create); diff --git a/samples/TestCpp/Resources/ccb/burst-hd.png.REMOVED.git-id b/samples/TestCpp/Resources/ccb/burst-hd.png.REMOVED.git-id new file mode 100644 index 0000000000..4b8037d9b8 --- /dev/null +++ b/samples/TestCpp/Resources/ccb/burst-hd.png.REMOVED.git-id @@ -0,0 +1 @@ +723ff604c8b83d6b1c5a72aea87e9c904fe6c699 \ No newline at end of file diff --git a/samples/TestCpp/Resources/ccb/burst-ipad.png.REMOVED.git-id b/samples/TestCpp/Resources/ccb/burst-ipad.png.REMOVED.git-id new file mode 100644 index 0000000000..4b8037d9b8 --- /dev/null +++ b/samples/TestCpp/Resources/ccb/burst-ipad.png.REMOVED.git-id @@ -0,0 +1 @@ +723ff604c8b83d6b1c5a72aea87e9c904fe6c699 \ No newline at end of file diff --git a/samples/TestCpp/Resources/ccb/official/pub/res/flower.jpg.REMOVED.git-id b/samples/TestCpp/Resources/ccb/flower.jpg.REMOVED.git-id similarity index 100% rename from samples/TestCpp/Resources/ccb/official/pub/res/flower.jpg.REMOVED.git-id rename to samples/TestCpp/Resources/ccb/flower.jpg.REMOVED.git-id diff --git a/samples/TestCpp/Resources/ccb/official/pub/res/markerfelt24shadow.fnt.REMOVED.git-id b/samples/TestCpp/Resources/ccb/markerfelt24shadow.fnt.REMOVED.git-id similarity index 100% rename from samples/TestCpp/Resources/ccb/official/pub/res/markerfelt24shadow.fnt.REMOVED.git-id rename to samples/TestCpp/Resources/ccb/markerfelt24shadow.fnt.REMOVED.git-id diff --git a/samples/TestCpp/Resources/ccb/official/src/res/flower.jpg.REMOVED.git-id b/samples/TestCpp/Resources/ccb/official/src/res/flower.jpg.REMOVED.git-id deleted file mode 100644 index 60dddf3fb7..0000000000 --- a/samples/TestCpp/Resources/ccb/official/src/res/flower.jpg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -38e3a5fabac55b5649842cb35930af7594f093ef \ No newline at end of file diff --git a/samples/TestCpp/Resources/ccb/official/src/res/markerfelt24shadow.fnt.REMOVED.git-id b/samples/TestCpp/Resources/ccb/official/src/res/markerfelt24shadow.fnt.REMOVED.git-id deleted file mode 100644 index 4b87d9cc98..0000000000 --- a/samples/TestCpp/Resources/ccb/official/src/res/markerfelt24shadow.fnt.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -2685fbcab626d939a8e2ea65b05a8a82beb90afa \ No newline at end of file diff --git a/samples/TestCpp/Resources/ccb/simple/pub/fonts/Droid.ttf.REMOVED.git-id b/samples/TestCpp/Resources/ccb/simple/pub/fonts/Droid.ttf.REMOVED.git-id deleted file mode 100644 index 8da6cbb3a0..0000000000 --- a/samples/TestCpp/Resources/ccb/simple/pub/fonts/Droid.ttf.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -197f4c7204f12af28120d3506524f0ac051b624d \ No newline at end of file diff --git a/samples/TestCpp/Resources/ccb/simple/src/fonts/Droid.ttf.REMOVED.git-id b/samples/TestCpp/Resources/ccb/simple/src/fonts/Droid.ttf.REMOVED.git-id deleted file mode 100644 index 8da6cbb3a0..0000000000 --- a/samples/TestCpp/Resources/ccb/simple/src/fonts/Droid.ttf.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -197f4c7204f12af28120d3506524f0ac051b624d \ No newline at end of file diff --git a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id index 5fc33334fb..fc5a9fd776 100644 --- a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -48422011360e4d8706df417f7061b830a3b9613a \ No newline at end of file +e2979d2a6cf37624621cb54dbfc8e84a9f5a3666 \ No newline at end of file From eba97a9b1efd824aa00213f904f724fc7c7900c0 Mon Sep 17 00:00:00 2001 From: dualface Date: Mon, 17 Sep 2012 14:40:42 +0800 Subject: [PATCH 030/181] [Lua] fix luabinding overloaded functions --- .../lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id | 2 +- tools/tolua++/CCAction.pkg | 6 +++--- tools/tolua++/CCActionTiledGrid.pkg | 2 +- tools/tolua++/CCAnimation.pkg | 2 +- tools/tolua++/CCFileUtils.pkg | 3 +-- tools/tolua++/CCLabelBMFont.pkg | 6 +++++- tools/tolua++/CCLabelTTF.pkg | 6 +++--- tools/tolua++/CCLayer.pkg | 2 +- tools/tolua++/CCMenuItem.pkg | 10 +++++----- tools/tolua++/CCParticleSystem.pkg | 2 +- tools/tolua++/CCSprite.pkg | 4 ++-- tools/tolua++/CCSpriteBatchNode.pkg | 2 +- tools/tolua++/CCSpriteFrame.pkg | 4 ++-- 13 files changed, 27 insertions(+), 24 deletions(-) diff --git a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index bc6ff70a17..3c867363b0 100644 --- a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -a27fd7b26a6f47a97de7ed9dc7f1dc202ccb638d \ No newline at end of file +d33790c08f03c11f8432a3bd2b9be537d00fa8c2 \ No newline at end of file diff --git a/tools/tolua++/CCAction.pkg b/tools/tolua++/CCAction.pkg index f87973a654..b52be8a8da 100644 --- a/tools/tolua++/CCAction.pkg +++ b/tools/tolua++/CCAction.pkg @@ -54,8 +54,8 @@ class CCFollow : public CCAction bool isDone(void); CCObject* copyWithZone(CCZone* pZone); - static CCFollow* create(CCNode *pFollowedNode); static CCFollow* create(CCNode *pFollowedNode, CCRect rect); + static CCFollow* create(CCNode *pFollowedNode); }; class CCSequence : public CCActionInterval @@ -90,8 +90,8 @@ class CCSpawn : public CCActionInterval CCObject* copyWithZone(CCZone* pZone); CCActionInterval* reverse(void); - static CCFiniteTimeAction* create(CCArray *actions); static CCFiniteTimeAction* createWithTwoActions(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2); + static CCFiniteTimeAction* create(CCArray *actions); }; class CCRotateTo : public CCActionInterval @@ -185,8 +185,8 @@ class CCScaleTo : public CCActionInterval { CCObject* copyWithZone(CCZone* pZone); - static CCScaleTo* create(float duration, float s); static CCScaleTo* create(float duration, float sx, float sy); + static CCScaleTo* create(float duration, float s); }; class CCScaleBy : public CCActionInterval diff --git a/tools/tolua++/CCActionTiledGrid.pkg b/tools/tolua++/CCActionTiledGrid.pkg index 48dc92f602..6da910c8af 100644 --- a/tools/tolua++/CCActionTiledGrid.pkg +++ b/tools/tolua++/CCActionTiledGrid.pkg @@ -58,8 +58,8 @@ class CCTurnOffTiles : public CCTiledGrid3DAction void turnOnTile(ccGridSize pos); void turnOffTile(ccGridSize pos); - static CCTurnOffTiles* create(ccGridSize size, float d); static CCTurnOffTiles* create(int s, ccGridSize gridSize, float duration); + static CCTurnOffTiles* create(ccGridSize size, float d); }; class CCWavesTiles3D : public CCTiledGrid3DAction diff --git a/tools/tolua++/CCAnimation.pkg b/tools/tolua++/CCAnimation.pkg index 7e6088119a..b5a3790872 100644 --- a/tools/tolua++/CCAnimation.pkg +++ b/tools/tolua++/CCAnimation.pkg @@ -22,8 +22,8 @@ class CCAnimation : public CCObject { static CCAnimation* create(CCArray *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops); static CCAnimation* create(void); - static CCAnimation* createWithSpriteFrames(CCArray* arrayOfSpriteFrameNames); static CCAnimation* createWithSpriteFrames(CCArray* arrayOfSpriteFrameNames, float delay); + static CCAnimation* createWithSpriteFrames(CCArray* arrayOfSpriteFrameNames); void addSpriteFrame(CCSpriteFrame *pFrame); void addSpriteFrameWithFileName(const char *pszFileName); diff --git a/tools/tolua++/CCFileUtils.pkg b/tools/tolua++/CCFileUtils.pkg index bca02e2e72..9c18120b04 100644 --- a/tools/tolua++/CCFileUtils.pkg +++ b/tools/tolua++/CCFileUtils.pkg @@ -4,7 +4,6 @@ class CCFileUtils static CCFileUtils* sharedFileUtils(); std::string getWriteablePath(); void setResourceDirectory(const char *pszDirectoryName); + const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile); const char* fullPathFromRelativePath(const char *pszRelativePath); - const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile); - const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile); }; diff --git a/tools/tolua++/CCLabelBMFont.pkg b/tools/tolua++/CCLabelBMFont.pkg index f2aeb918f8..7c7aca953b 100644 --- a/tools/tolua++/CCLabelBMFont.pkg +++ b/tools/tolua++/CCLabelBMFont.pkg @@ -1,4 +1,8 @@ +enum { + kCCLabelAutomaticWidth = -1, +}; + class CCLabelBMFont : public CCNode { void setString(const char *label); @@ -30,6 +34,6 @@ class CCLabelBMFont : public CCNode tolua_property__CCOpacity GLubyte opacity; static void purgeCachedData(); + static CCLabelBMFont * create(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointMake(0, 0)); static CCLabelBMFont * create(); - static CCLabelBMFont * create(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointMake(0, 0)); }; diff --git a/tools/tolua++/CCLabelTTF.pkg b/tools/tolua++/CCLabelTTF.pkg index 215b889ad8..2585628247 100644 --- a/tools/tolua++/CCLabelTTF.pkg +++ b/tools/tolua++/CCLabelTTF.pkg @@ -19,8 +19,8 @@ class CCLabelTTF : public CCSprite const char* getFontName(); void setFontName(const char *fontName); - static CCLabelTTF * create(); - static CCLabelTTF * create(const char *str, const char *fontName, float fontSize); + static CCLabelTTF * create(const char *str, const char *fontName, float fontSize, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment); static CCLabelTTF * create(const char *str, const char *fontName, float fontSize, const CCSize& dimensions, CCTextAlignment hAlignment); - static CCLabelTTF * create(const char *str, const char *fontName, float fontSize, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment); + static CCLabelTTF * create(const char *str, const char *fontName, float fontSize); + static CCLabelTTF * create(); }; diff --git a/tools/tolua++/CCLayer.pkg b/tools/tolua++/CCLayer.pkg index afd68899b8..67036125fa 100644 --- a/tools/tolua++/CCLayer.pkg +++ b/tools/tolua++/CCLayer.pkg @@ -57,8 +57,8 @@ class CCLayerGradient : public CCLayerColor void setCompressedInterpolation(bool Value); bool isCompressedInterpolation(void); - static CCLayerGradient* create(ccColor4B start, ccColor4B end); static CCLayerGradient* create(ccColor4B start, ccColor4B end, CCPoint v); + static CCLayerGradient* create(ccColor4B start, ccColor4B end); }; class CCLayerMultiplex : public CCLayer diff --git a/tools/tolua++/CCMenuItem.pkg b/tools/tolua++/CCMenuItem.pkg index 8a1c0eff79..318aca4ab0 100644 --- a/tools/tolua++/CCMenuItem.pkg +++ b/tools/tolua++/CCMenuItem.pkg @@ -81,11 +81,11 @@ class CCMenuItemSprite : public CCMenuItem void setOpacityModifyRGB(bool bValue); bool isOpacityModifyRGB(void); - static CCMenuItemSprite * create(CCNode* normalSprite, - CCNode* selectedSprite); static CCMenuItemSprite * create(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite); + static CCMenuItemSprite * create(CCNode* normalSprite, + CCNode* selectedSprite); }; class CCMenuItemImage : public CCMenuItemSprite @@ -99,12 +99,12 @@ class CCMenuItemImage : public CCMenuItemSprite void setSelectedSpriteFrame(CCSpriteFrame* frame); void setDisabledSpriteFrame(CCSpriteFrame* frame); - static CCMenuItemImage* create(); - static CCMenuItemImage* create(const char* normalImage, - const char* selectedImage); static CCMenuItemImage* create(const char* normalImage, const char* selectedImage, const char* disabledImage); + static CCMenuItemImage* create(const char* normalImage, + const char* selectedImage); + static CCMenuItemImage* create(); }; class CCMenuItemToggle : public CCMenuItem diff --git a/tools/tolua++/CCParticleSystem.pkg b/tools/tolua++/CCParticleSystem.pkg index 7637b605b2..35b4bec197 100644 --- a/tools/tolua++/CCParticleSystem.pkg +++ b/tools/tolua++/CCParticleSystem.pkg @@ -152,7 +152,7 @@ class CCParticleSystemQuad : public CCParticleSystem void postStep(); void setTotalParticles(unsigned int tp); - static CCParticleSystemQuad * create(); static CCParticleSystemQuad * create(const char *plistFile); + static CCParticleSystemQuad * create(); }; diff --git a/tools/tolua++/CCSprite.pkg b/tools/tolua++/CCSprite.pkg index ea65eb74f4..8076c4619c 100644 --- a/tools/tolua++/CCSprite.pkg +++ b/tools/tolua++/CCSprite.pkg @@ -95,7 +95,7 @@ class CCSprite : public CCNode static CCSprite* createWithTexture(CCTexture2D *pTexture, CCRect rect); static CCSprite* createWithSpriteFrame(CCSpriteFrame *pSpriteFrame); static CCSprite* createWithSpriteFrameName(const char *pszSpriteFrameName); - static CCSprite* create(); - static CCSprite* create(const char *pszFileName); static CCSprite* create(const char *pszFileName, CCRect rect); + static CCSprite* create(const char *pszFileName); + static CCSprite* create(); }; diff --git a/tools/tolua++/CCSpriteBatchNode.pkg b/tools/tolua++/CCSpriteBatchNode.pkg index cf6ad522a8..44acf1f1b5 100644 --- a/tools/tolua++/CCSpriteBatchNode.pkg +++ b/tools/tolua++/CCSpriteBatchNode.pkg @@ -33,6 +33,6 @@ class CCSpriteBatchNode : public CCNode static CCSpriteBatchNode* createWithTexture(CCTexture2D *tex); static CCSpriteBatchNode* createWithTexture(CCTexture2D* tex, unsigned int capacity); - static CCSpriteBatchNode* create(const char* fileImage); static CCSpriteBatchNode* create(const char* fileImage, unsigned int capacity); + static CCSpriteBatchNode* create(const char* fileImage); }; diff --git a/tools/tolua++/CCSpriteFrame.pkg b/tools/tolua++/CCSpriteFrame.pkg index 337f1a77b6..b42b515dbe 100644 --- a/tools/tolua++/CCSpriteFrame.pkg +++ b/tools/tolua++/CCSpriteFrame.pkg @@ -25,8 +25,8 @@ class CCSpriteFrame : public CCObject const CCPoint & getOffset(); void setOffset(const CCPoint & offsets); - static CCSpriteFrame* create(const char* filename, CCRect rect); static CCSpriteFrame* create(const char* filename, CCRect rect, bool rotated, CCPoint offset, CCSize originalSize); - static CCSpriteFrame* createWithTexture(CCTexture2D* pobTexture, CCRect rect); + static CCSpriteFrame* create(const char* filename, CCRect rect); static CCSpriteFrame* createWithTexture(CCTexture2D* pobTexture, CCRect rect, bool rotated, CCPoint offset, CCSize originalSize); + static CCSpriteFrame* createWithTexture(CCTexture2D* pobTexture, CCRect rect); }; From 4cbd9930915c7d1d039b3900124d856dc81c3487 Mon Sep 17 00:00:00 2001 From: Donald Alan Morrison Date: Mon, 17 Sep 2012 00:02:24 -0700 Subject: [PATCH 031/181] Minor English Spelling Corrections. A few grammar corrections. --- cocos2dx/actions/CCActionCatmullRom.h | 2 +- cocos2dx/actions/CCActionEase.h | 16 +++++------ cocos2dx/actions/CCActionInterval.cpp | 4 +-- cocos2dx/actions/CCActionInterval.h | 8 +++--- cocos2dx/actions/CCActionPageTurn3D.cpp | 2 +- cocos2dx/actions/CCActionTween.h | 2 +- cocos2dx/base_nodes/CCAtlasNode.cpp | 2 +- cocos2dx/base_nodes/CCAtlasNode.h | 2 +- cocos2dx/base_nodes/CCNode.cpp | 4 +-- cocos2dx/base_nodes/CCNode.h | 16 +++++------ cocos2dx/cocoa/CCArray.cpp | 2 +- cocos2dx/cocoa/CCArray.h | 4 +-- cocos2dx/cocoa/CCDictionary.cpp | 2 +- cocos2dx/cocoa/CCNS.cpp | 2 +- cocos2dx/cocoa/CCObject.cpp | 2 +- cocos2dx/cocoa/CCObject.h | 2 +- cocos2dx/cocoa/CCSet.h | 4 +-- cocos2dx/cocoa/CCString.h | 4 +-- cocos2dx/effects/CCGrabber.cpp | 2 +- cocos2dx/effects/CCGrid.cpp | 4 +-- cocos2dx/effects/CCGrid.h | 2 +- cocos2dx/include/CCProtocols.h | 10 +++---- cocos2dx/include/ccConfig.h | 18 ++++++------ cocos2dx/include/ccMacros.h | 2 +- cocos2dx/include/ccTypes.h | 6 ++-- cocos2dx/kazmath/include/kazmath/aabb.h | 2 +- .../include/kazmath/neon_matrix_impl.h | 6 ++-- cocos2dx/kazmath/include/kazmath/plane.h | 2 +- cocos2dx/kazmath/src/GL/matrix.c | 2 +- cocos2dx/kazmath/src/mat3.c | 2 +- cocos2dx/keypad_dispatcher/CCKeypadDelegate.h | 2 +- cocos2dx/label_nodes/CCLabelBMFont.cpp | 2 +- cocos2dx/label_nodes/CCLabelBMFont.h | 10 +++---- cocos2dx/label_nodes/CCLabelTTF.cpp | 2 +- .../CCLayer.cpp | 4 +-- .../layers_scenes_transitions_nodes/CCLayer.h | 4 +-- .../CCTransition.h | 10 +++---- .../CCTransitionProgress.h | 6 ++-- cocos2dx/menu_nodes/CCMenu.h | 2 +- cocos2dx/menu_nodes/CCMenuItem.h | 6 ++-- cocos2dx/misc_nodes/CCMotionStreak.cpp | 2 +- cocos2dx/misc_nodes/CCMotionStreak.h | 2 +- cocos2dx/misc_nodes/CCProgressTimer.cpp | 2 +- cocos2dx/misc_nodes/CCProgressTimer.h | 2 +- cocos2dx/misc_nodes/CCRenderTexture.cpp | 4 +-- cocos2dx/misc_nodes/CCRenderTexture.h | 2 +- .../particle_nodes/CCParticleBatchNode.cpp | 8 +++--- .../particle_nodes/CCParticleExamples.cpp | 14 +++++----- cocos2dx/particle_nodes/CCParticleSystem.cpp | 12 ++++---- cocos2dx/particle_nodes/CCParticleSystem.h | 18 ++++++------ .../particle_nodes/CCParticleSystemQuad.cpp | 2 +- .../particle_nodes/CCParticleSystemQuad.h | 8 +++--- cocos2dx/script_support/CCScriptSupport.h | 6 ++-- cocos2dx/shaders/CCShaderCache.cpp | 4 +-- cocos2dx/sprite_nodes/CCAnimation.h | 2 +- cocos2dx/sprite_nodes/CCAnimationCache.h | 2 +- cocos2dx/sprite_nodes/CCSprite.cpp | 4 +-- cocos2dx/sprite_nodes/CCSprite.h | 2 +- cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp | 6 ++-- cocos2dx/sprite_nodes/CCSpriteBatchNode.h | 6 ++-- cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp | 2 +- cocos2dx/sprite_nodes/CCSpriteFrameCache.h | 4 +-- cocos2dx/support/CCPointExtension.h | 2 +- cocos2dx/support/CCUserDefault.cpp | 6 ++-- cocos2dx/support/CCVertex.h | 2 +- cocos2dx/support/data_support/ccCArray.cpp | 26 ++++++++--------- cocos2dx/support/data_support/ccCArray.h | 28 +++++++++---------- cocos2dx/support/data_support/uthash.h | 2 +- cocos2dx/support/image_support/TGAlib.cpp | 8 +++--- cocos2dx/support/image_support/TGAlib.h | 2 +- cocos2dx/support/zip_support/ZipUtils.h | 4 +-- cocos2dx/support/zip_support/ioapi.h | 2 +- cocos2dx/support/zip_support/unzip.cpp | 26 ++++++++--------- cocos2dx/support/zip_support/unzip.h | 12 ++++---- cocos2dx/text_input_node/CCIMEDelegate.h | 18 ++++++------ cocos2dx/text_input_node/CCIMEDispatcher.cpp | 8 +++--- cocos2dx/text_input_node/CCIMEDispatcher.h | 18 ++++++------ cocos2dx/text_input_node/CCTextFieldTTF.cpp | 10 +++---- cocos2dx/text_input_node/CCTextFieldTTF.h | 10 +++---- cocos2dx/textures/CCTexture2D.cpp | 8 +++--- cocos2dx/textures/CCTexture2D.h | 4 +-- cocos2dx/textures/CCTextureAtlas.cpp | 2 +- cocos2dx/textures/CCTextureAtlas.h | 4 +-- cocos2dx/textures/CCTextureCache.cpp | 8 +++--- cocos2dx/textures/CCTextureCache.h | 10 +++---- cocos2dx/textures/CCTexturePVR.cpp | 10 +++---- cocos2dx/textures/CCTexturePVR.h | 4 +-- .../tilemap_parallax_nodes/CCTMXLayer.cpp | 4 +-- cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h | 10 +++---- .../tilemap_parallax_nodes/CCTMXTiledMap.h | 8 +++--- .../tilemap_parallax_nodes/CCTMXXMLParser.cpp | 4 +-- .../tilemap_parallax_nodes/CCTMXXMLParser.h | 10 +++---- .../tilemap_parallax_nodes/CCTileMapAtlas.cpp | 4 +-- .../tilemap_parallax_nodes/CCTileMapAtlas.h | 2 +- .../CCTouchDelegateProtocol.h | 4 +-- .../touch_dispatcher/CCTouchDispatcher.cpp | 8 +++--- cocos2dx/touch_dispatcher/CCTouchHandler.h | 4 +-- samples/HelloCpp/Classes/HelloWorldScene.h | 2 +- .../Classes/AppDelegate.cpp | 2 +- .../cocos2dx.xctemplate/ios/AppController.mm | 2 +- .../Classes/AppDelegate.cpp | 2 +- 101 files changed, 300 insertions(+), 300 deletions(-) mode change 100755 => 100644 cocos2dx/include/CCProtocols.h mode change 100755 => 100644 cocos2dx/include/ccConfig.h mode change 100755 => 100644 cocos2dx/include/ccTypes.h mode change 100755 => 100644 cocos2dx/textures/CCTexturePVR.cpp diff --git a/cocos2dx/actions/CCActionCatmullRom.h b/cocos2dx/actions/CCActionCatmullRom.h index cd9e12f14e..3fbbc66b46 100644 --- a/cocos2dx/actions/CCActionCatmullRom.h +++ b/cocos2dx/actions/CCActionCatmullRom.h @@ -26,7 +26,7 @@ * THE SOFTWARE. * * - * Orignal code by Radu Gruian: http://www.codeproject.com/Articles/30838/Overhauser-Catmull-Rom-Splines-for-Camera-Animatio.So + * Original code by Radu Gruian: http://www.codeproject.com/Articles/30838/Overhauser-Catmull-Rom-Splines-for-Camera-Animatio.So * * Adapted to cocos2d-x by Vit Valentin * diff --git a/cocos2dx/actions/CCActionEase.h b/cocos2dx/actions/CCActionEase.h index 8ee4695ca8..e7e9aeb38b 100644 --- a/cocos2dx/actions/CCActionEase.h +++ b/cocos2dx/actions/CCActionEase.h @@ -320,7 +320,7 @@ protected: /** @brief Ease Elastic In action. - @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. + @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 @ingroup Actions */ @@ -345,7 +345,7 @@ public: /** @brief Ease Elastic Out action. - @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. + @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 @ingroup Actions */ @@ -371,7 +371,7 @@ public: /** @brief Ease Elastic InOut action. - @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. + @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 @ingroup Actions */ @@ -440,7 +440,7 @@ public: /** @brief EaseBounceOut action. - @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. + @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 @ingroup Actions */ @@ -462,7 +462,7 @@ public: /** @brief CCEaseBounceInOut action. - @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. + @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 @ingroup Actions */ @@ -484,7 +484,7 @@ public: /** @brief CCEaseBackIn action. - @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. + @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 @ingroup Actions */ @@ -506,7 +506,7 @@ public: /** @brief CCEaseBackOut action. - @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. + @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 @ingroup Actions */ @@ -528,7 +528,7 @@ public: /** @brief CCEaseBackInOut action. - @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. + @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 @ingroup Actions */ diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index 2b86dcf7c3..194d3f693c 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -384,7 +384,7 @@ bool CCRepeat::initWithAction(CCFiniteTimeAction *pAction, unsigned int times) pAction->retain(); m_bActionInstant = dynamic_cast(pAction) ? true : false; - //a instant action needs to be executed one time less in the update method since it uses startWithTarget to execute the action + //an instant action needs to be executed one time less in the update method since it uses startWithTarget to execute the action if (m_bActionInstant) { m_uTimes -=1; @@ -463,7 +463,7 @@ void CCRepeat::update(float dt) m_uTotal++; } - // don't set a instantaction back or update it, it has no use because it has no duration + // don't set an instant action back or update it, it has no use because it has no duration if (!m_bActionInstant) { if (m_uTotal == m_uTimes) diff --git a/cocos2dx/actions/CCActionInterval.h b/cocos2dx/actions/CCActionInterval.h index f138b8fc3d..bdd147e478 100644 --- a/cocos2dx/actions/CCActionInterval.h +++ b/cocos2dx/actions/CCActionInterval.h @@ -116,7 +116,7 @@ public: @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); - /** helper contructor to create an array of sequenceable actions given an array + /** helper constructor to create an array of sequenceable actions given an array @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); @@ -127,7 +127,7 @@ public: /** helper constructor to create an array of sequenceable actions */ static CCFiniteTimeAction* create(CCFiniteTimeAction *pAction1, ...); - /** helper contructor to create an array of sequenceable actions given an array */ + /** helper constructor to create an array of sequenceable actions given an array */ static CCFiniteTimeAction* create(CCArray *arrayOfActions); /** creates the action */ static CCSequence* createWithTwoActions(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo); @@ -257,7 +257,7 @@ public: */ CC_DEPRECATED_ATTRIBUTE static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); - /** helper contructor to create an array of spawned actions given an array + /** helper constructor to create an array of spawned actions given an array @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); @@ -270,7 +270,7 @@ public: /** helper constructor to create an array of spawned actions */ static CCFiniteTimeAction* create(CCFiniteTimeAction *pAction1, ...); - /** helper contructor to create an array of spawned actions given an array */ + /** helper constructor to create an array of spawned actions given an array */ static CCFiniteTimeAction* create(CCArray *arrayOfActions); /** creates the Spawn action */ diff --git a/cocos2dx/actions/CCActionPageTurn3D.cpp b/cocos2dx/actions/CCActionPageTurn3D.cpp index 125cd94cbd..8397c454dc 100644 --- a/cocos2dx/actions/CCActionPageTurn3D.cpp +++ b/cocos2dx/actions/CCActionPageTurn3D.cpp @@ -96,7 +96,7 @@ void CCPageTurn3D::update(float time) p.y = ( R + ay - ( r * (1 - cosBeta) * sinTheta)); // We scale z here to avoid the animation being - // too much bigger than the screen due to perspectve transform + // too much bigger than the screen due to perspective transform p.z = (r * ( 1 - cosBeta ) * cosTheta) / 7;// "100" didn't work for // Stop z coord from dropping beneath underlying page in a transition diff --git a/cocos2dx/actions/CCActionTween.h b/cocos2dx/actions/CCActionTween.h index f355ccb771..2d9197c501 100644 --- a/cocos2dx/actions/CCActionTween.h +++ b/cocos2dx/actions/CCActionTween.h @@ -50,7 +50,7 @@ public: [target runAction:modifyWidth]; - Another example: CCScaleTo action could be rewriten using CCPropertyAction: + Another example: CCScaleTo action could be rewritten using CCPropertyAction: // scaleA and scaleB are equivalents id scaleA = [CCScaleTo actionWithDuration:2 scale:3]; diff --git a/cocos2dx/base_nodes/CCAtlasNode.cpp b/cocos2dx/base_nodes/CCAtlasNode.cpp index 4c814419a6..db54b2052f 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.cpp +++ b/cocos2dx/base_nodes/CCAtlasNode.cpp @@ -130,7 +130,7 @@ void CCAtlasNode::calculateMaxItems() void CCAtlasNode::updateAtlasValues() { - CCAssert(false, "CCAtlasNode:Abstract updateAtlasValue not overriden"); + CCAssert(false, "CCAtlasNode:Abstract updateAtlasValue not overridden"); } // CCAtlasNode - draw diff --git a/cocos2dx/base_nodes/CCAtlasNode.h b/cocos2dx/base_nodes/CCAtlasNode.h index f14eb04507..50885b3778 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.h +++ b/cocos2dx/base_nodes/CCAtlasNode.h @@ -98,7 +98,7 @@ public: bool initWithTileFile(const char* tile, unsigned int tileWidth, unsigned int tileHeight, unsigned int itemsToRender); /** updates the Atlas (indexed vertex array). - * Shall be overriden in subclasses + * Shall be overridden in subclasses */ virtual void updateAtlasValues(); diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index d616b58f58..be9e7c0913 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -171,7 +171,7 @@ void CCNode::setZOrder(int z) } } -/// ertexZ getter +/// vertexZ getter float CCNode::getVertexZ() { return m_fVertexZ; @@ -491,7 +491,7 @@ CCNode* CCNode::getChildByTag(int aTag) } /* "add" logic MUST only be on this method -* If a class want's to extend the 'addChild' behaviour it only needs +* If a class want's to extend the 'addChild' behavior it only needs * to override this method */ void CCNode::addChild(CCNode *child, int zOrder, int tag) diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index e474b21b38..e9595be0de 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -25,8 +25,8 @@ THE SOFTWARE. ****************************************************************************/ -#ifndef __PLATFOMR_CCNODE_H__ -#define __PLATFOMR_CCNODE_H__ +#ifndef __PLATFORM_CCNODE_H__ +#define __PLATFORM_CCNODE_H__ #include "ccMacros.h" #include "cocoa/CCAffineTransform.h" @@ -65,7 +65,7 @@ enum { kCCNodeOnExitTransitionDidStart }; -/** @brief CCNode is the main element. Anything thats gets drawn or contains things that get drawn is a CCNode. +/** @brief CCNode is the main element. Anything that gets drawn or contains things that get drawn is a CCNode. The most popular CCNodes are: CCScene, CCLayer, CCSprite, CCMenu. The main features of a CCNode are: @@ -239,7 +239,7 @@ public: /** A weak reference to the parent */ CC_PROPERTY(CCNode *, m_pParent, Parent) - // If ture, the Anchor Point will be (0,0) when you position the CCNode. + // If true, the Anchor Point will be (0,0) when you position the CCNode. // Used by CCLayer and CCScene bool m_bIgnoreAnchorPointForPosition; bool isIgnoreAnchorPointForPosition(); @@ -325,7 +325,7 @@ public: */ static CCNode * create(void); - //scene managment + //scene management /** callback that is called every time the CCNode enters the 'stage'. If the CCNode enters the 'stage' with a transition, this callback is called when the transition starts. @@ -577,7 +577,7 @@ public: */ virtual CCAffineTransform parentToNodeTransform(void); - /** Retrusn the world affine transform matrix. The matrix is in Pixels. + /** Returns the world affine transform matrix. The matrix is in Pixels. @since v0.7.1 */ virtual CCAffineTransform nodeToWorldTransform(void); @@ -611,7 +611,7 @@ public: */ CCPoint convertTouchToNodeSpace(CCTouch * touch); - /** converts a CCTouch (world coordinates) into a local coordiante. This method is AR (Anchor Relative). + /** converts a CCTouch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). @since v0.7.1 */ CCPoint convertTouchToNodeSpaceAR(CCTouch * touch); @@ -622,7 +622,7 @@ public: NS_CC_END -#endif // __PLATFOMR_CCNODE_H__ +#endif // __PLATFORM_CCNODE_H__ diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index 9cc9d5c5e6..7a6735eba0 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -414,7 +414,7 @@ void CCArray::reverseObjects() { if (data->num > 1) { - //floor it since in case of a oneven number the number of swaps stays the same + // floorf(), since in the case of an even number, the number of swaps stays the same int count = (int) floorf(data->num/2.f); unsigned int maxIndex = data->num - 1; diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index c35e8ce225..827bbda49c 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -33,7 +33,7 @@ THE SOFTWARE. */ /** @def CCARRAY_FOREACH -A convience macro to iterate over a CCArray using. It is faster than the "fast enumeration" interface. +A convenience macro to iterate over a CCArray using. It is faster than the "fast enumeration" interface. @since v0.99.4 */ @@ -139,7 +139,7 @@ public: @brief Generate a CCArray pointer by file @param pFileName The file name of *.plist file @return The CCArray pointer generated from the file - @deprecated: Please use createWithContentsOfFile(const char*) intead. This interface will be deprecated sooner or later. + @deprecated: Please use createWithContentsOfFile(const char*) instead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithContentsOfFile(const char* pFileName); diff --git a/cocos2dx/cocoa/CCDictionary.cpp b/cocos2dx/cocoa/CCDictionary.cpp index 990fbac698..2265d85540 100644 --- a/cocos2dx/cocoa/CCDictionary.cpp +++ b/cocos2dx/cocoa/CCDictionary.cpp @@ -264,7 +264,7 @@ void CCDictionary::removeAllObjects() CCObject* CCDictionary::copyWithZone(CCZone* pZone) { - CCAssert(pZone == NULL, "CCDirctionary should not be inherited."); + CCAssert(pZone == NULL, "CCDictionary should not be inherited."); CCDictionary* pNewDict = new CCDictionary(); CCDictElement* pElement = NULL; diff --git a/cocos2dx/cocoa/CCNS.cpp b/cocos2dx/cocoa/CCNS.cpp index 0fda42ce48..96360c10aa 100644 --- a/cocos2dx/cocoa/CCNS.cpp +++ b/cocos2dx/cocoa/CCNS.cpp @@ -50,7 +50,7 @@ static inline void split(std::string src, const char* token, strArray& vect) } // first, judge whether the form of the string like this: {x,y} -// if the form is right,the string will be splited into the parameter strs; +// if the form is right,the string will be split into the parameter strs; // or the parameter strs will be empty. // if the form is right return true,else return false. static bool splitWithForm(const char* pStr, strArray& strs) diff --git a/cocos2dx/cocoa/CCObject.cpp b/cocos2dx/cocoa/CCObject.cpp index 388e34e1bd..c439c1eda7 100644 --- a/cocos2dx/cocoa/CCObject.cpp +++ b/cocos2dx/cocoa/CCObject.cpp @@ -44,7 +44,7 @@ CCObject::CCObject(void) m_uID = ++uObjectCount; m_nLuaID = 0; - // when the object is created, the refrence count of it is 1 + // when the object is created, the reference count of it is 1 m_uReference = 1; m_bManaged = false; } diff --git a/cocos2dx/cocoa/CCObject.h b/cocos2dx/cocoa/CCObject.h index 1cdf5fef53..2aff081ee1 100644 --- a/cocos2dx/cocoa/CCObject.h +++ b/cocos2dx/cocoa/CCObject.h @@ -53,7 +53,7 @@ public: // Lua reference id int m_nLuaID; protected: - // count of refrence + // count of references unsigned int m_uReference; // is the object autoreleased bool m_bManaged; diff --git a/cocos2dx/cocoa/CCSet.h b/cocos2dx/cocoa/CCSet.h index 6d623ed8c0..e6513c3685 100644 --- a/cocos2dx/cocoa/CCSet.h +++ b/cocos2dx/cocoa/CCSet.h @@ -45,7 +45,7 @@ public: virtual ~CCSet(void); /** - *@brief Return a copy of the CCSet, it will copy all the elelments. + *@brief Return a copy of the CCSet, it will copy all the elements. */ CCSet* copy(); /** @@ -73,7 +73,7 @@ public: */ CCSetIterator begin(); /** - *@brief Return the iterator that points to the poisition after the last element. + *@brief Return the iterator that points to the position after the last element. */ CCSetIterator end(); /** diff --git a/cocos2dx/cocoa/CCString.h b/cocos2dx/cocoa/CCString.h index 503a37aa0a..bb8f242528 100644 --- a/cocos2dx/cocoa/CCString.h +++ b/cocos2dx/cocoa/CCString.h @@ -84,7 +84,7 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); virtual bool isEqual(const CCObject* pObject); - /* static funcitons */ + /* static functions */ /** create a string with c string * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. @@ -120,7 +120,7 @@ public: */ CC_DEPRECATED_ATTRIBUTE static CCString* stringWithContentsOfFile(const char* pszFileName); - /** create a string with std string, you can also pass a c string pointer because the default constuctor of std::string can access a c string pointer. + /** create a string with std string, you can also pass a c string pointer because the default constructor of std::string can access a c string pointer. * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. */ diff --git a/cocos2dx/effects/CCGrabber.cpp b/cocos2dx/effects/CCGrabber.cpp index dac9879136..6a408960c9 100644 --- a/cocos2dx/effects/CCGrabber.cpp +++ b/cocos2dx/effects/CCGrabber.cpp @@ -53,7 +53,7 @@ void CCGrabber::grab(CCTexture2D *pTexture) GLuint status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) { - CCAssert(0, "Frame Grabber: could not attach texture to frmaebuffer"); + CCAssert(0, "Frame Grabber: could not attach texture to framebuffer"); } glBindFramebuffer(GL_FRAMEBUFFER, m_oldFBO); diff --git a/cocos2dx/effects/CCGrid.cpp b/cocos2dx/effects/CCGrid.cpp index 7b21ab4a1e..9bd870c036 100644 --- a/cocos2dx/effects/CCGrid.cpp +++ b/cocos2dx/effects/CCGrid.cpp @@ -346,7 +346,7 @@ void CCGrid3D::blit(void) // position glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, m_pVertices); - // texCoods + // texCoords glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, m_pTexCoordinates); glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, m_pIndices); @@ -551,7 +551,7 @@ void CCTiledGrid3D::blit(void) // position glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, m_pVertices); - // texCoods + // texCoords glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, m_pTexCoordinates); glDrawElements(GL_TRIANGLES, (GLsizei)n*6, GL_UNSIGNED_SHORT, m_pIndices); diff --git a/cocos2dx/effects/CCGrid.h b/cocos2dx/effects/CCGrid.h index df008373e3..e6e49c1a5e 100644 --- a/cocos2dx/effects/CCGrid.h +++ b/cocos2dx/effects/CCGrid.h @@ -51,7 +51,7 @@ class CC_DLL CCGridBase : public CCObject public: virtual ~CCGridBase(void); - /** wheter or not the grid is active */ + /** whether or not the grid is active */ inline bool isActive(void) { return m_bActive; } void setActive(bool bActive); diff --git a/cocos2dx/include/CCProtocols.h b/cocos2dx/include/CCProtocols.h old mode 100755 new mode 100644 index 2dd5c0b87f..6ea1c60664 --- a/cocos2dx/include/CCProtocols.h +++ b/cocos2dx/include/CCProtocols.h @@ -50,7 +50,7 @@ public: virtual GLubyte getOpacity(void) = 0; /** sets the opacity. - @warning If the the texture has premultiplied alpha then, the R, G and B channels will be modifed. + @warning If the the texture has premultiplied alpha then, the R, G and B channels will be modified. Values goes from 0 to 255, where 255 means fully opaque. */ virtual void setOpacity(GLubyte opacity) = 0; @@ -59,7 +59,7 @@ public: /** sets the premultipliedAlphaOpacity property. If set to NO then opacity will be applied as: glColor(R,G,B,opacity); - If set to YES then oapcity will be applied as: glColor(opacity, opacity, opacity, opacity ); + If set to YES then opacity will be applied as: glColor(opacity, opacity, opacity, opacity ); Textures with premultiplied alpha will have this property by default on YES. Otherwise the default value is NO @since v0.8 */ @@ -72,7 +72,7 @@ public: }; /** - @brief You can specify the blending fuction. + @brief You can specify the blending function. @since v0.99.0 */ class CC_DLL CCBlendProtocol @@ -91,7 +91,7 @@ public: src=GL_ONE dst= GL_ONE_MINUS_SRC_ALPHA else src=GL_SRC_ALPHA dst= GL_ONE_MINUS_SRC_ALPHA - But you can change the blending funtion at any time. + But you can change the blending function at any time. @since v0.8.0 */ class CC_DLL CCTextureProtocol : public CCBlendProtocol @@ -119,7 +119,7 @@ public: class CC_DLL CCDirectorDelegate { public: - /** Called by CCDirector when the porjection is updated, and "custom" projection is used + /** Called by CCDirector when the projection is updated, and "custom" projection is used @since v0.99.5 */ virtual void updateProjection(void) = 0; diff --git a/cocos2dx/include/ccConfig.h b/cocos2dx/include/ccConfig.h old mode 100755 new mode 100644 index 4b3c3ba753..5b3bd9f44b --- a/cocos2dx/include/ccConfig.h +++ b/cocos2dx/include/ccConfig.h @@ -36,14 +36,14 @@ THE SOFTWARE. /** @def CC_ENABLE_GL_STATE_CACHE If enabled, cocos2d will maintain an OpenGL state cache internally to avoid unnecessary switches. - In order to use them, you have to use the following functions, insead of the the GL ones: + In order to use them, you have to use the following functions, instead of the the GL ones: - ccGLUseProgram() instead of glUseProgram() - ccGLDeleteProgram() instead of glDeleteProgram() - ccGLBlendFunc() instead of glBlendFunc() If this functionality is disabled, then ccGLUseProgram(), ccGLDeleteProgram(), ccGLBlendFunc() will call the GL ones, without using the cache. - It is recommened to enable whenever possible to improve speed. + It is recommended to enable whenever possible to improve speed. If you are migrating your code from GL ES 1.1, then keep it disabled. Once all your code works as expected, turn it on. @since v2.0.0 @@ -77,7 +77,7 @@ To enabled set it to 1. Disabled by default. #endif /** @def CC_DIRECTOR_FPS_INTERVAL - Senconds between FPS updates. + Seconds between FPS updates. 0.5 seconds, means that the FPS number will be updated every 0.5 seconds. Having a bigger number means a more reliable FPS @@ -190,7 +190,7 @@ Only valid for cocos2d-mac. Not supported on cocos2d-ios. /** @def CC_SPRITE_DEBUG_DRAW If enabled, all subclasses of CCSprite will draw a bounding box - Useful for debugging purposes only. It is recommened to leave it disabled. + Useful for debugging purposes only. It is recommended to leave it disabled. To enable set it to a value different than 0. Disabled by default: 0 -- disabled @@ -206,7 +206,7 @@ Only valid for cocos2d-mac. Not supported on cocos2d-ios. /** @def CC_SPRITEBATCHNODE_DEBUG_DRAW If enabled, all subclasses of CCSprite that are rendered using an CCSpriteBatchNode draw a bounding box. -Useful for debugging purposes only. It is recommened to leave it disabled. +Useful for debugging purposes only. It is recommended to leave it disabled. To enable set it to a value different than 0. Disabled by default. */ @@ -216,7 +216,7 @@ To enable set it to a value different than 0. Disabled by default. /** @def CC_LABELBMFONT_DEBUG_DRAW If enabled, all subclasses of CCLabelBMFont will draw a bounding box -Useful for debugging purposes only. It is recommened to leave it disabled. +Useful for debugging purposes only. It is recommended to leave it disabled. To enable set it to a value different than 0. Disabled by default. */ @@ -226,7 +226,7 @@ To enable set it to a value different than 0. Disabled by default. /** @def CC_LABELATLAS_DEBUG_DRAW If enabled, all subclasses of LabeltAtlas will draw a bounding box - Useful for debugging purposes only. It is recommened to leave it disabled. + Useful for debugging purposes only. It is recommended to leave it disabled. To enable set it to a value different than 0. Disabled by default. */ @@ -235,9 +235,9 @@ To enable set it to a value different than 0. Disabled by default. #endif /** @def CC_ENABLE_PROFILERS - If enabled, will activate various profilers withing cocos2d. This statistical data will be output to the console + If enabled, will activate various profilers within cocos2d. This statistical data will be output to the console once per second showing average time (in milliseconds) required to execute the specific routine(s). - Useful for debugging purposes only. It is recommened to leave it disabled. + Useful for debugging purposes only. It is recommended to leave it disabled. To enable set it to a value different than 0. Disabled by default. */ diff --git a/cocos2dx/include/ccMacros.h b/cocos2dx/include/ccMacros.h index 49252d46bb..e3c3dff77c 100644 --- a/cocos2dx/include/ccMacros.h +++ b/cocos2dx/include/ccMacros.h @@ -163,7 +163,7 @@ CCSizeMake( (__size_in_points__).width * CC_CONTENT_SCALE_FACTOR(), (__size_in_p void operator=(const TypeName&) /** -Helper marcos which converts 4-byte little/big endian +Helper macros which converts 4-byte little/big endian integral number to the machine native number representation It should work same as apples CFSwapInt32LittleToHost(..) diff --git a/cocos2dx/include/ccTypes.h b/cocos2dx/include/ccTypes.h old mode 100755 new mode 100644 index efccf070eb..790de5cab1 --- a/cocos2dx/include/ccTypes.h +++ b/cocos2dx/include/ccTypes.h @@ -254,7 +254,7 @@ typedef struct _ccV3F_C4B_T2F // char __padding2__[4]; // tex coords (2F) - ccTex2F texCoords; // 8 byts + ccTex2F texCoords; // 8 bytes } ccV3F_C4B_T2F; //! 4 ccVertex2FTex2FColor4B Quad @@ -305,7 +305,7 @@ typedef struct _ccBlendFunc GLenum dst; } ccBlendFunc; -// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m +// XXX: If any of these enums are edited and/or reordered, update CCTexture2D.m //! Vertical text alignment type typedef enum { @@ -314,7 +314,7 @@ typedef enum kCCVerticalTextAlignmentBottom, } CCVerticalTextAlignment; -// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m +// XXX: If any of these enums are edited and/or reordered, update CCTexture2D.m //! Horizontal text alignment type typedef enum { diff --git a/cocos2dx/kazmath/include/kazmath/aabb.h b/cocos2dx/kazmath/include/kazmath/aabb.h index 6b1860c13b..629889cef1 100644 --- a/cocos2dx/kazmath/include/kazmath/aabb.h +++ b/cocos2dx/kazmath/include/kazmath/aabb.h @@ -35,7 +35,7 @@ extern "C" { #endif /** - * A struture that represents an axis-aligned + * A structure that represents an axis-aligned * bounding box. */ typedef struct kmAABB { diff --git a/cocos2dx/kazmath/include/kazmath/neon_matrix_impl.h b/cocos2dx/kazmath/include/kazmath/neon_matrix_impl.h index 2223c65857..6e73e64a23 100644 --- a/cocos2dx/kazmath/include/kazmath/neon_matrix_impl.h +++ b/cocos2dx/kazmath/include/kazmath/neon_matrix_impl.h @@ -32,13 +32,13 @@ #endif #endif // __arm__ -// Matrixes are assumed to be stored in column major format according to OpenGL +// Matrices are assumed to be stored in column major format according to OpenGL // specification. -// Multiplies two 4x4 matrices (a,b) outputing a 4x4 matrix (output) +// Multiplies two 4x4 matrices (a,b) outputting a 4x4 matrix (output) void NEON_Matrix4Mul(const float* a, const float* b, float* output ); -// Multiplies a 4x4 matrix (m) with a vector 4 (v), outputing a vector 4 +// Multiplies a 4x4 matrix (m) with a vector 4 (v), outputting a vector 4 void NEON_Matrix4Vector4Mul(const float* m, const float* v, float* output); diff --git a/cocos2dx/kazmath/include/kazmath/plane.h b/cocos2dx/kazmath/include/kazmath/plane.h index 0a42daf63e..c4e4fe5b7e 100644 --- a/cocos2dx/kazmath/include/kazmath/plane.h +++ b/cocos2dx/kazmath/include/kazmath/plane.h @@ -62,7 +62,7 @@ CC_DLL kmPlane* const kmPlaneFromPoints(kmPlane* pOut, const struct kmVec3* p1, CC_DLL kmVec3* const kmPlaneIntersectLine(struct kmVec3* pOut, const kmPlane* pP, const struct kmVec3* pV1, const struct kmVec3* pV2); CC_DLL kmPlane* const kmPlaneNormalize(kmPlane* pOut, const kmPlane* pP); CC_DLL kmPlane* const kmPlaneScale(kmPlane* pOut, const kmPlane* pP, kmScalar s); -CC_DLL const POINT_CLASSIFICATION kmPlaneClassifyPoint(const kmPlane* pIn, const kmVec3* pP); /** Classifys a point against a plane */ +CC_DLL const POINT_CLASSIFICATION kmPlaneClassifyPoint(const kmPlane* pIn, const kmVec3* pP); /** Classifies a point against a plane */ #ifdef __cplusplus } diff --git a/cocos2dx/kazmath/src/GL/matrix.c b/cocos2dx/kazmath/src/GL/matrix.c index f074f86251..dfd8a87259 100644 --- a/cocos2dx/kazmath/src/GL/matrix.c +++ b/cocos2dx/kazmath/src/GL/matrix.c @@ -100,7 +100,7 @@ void kmGLPushMatrix(void) void kmGLPopMatrix(void) { assert(initialized && "Cannot Pop empty matrix stack"); - //No need to lazy initialize, you shouldnt be popping first anyway! + //No need to lazy initialize, you shouldn't be popping first anyway! km_mat4_stack_pop(current_stack, NULL); } diff --git a/cocos2dx/kazmath/src/mat3.c b/cocos2dx/kazmath/src/mat3.c index d5549a7792..6654d0634f 100644 --- a/cocos2dx/kazmath/src/mat3.c +++ b/cocos2dx/kazmath/src/mat3.c @@ -55,7 +55,7 @@ const kmScalar kmMat3Determinant(const kmMat3* pIn) m = | 1 4 7 | 1 4 | | 2 5 8 | 2 5 | now sum up the products of the diagonals going to the right (i.e. 0,4,8) - and substract the products of the other diagonals (i.e. 2,4,6) + and subtract the products of the other diagonals (i.e. 2,4,6) */ output = pIn->mat[0] * pIn->mat[4] * pIn->mat[8] + pIn->mat[1] * pIn->mat[5] * pIn->mat[6] + pIn->mat[2] * pIn->mat[3] * pIn->mat[7]; diff --git a/cocos2dx/keypad_dispatcher/CCKeypadDelegate.h b/cocos2dx/keypad_dispatcher/CCKeypadDelegate.h index fe930880a8..fd47e80523 100644 --- a/cocos2dx/keypad_dispatcher/CCKeypadDelegate.h +++ b/cocos2dx/keypad_dispatcher/CCKeypadDelegate.h @@ -41,7 +41,7 @@ public: // The back key clicked virtual void keyBackClicked() {} - // The menu key clicked. only avialble on wophone & android + // The menu key clicked. only available on wophone & android virtual void keyMenuClicked() {}; }; diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 737e801e42..299fd7553d 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -931,7 +931,7 @@ void CCLabelBMFont::createFontChars() // Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on fontChar->setColor(m_tColor); - // only apply opaccity if it is different than 255 ) + // only apply opacity if it is different than 255 ) // to prevent modifying the color too (issue #610) if( m_cOpacity != 255 ) { diff --git a/cocos2dx/label_nodes/CCLabelBMFont.h b/cocos2dx/label_nodes/CCLabelBMFont.h index eec1a44389..0488b3df3e 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.h +++ b/cocos2dx/label_nodes/CCLabelBMFont.h @@ -93,7 +93,7 @@ typedef struct _BMFontPadding { */ class CC_DLL CCBMFontConfiguration : public CCObject { - // XXX: Creating a public interface so that the bitmapFontArray[] is accesible + // XXX: Creating a public interface so that the bitmapFontArray[] is accessible public://@public // BMFont definitions struct _FontDefHashElement* m_pFontDefDictionary; @@ -142,7 +142,7 @@ Features: - scaled - translated - tinted -- chage the opacity +- change the opacity - It can be used as part of a menu item. - anchorPoint can be used to align the "label" - Supports AngelCode text format @@ -202,11 +202,11 @@ public: @since v0.99.3 */ static void purgeCachedData(); - /** creates a bitmap font altas with an initial string and the FNT file + /** creates a bitmap font atlas with an initial string and the FNT file @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCLabelBMFont * labelWithString(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointZero); - /** creates a bitmap font altas with an initial string and the FNT file */ + /** creates a bitmap font atlas with an initial string and the FNT file */ static CCLabelBMFont * create(const char *str, const char *fntFile, float width, CCTextAlignment alignment, CCPoint imageOffset); static CCLabelBMFont * create(const char *str, const char *fntFile, float width, CCTextAlignment alignment) { @@ -231,7 +231,7 @@ public: static CCLabelBMFont * create(); bool init(); - /** init a bitmap font altas with an initial string and the FNT file */ + /** init a bitmap font atlas with an initial string and the FNT file */ bool initWithString(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointZero); /** updates the font chars based on the string to render */ diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index 8ed7a89205..1aaa340771 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -227,7 +227,7 @@ void CCLabelTTF::setDimensions(const CCSize &dim) { m_tDimensions = dim; - // Force udpate + // Force update if (m_string.size() > 0) { this->updateTexture(); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index a2bf9c59bc..f0b3347a6e 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -247,7 +247,7 @@ void CCLayer::onEnter() pDirector->getAccelerometer()->setDelegate(this); } - // add this layer to concern the kaypad msg + // add this layer to concern the keypad msg if (m_bIsKeypadEnabled) { pDirector->getKeypadDispatcher()->addDelegate(this); @@ -269,7 +269,7 @@ void CCLayer::onExit() pDirector->getAccelerometer()->setDelegate(NULL); } - // remove this layer from the delegates who concern the kaypad msg + // remove this layer from the delegates who concern the keypad msg if (m_bIsKeypadEnabled) { pDirector->getKeypadDispatcher()->removeDelegate(this); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index 8423e06be0..ecff165334 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -293,7 +293,7 @@ public: /** * lua script can not init with undetermined number of variables - * so add these functinons to be used with lua. + * so add these functions to be used with lua. @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCLayerMultiplex * layerWithLayer(CCLayer* layer); @@ -303,7 +303,7 @@ public: /** * lua script can not init with undetermined number of variables - * so add these functinons to be used with lua. + * so add these functions to be used with lua. */ static CCLayerMultiplex * createWithLayer(CCLayer* layer); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h index ec821a516e..a146af445a 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h @@ -130,7 +130,7 @@ public: /** called after the transition finishes */ void finish(void); - /** used by some transitions to hide the outter scene */ + /** used by some transitions to hide the outer scene */ void hideOutShowIn(void); protected: @@ -266,7 +266,7 @@ public: /** initializes the scenes */ virtual void initScenes(void); - /** returns the action that will be performed by the incomming and outgoing scene */ + /** returns the action that will be performed by the incoming and outgoing scene */ virtual CCActionInterval* action(void); virtual void onEnter(); @@ -290,7 +290,7 @@ public: /** initializes the scenes */ virtual void initScenes(void); - /** returns the action that will be performed by the incomming and outgoing scene */ + /** returns the action that will be performed by the incoming and outgoing scene */ virtual CCActionInterval* action(void); TRANSITION_CREATE_FUNC(CCTransitionSlideInR); @@ -310,7 +310,7 @@ public: /** initializes the scenes */ virtual void initScenes(void); - /** returns the action that will be performed by the incomming and outgoing scene */ + /** returns the action that will be performed by the incoming and outgoing scene */ virtual CCActionInterval* action(void); TRANSITION_CREATE_FUNC(CCTransitionSlideInB); @@ -330,7 +330,7 @@ public: /** initializes the scenes */ virtual void initScenes(void); - /** returns the action that will be performed by the incomming and outgoing scene */ + /** returns the action that will be performed by the incoming and outgoing scene */ virtual CCActionInterval* action(void); TRANSITION_CREATE_FUNC(CCTransitionSlideInT); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h index 11b9976899..7ae48686be 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h @@ -59,7 +59,7 @@ protected: /** CCTransitionRadialCCW transition. - A counter colock-wise radial transition to the next scene + A counter clock-wise radial transition to the next scene */ class CC_DLL CCTransitionProgressRadialCCW : public CCTransitionProgress { @@ -73,7 +73,7 @@ protected: /** CCTransitionRadialCW transition. - A counter colock-wise radial transition to the next scene + A counter clock-wise radial transition to the next scene */ class CC_DLL CCTransitionProgressRadialCW : public CCTransitionProgress { @@ -86,7 +86,7 @@ protected: }; /** CCTransitionProgressHorizontal transition. - A colock-wise radial transition to the next scene + A clock-wise radial transition to the next scene */ class CC_DLL CCTransitionProgressHorizontal : public CCTransitionProgress { diff --git a/cocos2dx/menu_nodes/CCMenu.h b/cocos2dx/menu_nodes/CCMenu.h index d636592c83..8a1453f420 100644 --- a/cocos2dx/menu_nodes/CCMenu.h +++ b/cocos2dx/menu_nodes/CCMenu.h @@ -51,7 +51,7 @@ enum { * * Features and Limitation: * - You can add MenuItem objects in runtime using addChild: -* - But the only accecpted children are MenuItem objects +* - But the only accepted children are MenuItem objects */ class CC_DLL CCMenu : public CCLayer, public CCRGBAProtocol { diff --git a/cocos2dx/menu_nodes/CCMenuItem.h b/cocos2dx/menu_nodes/CCMenuItem.h index 56566f6973..379737c9ba 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.h +++ b/cocos2dx/menu_nodes/CCMenuItem.h @@ -129,14 +129,14 @@ public: @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemLabel * itemWithLabel(CCNode*label, CCObject* target, SEL_MenuHandler selector); - /** creates a CCMenuItemLabel with a Label. Target and selector will be nill + /** creates a CCMenuItemLabel with a Label. Target and selector will be nil @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemLabel* itemWithLabel(CCNode *label); /** creates a CCMenuItemLabel with a Label, target and selector */ static CCMenuItemLabel * create(CCNode*label, CCObject* target, SEL_MenuHandler selector); - /** creates a CCMenuItemLabel with a Label. Target and selector will be nill */ + /** creates a CCMenuItemLabel with a Label. Target and selector will be nil */ static CCMenuItemLabel* create(CCNode *label); /** initializes a CCMenuItemLabel with a Label, target and selector */ @@ -373,7 +373,7 @@ public: /** @brief A CCMenuItemToggle A simple container class that "toggles" it's inner items - The inner itmes can be any MenuItem + The inner items can be any MenuItem */ class CC_DLL CCMenuItemToggle : public CCMenuItem, public CCRGBAProtocol { diff --git a/cocos2dx/misc_nodes/CCMotionStreak.cpp b/cocos2dx/misc_nodes/CCMotionStreak.cpp index 30c13792d3..8d2d85027d 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.cpp +++ b/cocos2dx/misc_nodes/CCMotionStreak.cpp @@ -299,7 +299,7 @@ void CCMotionStreak::update(float delta) m_pPointVertexes[m_uNuPoints] = m_tPositionR; m_pPointState[m_uNuPoints] = 1.0f; - // Color asignation + // Color assignment const unsigned int offset = m_uNuPoints*8; *((ccColor3B*)(m_pColorPointer + offset)) = m_tColor; *((ccColor3B*)(m_pColorPointer + offset+4)) = m_tColor; diff --git a/cocos2dx/misc_nodes/CCMotionStreak.h b/cocos2dx/misc_nodes/CCMotionStreak.h index c09784cdc1..c93e6936e4 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.h +++ b/cocos2dx/misc_nodes/CCMotionStreak.h @@ -87,7 +87,7 @@ public: virtual void setOpacityModifyRGB(bool bValue); virtual bool isOpacityModifyRGB(void); - /** When fast mode is enbled, new points are added faster but with lower precision */ + /** When fast mode is enabled, new points are added faster but with lower precision */ inline bool isFastMode() { return m_bFastMode; } inline void setFastMode(bool bFastMode) { m_bFastMode = bFastMode; } diff --git a/cocos2dx/misc_nodes/CCProgressTimer.cpp b/cocos2dx/misc_nodes/CCProgressTimer.cpp index fa98613a04..a348d7175f 100644 --- a/cocos2dx/misc_nodes/CCProgressTimer.cpp +++ b/cocos2dx/misc_nodes/CCProgressTimer.cpp @@ -118,7 +118,7 @@ void CCProgressTimer::setSprite(CCSprite *pSprite) m_pSprite = pSprite; setContentSize(m_pSprite->getContentSize()); - // Everytime we set a new sprite, we free the current vertex data + // Every time we set a new sprite, we free the current vertex data if (m_pVertexData) { CC_SAFE_FREE(m_pVertexData); diff --git a/cocos2dx/misc_nodes/CCProgressTimer.h b/cocos2dx/misc_nodes/CCProgressTimer.h index 475b0bb941..3f3aebbcc7 100644 --- a/cocos2dx/misc_nodes/CCProgressTimer.h +++ b/cocos2dx/misc_nodes/CCProgressTimer.h @@ -45,7 +45,7 @@ typedef enum { } CCProgressTimerType; /** - @brief CCProgresstimer is a subclass of CCNode. + @brief CCProgressTimer is a subclass of CCNode. It renders the inner sprite according to the percentage. The progress can be Radial, Horizontal or vertical. @since v0.99.1 diff --git a/cocos2dx/misc_nodes/CCRenderTexture.cpp b/cocos2dx/misc_nodes/CCRenderTexture.cpp index 9839d7e0a7..bed3dae646 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.cpp +++ b/cocos2dx/misc_nodes/CCRenderTexture.cpp @@ -431,7 +431,7 @@ CCImage* CCRenderTexture::newCCImage() const CCSize& s = m_pTexture->getContentSizeInPixels(); // to get the image size to save - // if the saving image domain exeeds the buffer texture domain, + // if the saving image domain exceeds the buffer texture domain, // it should be cut int nSavedBufferWidth = (int)s.width; int nSavedBufferHeight = (int)s.height; @@ -458,7 +458,7 @@ CCImage* CCRenderTexture::newCCImage() this->end(); // to get the actual texture data - // #640 the image read from rendertexture is upseted + // #640 the image read from rendertexture is dirty for (int i = 0; i < nSavedBufferHeight; ++i) { memcpy(&pBuffer[i * nSavedBufferWidth * 4], diff --git a/cocos2dx/misc_nodes/CCRenderTexture.h b/cocos2dx/misc_nodes/CCRenderTexture.h index 7dc58c8014..22d9ae8c0b 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.h +++ b/cocos2dx/misc_nodes/CCRenderTexture.h @@ -44,7 +44,7 @@ typedef enum eImageFormat /** @brief CCRenderTexture is a generic rendering target. To render things into it, simply construct a render target, call begin on it, call visit on any cocos -scenes or objects to render them, and call end. For convienience, render texture +scenes or objects to render them, and call end. For convenience, render texture adds a sprite as it's display child with the results, so you can simply add the render texture to your scene and treat it like any other CocosNode. There are also functions for saving the render texture to disk in PNG or JPG format. diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp index 86da441a9b..e6d1721226 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp @@ -135,7 +135,7 @@ void CCParticleBatchNode::visit() // with the exception that it doesn't call visit on it's children // // The alternative is to have a void CCSprite#visit, but - // although this is less mantainable, is faster + // although this is less maintainable, is faster // if (!m_bIsVisible) { @@ -185,7 +185,7 @@ void CCParticleBatchNode::addChild(CCNode * child, int zOrder, int tag) setBlendFunc(pChild->getBlendFunc()); } - CCAssert( m_tBlendFunc.src == pChild->getBlendFunc().src && m_tBlendFunc.dst == pChild->getBlendFunc().dst, "Can't add a PaticleSystem that uses a differnt blending function"); + CCAssert( m_tBlendFunc.src == pChild->getBlendFunc().src && m_tBlendFunc.dst == pChild->getBlendFunc().dst, "Can't add a PaticleSystem that uses a different blending function"); //no lazy sorting, so don't call super addChild, call helper instead unsigned int pos = addChildHelper(pChild,zOrder,tag); @@ -388,7 +388,7 @@ void CCParticleBatchNode::removeChild(CCNode* child, bool cleanup) // after memmove of data, empty the quads at the end of array m_pTextureAtlas->fillWithEmptyQuadsFromIndex(m_pTextureAtlas->getTotalQuads(), pChild->getTotalParticles()); - // paticle could be reused for self rendering + // particle could be reused for self rendering pChild->setBatchNode(NULL); updateAllAtlasIndexes(); @@ -469,7 +469,7 @@ void CCParticleBatchNode::insertChild(CCParticleSystem* pSystem, unsigned int in m_pTextureAtlas->moveQuadsFromIndex(index, index+pSystem->getTotalParticles()); } - // increase totalParticles here for new particles, update method of particlesystem will fill the quads + // increase totalParticles here for new particles, update method of particle-system will fill the quads m_pTextureAtlas->increaseTotalQuadsWith(pSystem->getTotalParticles()); updateAllAtlasIndexes(); diff --git a/cocos2dx/particle_nodes/CCParticleExamples.cpp b/cocos2dx/particle_nodes/CCParticleExamples.cpp index 2aa2cc3379..b931458302 100644 --- a/cocos2dx/particle_nodes/CCParticleExamples.cpp +++ b/cocos2dx/particle_nodes/CCParticleExamples.cpp @@ -263,7 +263,7 @@ bool CCParticleGalaxy::initWithTotalParticles(unsigned int numberOfParticles) modeA.radialAccel = -80; modeA.radialAccelVar = 0; - // Gravity Mode: tagential + // Gravity Mode: tangential modeA.tangentialAccel = 80; modeA.tangentialAccelVar = 0; @@ -337,7 +337,7 @@ bool CCParticleFlower::initWithTotalParticles(unsigned int numberOfParticles) modeA.radialAccel = -60; modeA.radialAccelVar = 0; - // Gravity Mode: tagential + // Gravity Mode: tangential modeA.tangentialAccel = 15; modeA.tangentialAccelVar = 0; @@ -410,7 +410,7 @@ bool CCParticleMeteor::initWithTotalParticles(unsigned int numberOfParticles) modeA.radialAccel = 0; modeA.radialAccelVar = 0; - // Gravity Mode: tagential + // Gravity Mode: tangential modeA.tangentialAccel = 0; modeA.tangentialAccelVar = 0; @@ -484,7 +484,7 @@ bool CCParticleSpiral::initWithTotalParticles(unsigned int numberOfParticles) modeA.radialAccel = -380; modeA.radialAccelVar = 0; - // Gravity Mode: tagential + // Gravity Mode: tangential modeA.tangentialAccel = 45; modeA.tangentialAccelVar = 0; @@ -557,7 +557,7 @@ bool CCParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles) modeA.radialAccel = 0; modeA.radialAccelVar = 0; - // Gravity Mode: tagential + // Gravity Mode: tangential modeA.tangentialAccel = 0; modeA.tangentialAccelVar = 0; @@ -700,7 +700,7 @@ bool CCParticleSnow::initWithTotalParticles(unsigned int numberOfParticles) modeA.radialAccel = 0; modeA.radialAccelVar = 1; - // Gravity mode: tagential + // Gravity mode: tangential modeA.tangentialAccel = 0; modeA.tangentialAccelVar = 1; @@ -768,7 +768,7 @@ bool CCParticleRain::initWithTotalParticles(unsigned int numberOfParticles) modeA.radialAccel = 0; modeA.radialAccelVar = 1; - // Gravity Mode: tagential + // Gravity Mode: tangential modeA.tangentialAccel = 0; modeA.tangentialAccelVar = 1; diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index 4c79cc21af..ec9f5e0ea6 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -37,7 +37,7 @@ THE SOFTWARE. // http://particledesigner.71squared.com/ // // IMPORTANT: Particle Designer is supported by cocos2d, but -// 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d, +// 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guaranteed in cocos2d, // cocos2d uses a another approach, but the results are almost identical. // @@ -73,7 +73,7 @@ NS_CC_BEGIN // http://particledesigner.71squared.com/ // // IMPORTANT: Particle Designer is supported by cocos2d, but -// 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d, +// 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guaranteed in cocos2d, // cocos2d uses a another approach, but the results are almost identical. // @@ -392,12 +392,12 @@ bool CCParticleSystem::initWithTotalParticles(unsigned int numberOfParticles) m_bIsAutoRemoveOnFinish = false; - // Optimization: compile udpateParticle method + // Optimization: compile updateParticle method //updateParticleSel = @selector(updateQuadWithParticle:newPosition:); //updateParticleImp = (CC_UPDATE_PARTICLE_IMP) [self methodForSelector:updateParticleSel]; //for batchNode m_bTransformSystemDirty = false; - // udpate after action in run! + // update after action in run! this->scheduleUpdateWithPriority(1); return true; @@ -734,12 +734,12 @@ void CCParticleSystem::updateQuadWithParticle(tCCParticle* particle, const CCPoi { CC_UNUSED_PARAM(particle); CC_UNUSED_PARAM(newPosition); - // should be overriden + // should be overridden } void CCParticleSystem::postStep() { - // should be overriden + // should be overridden } // ParticleSystem - CCTexture protocol diff --git a/cocos2dx/particle_nodes/CCParticleSystem.h b/cocos2dx/particle_nodes/CCParticleSystem.h index ca855f5209..e6f7688ba4 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.h +++ b/cocos2dx/particle_nodes/CCParticleSystem.h @@ -131,7 +131,7 @@ class CCTexture2D; /** @brief Particle System base class. Attributes of a Particle System: -- emmision rate of the particles +- emission rate of the particles - Gravity Mode (Mode A): - gravity - direction @@ -155,7 +155,7 @@ Attributes of a Particle System: - texture cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/). -'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d, +'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guaranteed in cocos2d, cocos2d uses a another approach, but the results are almost identical. cocos2d supports all the variables used by Particle Designer plus a bit more: @@ -208,7 +208,7 @@ protected: float endRadius; /** The ending radius variance of the particles. Only available in 'Radius' mode. */ float endRadiusVar; - /** Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode. */ + /** Number of degrees to rotate a particle around the source pos per second. Only available in 'Radius' mode. */ float rotatePerSecond; /** Variance in degrees for rotatePerSecond. Only available in 'Radius' mode. */ float rotatePerSecondVar; @@ -245,7 +245,7 @@ protected: bool m_bIsActive; /** Quantity of particles that are being simulated at the moment */ CC_PROPERTY_READONLY(unsigned int, m_uParticleCount, ParticleCount) - /** How many seconds the emitter wil run. -1 means 'forever' */ + /** How many seconds the emitter will run. -1 means 'forever' */ CC_PROPERTY(float, m_fDuration, Duration) /** sourcePosition of the emitter */ CC_PROPERTY_PASS_BY_REF(CCPoint, m_tSourcePosition, SourcePosition) @@ -368,7 +368,7 @@ public: CCParticleSystem(); virtual ~CCParticleSystem(); /** creates an initializes a CCParticleSystem from a plist file. - This plist files can be creted manually or with Particle Designer: + This plist files can be created manually or with Particle Designer: http://particledesigner.71squared.com/ @deprecated: This interface will be deprecated sooner or later. @since v0.99.3 @@ -376,7 +376,7 @@ public: CC_DEPRECATED_ATTRIBUTE static CCParticleSystem * particleWithFile(const char *plistFile); /** creates an initializes a CCParticleSystem from a plist file. - This plist files can be creted manually or with Particle Designer: + This plist files can be created manually or with Particle Designer: http://particledesigner.71squared.com/ @since v2.0 */ @@ -388,7 +388,7 @@ public: /** initializes a CCParticleSystem*/ bool init(); /** initializes a CCParticleSystem from a plist file. - This plist files can be creted manually or with Particle Designer: + This plist files can be created manually or with Particle Designer: http://particledesigner.71squared.com/ @since v0.99.3 */ @@ -412,9 +412,9 @@ public: //! whether or not the system is full bool isFull(); - //! should be overriden by subclasses + //! should be overridden by subclasses virtual void updateQuadWithParticle(tCCParticle* particle, const CCPoint& newPosition); - //! should be overriden by subclasses + //! should be overridden by subclasses virtual void postStep(); virtual void update(float dt); diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp index ebd01eb50f..35fe1f0e02 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp @@ -381,7 +381,7 @@ void CCParticleSystemQuad::draw() void CCParticleSystemQuad::setTotalParticles(unsigned int tp) { - // If we are setting the total numer of particles to a number higher + // If we are setting the total number of particles to a number higher // than what is allocated, we need to allocate new arrays if( tp > m_uAllocatedParticles ) { diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.h b/cocos2dx/particle_nodes/CCParticleSystemQuad.h index fc1e674ecb..10822f4a24 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.h +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.h @@ -67,20 +67,20 @@ public: virtual ~CCParticleSystemQuad(); /** creates an initializes a CCParticleSystemQuad from a plist file. - This plist files can be creted manually or with Particle Designer: + This plist files can be created manually or with Particle Designer: @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCParticleSystemQuad * particleWithFile(const char *plistFile); /** creates an initializes a CCParticleSystemQuad from a plist file. - This plist files can be creted manually or with Particle Designer: + This plist files can be created manually or with Particle Designer: */ static CCParticleSystemQuad * create(const char *plistFile); - /** initialices the indices for the vertices*/ + /** initializes the indices for the vertices*/ void setupIndices(); - /** initilizes the texture with a rectangle measured Points */ + /** initializes the texture with a rectangle measured Points */ void initTexCoordsWithRect(const CCRect& rect); /** Sets a new CCSpriteFrame as particle. diff --git a/cocos2dx/script_support/CCScriptSupport.h b/cocos2dx/script_support/CCScriptSupport.h index 7c32e7167e..93856a8c2c 100644 --- a/cocos2dx/script_support/CCScriptSupport.h +++ b/cocos2dx/script_support/CCScriptSupport.h @@ -184,8 +184,8 @@ public: /** @brief Execute script code contained in the given string. @param codes holding the valid script code that should be executed. - @return 0 if the string is excuted correctly. - @return other if the string is excuted wrongly. + @return 0 if the string is executed correctly. + @return other if the string is executed wrongly. */ virtual int executeString(const char* codes) = 0; @@ -220,7 +220,7 @@ public: /** execute a schedule function */ virtual int executeSchedule(CCTimer* pTimer, float dt, CCNode* pNode = NULL) = 0; - /** functions for excute touch event */ + /** functions for execute touch event */ virtual int executeLayerTouchesEvent(CCLayer* pLayer, int eventType, CCSet *pTouches) = 0; virtual int executeLayerTouchEvent(CCLayer* pLayer, int eventType, CCTouch *pTouch) = 0; }; diff --git a/cocos2dx/shaders/CCShaderCache.cpp b/cocos2dx/shaders/CCShaderCache.cpp index c5c61db11b..2ff29d8976 100644 --- a/cocos2dx/shaders/CCShaderCache.cpp +++ b/cocos2dx/shaders/CCShaderCache.cpp @@ -134,7 +134,7 @@ void CCShaderCache::loadDefaultShaders() p->release(); // - // Position and 1 color passed as a uniform (to similate glColor4ub ) + // Position and 1 color passed as a uniform (to simulate glColor4ub ) // p = new CCGLProgram(); loadDefaultShader(p, kCCShaderType_Position_uColor); @@ -186,7 +186,7 @@ void CCShaderCache::reloadDefaultShaders() loadDefaultShader(p, kCCShaderType_PositionTextureA8Color); // - // Position and 1 color passed as a uniform (to similate glColor4ub ) + // Position and 1 color passed as a uniform (to simulate glColor4ub ) // p = programForKey(kCCShader_Position_uColor); p->reset(); diff --git a/cocos2dx/sprite_nodes/CCAnimation.h b/cocos2dx/sprite_nodes/CCAnimation.h index c12852bdb8..9d92817894 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.h +++ b/cocos2dx/sprite_nodes/CCAnimation.h @@ -67,7 +67,7 @@ public: /** how many units of time the frame takes */ CC_SYNTHESIZE(float, m_fDelayUnits, DelayUnits) - /** A CCAnimationFrameDisplayedNotification notification will be broadcasted when the frame is displayed with this dictionary as UserInfo. If UserInfo is nil, then no notification will be broadcasted. */ + /** A CCAnimationFrameDisplayedNotification notification will be broadcast when the frame is displayed with this dictionary as UserInfo. If UserInfo is nil, then no notification will be broadcast. */ CC_SYNTHESIZE_RETAIN(CCDictionary*, m_pUserInfo, UserInfo) }; diff --git a/cocos2dx/sprite_nodes/CCAnimationCache.h b/cocos2dx/sprite_nodes/CCAnimationCache.h index 570fc2979e..ac86cc5494 100644 --- a/cocos2dx/sprite_nodes/CCAnimationCache.h +++ b/cocos2dx/sprite_nodes/CCAnimationCache.h @@ -52,7 +52,7 @@ class CC_DLL CCAnimationCache : public CCObject public: CCAnimationCache(); ~CCAnimationCache(); - /** Retruns ths shared instance of the Animation cache */ + /** Returns the shared instance of the Animation cache */ static CCAnimationCache* sharedAnimationCache(void); /** Purges the cache. It releases all the CCAnimation objects and the shared instance. diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index 3120c95232..f77e140102 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -304,7 +304,7 @@ bool CCSprite::initWithSpriteFrameName(const char *pszSpriteFrameName) CCSprite* CCSprite::initWithCGImage(CGImageRef pImage) { // todo - // because it is deprecated, so we do not impelment it + // because it is deprecated, so we do not implement it return NULL; } @@ -482,7 +482,7 @@ void CCSprite::updateTransform(void) { CCAssert(m_pobBatchNode, "updateTransform is only valid when CCSprite is being rendered using an CCSpriteBatchNode"); - // recaculate matrix only if it is dirty + // recalculate matrix only if it is dirty if( isDirty() ) { // If it is not visible, or one of its ancestors is not visible, then do nothing: diff --git a/cocos2dx/sprite_nodes/CCSprite.h b/cocos2dx/sprite_nodes/CCSprite.h index 2a2aa504f0..ed5994b765 100644 --- a/cocos2dx/sprite_nodes/CCSprite.h +++ b/cocos2dx/sprite_nodes/CCSprite.h @@ -50,7 +50,7 @@ struct transformValues_; * @{ */ -#define CCSpriteIndexNotInitialized 0xffffffff /// CCSprite invalid index on the CCSpriteBatchode +#define CCSpriteIndexNotInitialized 0xffffffff /// CCSprite invalid index on the CCSpriteBatchNode /** CCSprite is a 2d image ( http://en.wikipedia.org/wiki/Sprite_(computer_graphics) ) diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index ac82b54d03..8683e9120b 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -139,7 +139,7 @@ void CCSpriteBatchNode::visit(void) // with the exception that it doesn't call visit on it's children // // The alternative is to have a void CCSprite#visit, but - // although this is less mantainable, is faster + // although this is less maintainable, is faster // if (! m_bIsVisible) { @@ -280,7 +280,7 @@ void CCSpriteBatchNode::sortAllChildren() CCObject* pObj = NULL; //fast dispatch, give every child a new atlasIndex based on their relative zOrder (keep parent -> child relations intact) - // and at the same time reorder descedants and the quads to the right index + // and at the same time reorder descendants and the quads to the right index CCARRAY_FOREACH(m_pChildren, pObj) { CCSprite* pChild = (CCSprite*)pObj; @@ -424,7 +424,7 @@ void CCSpriteBatchNode::increaseAtlasCapacity(void) { // serious problems CCLOGWARN("cocos2d: WARNING: Not enough memory to resize the atlas"); - CCAssert(false, "Not enough memory to resize the atla"); + CCAssert(false, "Not enough memory to resize the atlas"); } } diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h index b23882a167..a0c2f98d72 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h @@ -157,12 +157,12 @@ public: virtual void draw(void); protected: - /* IMPORTANT XXX IMPORTNAT: + /* IMPORTANT XXX IMPORTANT: * These 2 methods can't be part of CCTMXLayer since they call [super add...], and CCSpriteSheet#add SHALL not be called */ /* Adds a quad into the texture atlas but it won't be added into the children array. - This method should be called only when you are dealing with very big AtlasSrite and when most of the CCSprite won't be updated. + This method should be called only when you are dealing with very big AtlasSprite and when most of the CCSprite won't be updated. For example: a tile map (CCTMXMap) or a label with lots of characters (BitmapFontAtlas) */ void addQuadFromSprite(CCSprite *sprite, unsigned int index); @@ -180,7 +180,7 @@ protected: CCTextureAtlas *m_pobTextureAtlas; ccBlendFunc m_blendFunc; - // all descendants: chlidren, gran children, etc... + // all descendants: children, gran children, etc... CCArray* m_pobDescendants; }; diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp index 056ed7f98b..2d9881ca3c 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp @@ -405,7 +405,7 @@ CCSpriteFrame* CCSpriteFrameCache::spriteFrameByName(const char *pszName) frame = (CCSpriteFrame*)m_pSpriteFrames->objectForKey(key->getCString()); if (! frame) { - CCLOG("cocos2d: CCSpriteFrameCahce: Frame '%s' not found", pszName); + CCLOG("cocos2d: CCSpriteFrameCache: Frame '%s' not found", pszName); } } } diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.h b/cocos2dx/sprite_nodes/CCSpriteFrameCache.h index 2fd8462174..8aaa86b728 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.h +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.h @@ -104,7 +104,7 @@ public: /** Removes multiple Sprite Frames from a plist file. * Sprite Frames stored in this file will be removed. - * It is convinient to call this method when a specific texture needs to be removed. + * It is convenient to call this method when a specific texture needs to be removed. * @since v0.99.5 */ void removeSpriteFramesFromFile(const char* plist); @@ -116,7 +116,7 @@ private: void removeSpriteFramesFromDictionary(CCDictionary* dictionary); public: /** Removes all Sprite Frames associated with the specified textures. - * It is convinient to call this method when a specific texture needs to be removed. + * It is convenient to call this method when a specific texture needs to be removed. * @since v0.995. */ void removeSpriteFramesFromTexture(CCTexture2D* texture); diff --git a/cocos2dx/support/CCPointExtension.h b/cocos2dx/support/CCPointExtension.h index caecb9ca7d..d288704af5 100644 --- a/cocos2dx/support/CCPointExtension.h +++ b/cocos2dx/support/CCPointExtension.h @@ -272,7 +272,7 @@ CCPoint CC_DLL ccpLerp(const CCPoint& a, const CCPoint& b, float alpha); bool CC_DLL ccpFuzzyEqual(const CCPoint& a, const CCPoint& b, float variance); -/** Multiplies a nd b components, a.x*b.x, a.y*b.y +/** Multiplies a and b components, a.x*b.x, a.y*b.y @returns a component-wise multiplication @since v0.99.1 */ diff --git a/cocos2dx/support/CCUserDefault.cpp b/cocos2dx/support/CCUserDefault.cpp index 6714b255ab..2c13b2cf51 100644 --- a/cocos2dx/support/CCUserDefault.cpp +++ b/cocos2dx/support/CCUserDefault.cpp @@ -118,7 +118,7 @@ static void setValueForKey(const char* pKey, const char* pValue) if (rootNode) { // the node doesn't exist, add a new one - // libxml in android donesn't support xmlNewTextChild, so use this approach + // libxml in android doesn't support xmlNewTextChild, so use this approach xmlNodePtr tmpNode = xmlNewNode(NULL, BAD_CAST pKey); xmlNodePtr content = xmlNewText(BAD_CAST pValue); xmlAddChild(rootNode, tmpNode); @@ -227,7 +227,7 @@ string CCUserDefault::getStringForKey(const char* pKey, const std::string & defa void CCUserDefault::setBoolForKey(const char* pKey, bool value) { - // save bool value as sring + // save bool value as string if (true == value) { @@ -292,7 +292,7 @@ CCUserDefault* CCUserDefault::sharedUserDefault() initXMLFilePath(); // only create xml file one time - // the file exists after the programe exit + // the file exists after the program exit if ((! isXMLFileExist()) && (! createXMLFile())) { return NULL; diff --git a/cocos2dx/support/CCVertex.h b/cocos2dx/support/CCVertex.h index 7ea150faaa..2ce4446afc 100644 --- a/cocos2dx/support/CCVertex.h +++ b/cocos2dx/support/CCVertex.h @@ -39,7 +39,7 @@ NS_CC_BEGIN /** converts a line to a polygon */ void CC_DLL ccVertexLineToPolygon(CCPoint *points, float stroke, ccVertex2F *vertices, unsigned int offset, unsigned int nuPoints); -/** returns wheter or not the line intersects */ +/** returns whether or not the line intersects */ bool CC_DLL ccVertexLineIntersect(float Ax, float Ay, float Bx, float By, float Cx, float Cy, diff --git a/cocos2dx/support/data_support/ccCArray.cpp b/cocos2dx/support/data_support/ccCArray.cpp index 3255ac7289..cb6df03055 100644 --- a/cocos2dx/support/data_support/ccCArray.cpp +++ b/cocos2dx/support/data_support/ccCArray.cpp @@ -97,7 +97,7 @@ void ccArrayShrink(ccArray *arr) } } -/** Returns index of first occurence of object, CC_INVALID_INDEX if object not found. */ +/** Returns index of first occurrence of object, CC_INVALID_INDEX if object not found. */ unsigned int ccArrayGetIndexOfObject(ccArray *arr, CCObject* object) { for(unsigned int i = 0; i < arr->num; i++) @@ -114,7 +114,7 @@ bool ccArrayContainsObject(ccArray *arr, CCObject* object) return ccArrayGetIndexOfObject(arr, object) != CC_INVALID_INDEX; } -/** Appends an object. Bahaviour undefined if array doesn't have enough capacity. */ +/** Appends an object. Behavior undefined if array doesn't have enough capacity. */ void ccArrayAppendObject(ccArray *arr, CCObject* object) { CCAssert(object != NULL, "Invalid parameter!"); @@ -130,7 +130,7 @@ void ccArrayAppendObjectWithResize(ccArray *arr, CCObject* object) ccArrayAppendObject(arr, object); } -/** Appends objects from plusArr to arr. Behaviour undefined if arr doesn't have +/** Appends objects from plusArr to arr. Behavior undefined if arr doesn't have enough capacity. */ void ccArrayAppendArray(ccArray *arr, ccArray *plusArr) { @@ -188,7 +188,7 @@ void ccArrayRemoveAllObjects(ccArray *arr) } /** Removes object at specified index and pushes back all subsequent objects. - Behaviour undefined if index outside [0, num-1]. */ + Behavior undefined if index outside [0, num-1]. */ void ccArrayRemoveObjectAtIndex(ccArray *arr, unsigned int index, bool bReleaseObj/* = true*/) { CCAssert(arr && arr->num > 0 && index < arr->num, "Invalid index. Out of bounds"); @@ -208,7 +208,7 @@ void ccArrayRemoveObjectAtIndex(ccArray *arr, unsigned int index, bool bReleaseO /** Removes object at specified index and fills the gap with the last object, thereby avoiding the need to push back subsequent objects. - Behaviour undefined if index outside [0, num-1]. */ + Behavior undefined if index outside [0, num-1]. */ void ccArrayFastRemoveObjectAtIndex(ccArray *arr, unsigned int index) { CC_SAFE_RELEASE(arr->arr[index]); @@ -225,7 +225,7 @@ void ccArrayFastRemoveObject(ccArray *arr, CCObject* object) } } -/** Searches for the first occurance of object and removes it. If object is not +/** Searches for the first occurrence of object and removes it. If object is not found the function has no effect. */ void ccArrayRemoveObject(ccArray *arr, CCObject* object, bool bReleaseObj/* = true*/) { @@ -313,7 +313,7 @@ void ccCArrayEnsureExtraCapacity(ccCArray *arr, unsigned int extra) ccArrayEnsureExtraCapacity((ccArray*)arr,extra); } -/** Returns index of first occurence of value, CC_INVALID_INDEX if value not found. */ +/** Returns index of first occurrence of value, CC_INVALID_INDEX if value not found. */ unsigned int ccCArrayGetIndexOfValue(ccCArray *arr, void* value) { unsigned int i; @@ -331,7 +331,7 @@ bool ccCArrayContainsValue(ccCArray *arr, void* value) return ccCArrayGetIndexOfValue(arr, value) != CC_INVALID_INDEX; } -/** Inserts a value at a certain position. Behaviour undefined if aray doesn't have enough capacity */ +/** Inserts a value at a certain position. Behavior undefined if array doesn't have enough capacity */ void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, unsigned int index) { CCAssert( index < arr->max, "ccCArrayInsertValueAtIndex: invalid index"); @@ -352,7 +352,7 @@ void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, unsigned int index) arr->arr[index] = value; } -/** Appends an value. Bahaviour undefined if array doesn't have enough capacity. */ +/** Appends an value. Behavior undefined if array doesn't have enough capacity. */ void ccCArrayAppendValue(ccCArray *arr, void* value) { arr->arr[arr->num] = value; @@ -373,7 +373,7 @@ void ccCArrayAppendValueWithResize(ccCArray *arr, void* value) } -/** Appends values from plusArr to arr. Behaviour undefined if arr doesn't have +/** Appends values from plusArr to arr. Behavior undefined if arr doesn't have enough capacity. */ void ccCArrayAppendArray(ccCArray *arr, ccCArray *plusArr) { @@ -399,7 +399,7 @@ void ccCArrayRemoveAllValues(ccCArray *arr) } /** Removes value at specified index and pushes back all subsequent values. - Behaviour undefined if index outside [0, num-1]. + Behavior undefined if index outside [0, num-1]. @since v0.99.4 */ void ccCArrayRemoveValueAtIndex(ccCArray *arr, unsigned int index) @@ -414,7 +414,7 @@ void ccCArrayRemoveValueAtIndex(ccCArray *arr, unsigned int index) /** Removes value at specified index and fills the gap with the last value, thereby avoiding the need to push back subsequent values. - Behaviour undefined if index outside [0, num-1]. + Behavior undefined if index outside [0, num-1]. @since v0.99.4 */ void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, unsigned int index) @@ -423,7 +423,7 @@ void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, unsigned int index) arr->arr[index] = arr->arr[last]; } -/** Searches for the first occurance of value and removes it. If value is not found the function has no effect. +/** Searches for the first occurrence of value and removes it. If value is not found the function has no effect. @since v0.99.4 */ void ccCArrayRemoveValue(ccCArray *arr, void* value) diff --git a/cocos2dx/support/data_support/ccCArray.h b/cocos2dx/support/data_support/ccCArray.h index a6afcbc256..cd6ee42255 100644 --- a/cocos2dx/support/data_support/ccCArray.h +++ b/cocos2dx/support/data_support/ccCArray.h @@ -35,7 +35,7 @@ THE SOFTWARE. - comparisons are done using pointer equality instead of isEqual There are 2 kind of functions: - - ccArray functions that manipulates objective-c objects (retain and release are performanced) + - ccArray functions that manipulates objective-c objects (retain and release are performed) - ccCArray functions that manipulates values like if they were standard C structures (no retain/release is performed) */ @@ -78,20 +78,20 @@ void ccArrayEnsureExtraCapacity(ccArray *arr, unsigned int extra); /** shrinks the array so the memory footprint corresponds with the number of items */ void ccArrayShrink(ccArray *arr); -/** Returns index of first occurence of object, NSNotFound if object not found. */ +/** Returns index of first occurrence of object, NSNotFound if object not found. */ unsigned int ccArrayGetIndexOfObject(ccArray *arr, CCObject* object); /** Returns a Boolean value that indicates whether object is present in array. */ bool ccArrayContainsObject(ccArray *arr, CCObject* object); -/** Appends an object. Bahaviour undefined if array doesn't have enough capacity. */ +/** Appends an object. Behavior undefined if array doesn't have enough capacity. */ void ccArrayAppendObject(ccArray *arr, CCObject* object); /** Appends an object. Capacity of arr is increased if needed. */ void ccArrayAppendObjectWithResize(ccArray *arr, CCObject* object); /** Appends objects from plusArr to arr. - Behaviour undefined if arr doesn't have enough capacity. */ + Behavior undefined if arr doesn't have enough capacity. */ void ccArrayAppendArray(ccArray *arr, ccArray *plusArr); /** Appends objects from plusArr to arr. Capacity of arr is increased if needed. */ @@ -107,17 +107,17 @@ void ccArraySwapObjectsAtIndexes(ccArray *arr, unsigned int index1, unsigned int void ccArrayRemoveAllObjects(ccArray *arr); /** Removes object at specified index and pushes back all subsequent objects. - Behaviour undefined if index outside [0, num-1]. */ + Behavior undefined if index outside [0, num-1]. */ void ccArrayRemoveObjectAtIndex(ccArray *arr, unsigned int index, bool bReleaseObj = true); /** Removes object at specified index and fills the gap with the last object, thereby avoiding the need to push back subsequent objects. - Behaviour undefined if index outside [0, num-1]. */ + Behavior undefined if index outside [0, num-1]. */ void ccArrayFastRemoveObjectAtIndex(ccArray *arr, unsigned int index); void ccArrayFastRemoveObject(ccArray *arr, CCObject* object); -/** Searches for the first occurance of object and removes it. If object is not +/** Searches for the first occurrence of object and removes it. If object is not found the function has no effect. */ void ccArrayRemoveObject(ccArray *arr, CCObject* object, bool bReleaseObj = true); @@ -149,22 +149,22 @@ void ccCArrayDoubleCapacity(ccCArray *arr); /** Increases array capacity such that max >= num + extra. */ void ccCArrayEnsureExtraCapacity(ccCArray *arr, unsigned int extra); -/** Returns index of first occurence of value, NSNotFound if value not found. */ +/** Returns index of first occurrence of value, NSNotFound if value not found. */ unsigned int ccCArrayGetIndexOfValue(ccCArray *arr, void* value); /** Returns a Boolean value that indicates whether value is present in the C array. */ bool ccCArrayContainsValue(ccCArray *arr, void* value); -/** Inserts a value at a certain position. Behaviour undefined if aray doesn't have enough capacity */ +/** Inserts a value at a certain position. Behavior undefined if array doesn't have enough capacity */ void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, unsigned int index); -/** Appends an value. Bahaviour undefined if array doesn't have enough capacity. */ +/** Appends an value. Behavior undefined if array doesn't have enough capacity. */ void ccCArrayAppendValue(ccCArray *arr, void* value); /** Appends an value. Capacity of arr is increased if needed. */ void ccCArrayAppendValueWithResize(ccCArray *arr, void* value); -/** Appends values from plusArr to arr. Behaviour undefined if arr doesn't have +/** Appends values from plusArr to arr. Behavior undefined if arr doesn't have enough capacity. */ void ccCArrayAppendArray(ccCArray *arr, ccCArray *plusArr); @@ -175,19 +175,19 @@ void ccCArrayAppendArrayWithResize(ccCArray *arr, ccCArray *plusArr); void ccCArrayRemoveAllValues(ccCArray *arr); /** Removes value at specified index and pushes back all subsequent values. - Behaviour undefined if index outside [0, num-1]. + Behavior undefined if index outside [0, num-1]. @since v0.99.4 */ void ccCArrayRemoveValueAtIndex(ccCArray *arr, unsigned int index); /** Removes value at specified index and fills the gap with the last value, thereby avoiding the need to push back subsequent values. - Behaviour undefined if index outside [0, num-1]. + Behavior undefined if index outside [0, num-1]. @since v0.99.4 */ void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, unsigned int index); -/** Searches for the first occurance of value and removes it. If value is not found the function has no effect. +/** Searches for the first occurrence of value and removes it. If value is not found the function has no effect. @since v0.99.4 */ void ccCArrayRemoveValue(ccCArray *arr, void* value); diff --git a/cocos2dx/support/data_support/uthash.h b/cocos2dx/support/data_support/uthash.h index f86a82e81b..f2576e9154 100644 --- a/cocos2dx/support/data_support/uthash.h +++ b/cocos2dx/support/data_support/uthash.h @@ -62,7 +62,7 @@ do { } while(0) #endif -/* uint32_t next definded will conflict with other libraries and an "error C2872: 'uint32_t' : ambiguous symbol" will appear. +/* uint32_t next defined will conflict with other libraries and an "error C2872: 'uint32_t' : ambiguous symbol" will appear. so we replace all uint32_t with 'unsigned int'. */ /* a number of the hash function use uint32_t which isn't defined on win32 */ diff --git a/cocos2dx/support/image_support/TGAlib.cpp b/cocos2dx/support/image_support/TGAlib.cpp index 23d9a2bf64..dd98b87fb1 100644 --- a/cocos2dx/support/image_support/TGAlib.cpp +++ b/cocos2dx/support/image_support/TGAlib.cpp @@ -275,14 +275,14 @@ tImageTGA * tgaLoad(const char *pszFilename) return info; } -// converts RGB to greyscale +// converts RGB to grayscale void tgaRGBtogreyscale(tImageTGA *psInfo) { int mode,i,j; unsigned char *newImageData; - // if the image is already greyscale do nothing + // if the image is already grayscale do nothing if (psInfo->pixelDepth == 8) return; @@ -296,7 +296,7 @@ void tgaRGBtogreyscale(tImageTGA *psInfo) { return; } - // convert pixels: greyscale = o.30 * R + 0.59 * G + 0.11 * B + // convert pixels: grayscale = o.30 * R + 0.59 * G + 0.11 * B for (i = 0,j = 0; j < psInfo->width * psInfo->height; i +=mode, j++) newImageData[j] = (unsigned char)(0.30 * psInfo->imageData[i] + @@ -310,7 +310,7 @@ void tgaRGBtogreyscale(tImageTGA *psInfo) { // reassign pixelDepth and type according to the new image type psInfo->pixelDepth = 8; psInfo->type = 3; - // reassing imageData to the new array. + // reassigning imageData to the new array. psInfo->imageData = newImageData; } diff --git a/cocos2dx/support/image_support/TGAlib.h b/cocos2dx/support/image_support/TGAlib.h index 58e66b2e88..141b6a2fff 100644 --- a/cocos2dx/support/image_support/TGAlib.h +++ b/cocos2dx/support/image_support/TGAlib.h @@ -61,7 +61,7 @@ bool tgaLoadImageData(unsigned char *Buffer, unsigned long bufSize, tImageTGA *p /// this is the function to call when we want to load an image tImageTGA * tgaLoad(const char *pszFilename); -// /converts RGB to greyscale +// /converts RGB to grayscale void tgaRGBtogreyscale(tImageTGA *psInfo); /// releases the memory used for the image diff --git a/cocos2dx/support/zip_support/ZipUtils.h b/cocos2dx/support/zip_support/ZipUtils.h index d9cc1ecdd3..564ec230f7 100644 --- a/cocos2dx/support/zip_support/ZipUtils.h +++ b/cocos2dx/support/zip_support/ZipUtils.h @@ -33,7 +33,7 @@ namespace cocos2d unsigned char sig[4]; // signature. Should be 'CCZ!' 4 bytes unsigned short compression_type; // should 0 unsigned short version; // should be 2 (although version type==1 is also supported) - unsigned int reserved; // Reserverd for users. + unsigned int reserved; // Reserved for users. unsigned int len; // size of the uncompressed file }; @@ -51,7 +51,7 @@ namespace cocos2d * Inflates either zlib or gzip deflated memory. The inflated memory is * expected to be freed by the caller. * - * It will allocate 256k for the destination buffer. If it is not enought it will multiply the previous buffer size per 2, until there is enough memory. + * It will allocate 256k for the destination buffer. If it is not enough it will multiply the previous buffer size per 2, until there is enough memory. * @returns the length of the deflated buffer * @since v0.8.1 diff --git a/cocos2dx/support/zip_support/ioapi.h b/cocos2dx/support/zip_support/ioapi.h index 4eeddaadf8..48b65c95b2 100644 --- a/cocos2dx/support/zip_support/ioapi.h +++ b/cocos2dx/support/zip_support/ioapi.h @@ -80,7 +80,7 @@ namespace cocos2d { #include "mz64conf.h" #endif -/* a type choosen by DEFINE */ +/* a type chosen by DEFINE */ #ifdef HAVE_64BIT_INT_CUSTOM typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; #else diff --git a/cocos2dx/support/zip_support/unzip.cpp b/cocos2dx/support/zip_support/unzip.cpp index 29a589eb73..b65caaae89 100644 --- a/cocos2dx/support/zip_support/unzip.cpp +++ b/cocos2dx/support/zip_support/unzip.cpp @@ -53,8 +53,8 @@ Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G should only read the compressed/uncompressed size from the Zip64 format if the size from normal header was 0xFFFFFFFF - Oct-2009 - Mathias Svensson - Applied some bug fixes from paches recived from Gilles Vollant - Oct-2009 - Mathias Svensson - Applied support to unzip files with compression mathod BZIP2 (bzip2 lib is required) + Oct-2009 - Mathias Svensson - Applied some bug fixes from patches received from Gilles Vollant + Oct-2009 - Mathias Svensson - Applied support to unzip files with compression method BZIP2 (bzip2 lib is required) Patch created by Daniel Borca Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer @@ -142,7 +142,7 @@ typedef struct #endif ZPOS64_T pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ - uLong stream_initialised; /* flag set if stream structure is initialised*/ + uLong stream_initialised; /* flag set if stream structure is initialized*/ ZPOS64_T offset_local_extrafield;/* offset of the local extra field */ uInt size_local_extrafield;/* size of the local extra field */ @@ -154,7 +154,7 @@ typedef struct ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */ ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/ zlib_filefunc64_32_def z_filefunc; - voidpf filestream; /* io structore of the zipfile */ + voidpf filestream; /* io structure of the zipfile */ uLong compression_method; /* compression method (0==store) */ ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ int raw; @@ -167,7 +167,7 @@ typedef struct { zlib_filefunc64_32_def z_filefunc; int is64bitOpenFunction; - voidpf filestream; /* io structore of the zipfile */ + voidpf filestream; /* io structure of the zipfile */ unz_global_info64 gi; /* public global information */ ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ ZPOS64_T num_file; /* number of the current file in the zipfile*/ @@ -201,7 +201,7 @@ typedef struct /* =========================================================================== Read a byte from a gz_stream; update next_in and avail_in. Return EOF for end of file. - IN assertion: the stream s has been sucessfully opened for reading. + IN assertion: the stream s has been successfully opened for reading. */ @@ -381,10 +381,10 @@ local int strcmpcasenosensitive_internal (const char* fileName1, const char* fil /* Compare two filename (fileName1,fileName2). - If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) - If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi + If iCaseSenisivity = 1, comparison is case sensitivity (like strcmp) + If iCaseSenisivity = 2, comparison is not case sensitivity (like strcmpi or strcasecmp) - If iCaseSenisivity = 0, case sensitivity is defaut of your operating system + If iCaseSenisivity = 0, case sensitivity is default of your operating system (like 1 on Unix, 2 on Windows) */ @@ -592,9 +592,9 @@ local unzFile unzOpenInternal (const void *path, uLong uL; uLong number_disk; /* number of the current dist, used for - spaning ZIP, unsupported, always 0*/ + spanning ZIP, unsupported, always 0*/ uLong number_disk_with_CD; /* number the the disk with central dir, used - for spaning ZIP, unsupported, always 0*/ + for spanning ZIP, unsupported, always 0*/ ZPOS64_T number_entry_CD; /* total number of entries in the central dir (same than number_entry on nospan) */ @@ -848,7 +848,7 @@ int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info32) return UNZ_OK; } /* - Translate date/time from Dos format to tm_unz (readable more easilty) + Translate date/time from Dos format to tm_unz (readable more easily) */ local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm) { @@ -1677,7 +1677,7 @@ ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file) buf contain buffer where data must be copied len the size of buf. - return the number of byte copied if somes bytes are copied + return the number of byte copied if some bytes are copied return 0 if the end of file was reached return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) diff --git a/cocos2dx/support/zip_support/unzip.h b/cocos2dx/support/zip_support/unzip.h index 4fab73cda3..e30e403d17 100644 --- a/cocos2dx/support/zip_support/unzip.h +++ b/cocos2dx/support/zip_support/unzip.h @@ -153,10 +153,10 @@ int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, int iCaseSensitivity)); /* Compare two filename (fileName1,fileName2). - If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) - If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi + If iCaseSenisivity = 1, comparison is case sensitivity (like strcmp) + If iCaseSenisivity = 2, comparison is not case sensitivity (like strcmpi or strcasecmp) - If iCaseSenisivity = 0, case sensitivity is defaut of your operating system + If iCaseSenisivity = 0, case sensitivity is default of your operating system (like 1 on Unix, 2 on Windows) */ @@ -302,9 +302,9 @@ int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, uLong commentBufferSize)); /* Get Info about the current file - if pfile_info!=NULL, the *pfile_info structure will contain somes info about + if pfile_info!=NULL, the *pfile_info structure will contain some info about the current file - if szFileName!=NULL, the filemane string will be copied in szFileName + if szFileName!=NULL, the filename string will be copied in szFileName (fileNameBufferSize is the size of the buffer) if extraField!=NULL, the extra field information will be copied in extraField (extraFieldBufferSize is the size of the buffer). @@ -382,7 +382,7 @@ int ZEXPORT unzReadCurrentFile OF((unzFile file, buf contain buffer where data must be copied len the size of buf. - return the number of byte copied if somes bytes are copied + return the number of byte copied if some bytes are copied return 0 if the end of file was reached return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) diff --git a/cocos2dx/text_input_node/CCIMEDelegate.h b/cocos2dx/text_input_node/CCIMEDelegate.h index bc70383344..07c54ca300 100644 --- a/cocos2dx/text_input_node/CCIMEDelegate.h +++ b/cocos2dx/text_input_node/CCIMEDelegate.h @@ -36,8 +36,8 @@ NS_CC_BEGIN typedef struct { - CCRect begin; // the soft keyboard rectangle when animatin begin - CCRect end; // the soft keyboard rectangle when animatin end + CCRect begin; // the soft keyboard rectangle when animation begins + CCRect end; // the soft keyboard rectangle when animation ends float duration; // the soft keyboard animation duration } CCIMEKeyboardNotificationInfo; @@ -56,38 +56,38 @@ protected: friend class CCIMEDispatcher; /** - @brief Decide the delegate instance is ready for receive ime message or not. + @brief Decide if the delegate instance is ready to receive an IME message. Called by CCIMEDispatcher. */ virtual bool canAttachWithIME() { return false; } /** - @brief When the delegate detach with IME, this method call by CCIMEDispatcher. + @brief When the delegate detaches from the IME, this method is called by CCIMEDispatcher. */ virtual void didAttachWithIME() {} /** - @brief Decide the delegate instance can stop receive ime message or not. + @brief Decide if the delegate instance can stop receiving IME messages. */ virtual bool canDetachWithIME() { return false; } /** - @brief When the delegate detach with IME, this method call by CCIMEDispatcher. + @brief When the delegate detaches from the IME, this method is called by CCIMEDispatcher. */ virtual void didDetachWithIME() {} /** - @brief Called by CCIMEDispatcher when some text input from IME. + @brief Called by CCIMEDispatcher when text input received from the IME. */ virtual void insertText(const char * text, int len) {CC_UNUSED_PARAM(text);CC_UNUSED_PARAM(len);} /** - @brief Called by CCIMEDispatcher when user clicked the backward key. + @brief Called by CCIMEDispatcher after the user clicks the backward key. */ virtual void deleteBackward() {} /** - @brief Called by CCIMEDispatcher for get text which delegate already has. + @brief Called by CCIMEDispatcher for text stored in delegate. */ virtual const char * getContentText() { return 0; } diff --git a/cocos2dx/text_input_node/CCIMEDispatcher.cpp b/cocos2dx/text_input_node/CCIMEDispatcher.cpp index 9fd58584d9..1371557d7e 100644 --- a/cocos2dx/text_input_node/CCIMEDispatcher.cpp +++ b/cocos2dx/text_input_node/CCIMEDispatcher.cpp @@ -160,7 +160,7 @@ bool CCIMEDispatcher::attachDelegateWithIME(CCIMEDelegate * pDelegate) break; } - // havn't delegate attached with IME yet + // delegate hasn't attached to IME yet CC_BREAK_IF(! pDelegate->canAttachWithIME()); m_pImpl->m_DelegateWithIme = *iter; @@ -177,7 +177,7 @@ bool CCIMEDispatcher::detachDelegateWithIME(CCIMEDelegate * pDelegate) { CC_BREAK_IF(! m_pImpl || ! pDelegate); - // if pDelegate is not the current delegate attached with ime, return + // if pDelegate is not the current delegate attached to IME, return CC_BREAK_IF(m_pImpl->m_DelegateWithIme != pDelegate); CC_BREAK_IF(! pDelegate->canDetachWithIME()); @@ -219,7 +219,7 @@ void CCIMEDispatcher::dispatchInsertText(const char * pText, int nLen) { CC_BREAK_IF(! m_pImpl || ! pText || nLen <= 0); - // there is no delegate attach with ime + // there is no delegate attached to IME CC_BREAK_IF(! m_pImpl->m_DelegateWithIme); m_pImpl->m_DelegateWithIme->insertText(pText, nLen); @@ -232,7 +232,7 @@ void CCIMEDispatcher::dispatchDeleteBackward() { CC_BREAK_IF(! m_pImpl); - // there is no delegate attach with ime + // there is no delegate attached to IME CC_BREAK_IF(! m_pImpl->m_DelegateWithIme); m_pImpl->m_DelegateWithIme->deleteBackward(); diff --git a/cocos2dx/text_input_node/CCIMEDispatcher.h b/cocos2dx/text_input_node/CCIMEDispatcher.h index 54fdaeb137..1887e223da 100644 --- a/cocos2dx/text_input_node/CCIMEDispatcher.h +++ b/cocos2dx/text_input_node/CCIMEDispatcher.h @@ -48,22 +48,22 @@ public: static CCIMEDispatcher* sharedDispatcher(); // /** -// @brief Release all CCIMEDelegates from shared dispatcher. +// @brief Releases all CCIMEDelegates from the shared dispatcher. // */ // static void purgeSharedDispatcher(); /** - @brief dispatch the input text from ime + @brief Dispatches the input text from IME. */ void dispatchInsertText(const char * pText, int nLen); /** - @brief dispatch the delete backward operation + @brief Dispatches the delete-backward operation. */ void dispatchDeleteBackward(); /** - @brief get the content text, which current CCIMEDelegate which attached with IME has. + @brief Get the content text from CCIMEDelegate, retrieved previously from IME. */ const char * getContentText(); @@ -79,20 +79,20 @@ protected: friend class CCIMEDelegate; /** - @brief add delegate to concern ime msg + @brief Add delegate to receive IME messages. */ void addDelegate(CCIMEDelegate * pDelegate); /** - @brief attach the pDeleate with ime. - @return If the old delegate can detattach with ime and the new delegate - can attach with ime, return true, otherwise return false. + @brief Attach the pDelegate to the IME. + @return If the old delegate can detach from the IME, and the new delegate + can attach to the IME, return true, otherwise false. */ bool attachDelegateWithIME(CCIMEDelegate * pDelegate); bool detachDelegateWithIME(CCIMEDelegate * pDelegate); /** - @brief remove the delegate from the delegates who concern ime msg + @brief Remove the delegate from the delegates which receive IME messages. */ void removeDelegate(CCIMEDelegate * pDelegate); diff --git a/cocos2dx/text_input_node/CCTextFieldTTF.cpp b/cocos2dx/text_input_node/CCTextFieldTTF.cpp index b0d6d36879..4d689893fa 100644 --- a/cocos2dx/text_input_node/CCTextFieldTTF.cpp +++ b/cocos2dx/text_input_node/CCTextFieldTTF.cpp @@ -184,7 +184,7 @@ void CCTextFieldTTF::insertText(const char * text, int len) { if (m_pDelegate && m_pDelegate->onTextFieldInsertText(this, sInsert.c_str(), len)) { - // delegate doesn't want insert text + // delegate doesn't want to insert text return; } @@ -198,13 +198,13 @@ void CCTextFieldTTF::insertText(const char * text, int len) return; } - // '\n' has inserted, let delegate process first + // '\n' inserted, let delegate process first if (m_pDelegate && m_pDelegate->onTextFieldInsertText(this, "\n", 1)) { return; } - // if delegate hasn't process, detach with ime as default + // if delegate hasn't processed, detach from IME by default detachWithIME(); } @@ -227,11 +227,11 @@ void CCTextFieldTTF::deleteBackward() if (m_pDelegate && m_pDelegate->onTextFieldDeleteBackward(this, m_pInputText->c_str() + nStrLen - nDeleteLen, nDeleteLen)) { - // delegate don't wan't delete backward + // delegate doesn't wan't to delete backwards return; } - // if delete all text, show space holder string + // if all text deleted, show placeholder string if (nStrLen <= nDeleteLen) { CC_SAFE_DELETE(m_pInputText); diff --git a/cocos2dx/text_input_node/CCTextFieldTTF.h b/cocos2dx/text_input_node/CCTextFieldTTF.h index da3d590d94..c59b01555a 100644 --- a/cocos2dx/text_input_node/CCTextFieldTTF.h +++ b/cocos2dx/text_input_node/CCTextFieldTTF.h @@ -42,7 +42,7 @@ class CC_DLL CCTextFieldDelegate { public: /** - @brief If the sender doesn't want to attach with IME, return true; + @brief If the sender doesn't want to attach to the IME, return true; */ virtual bool onTextFieldAttachWithIME(CCTextFieldTTF * sender) { @@ -51,7 +51,7 @@ public: } /** - @brief If the sender doesn't want to detach with IME, return true; + @brief If the sender doesn't want to detach from the IME, return true; */ virtual bool onTextFieldDetachWithIME(CCTextFieldTTF * sender) { @@ -82,7 +82,7 @@ public: } /** - @brief If doesn't want draw sender as default, return true. + @brief If the sender doesn't want to draw, return true. */ virtual bool onDraw(CCTextFieldTTF * sender) { @@ -117,7 +117,7 @@ public: virtual bool attachWithIME(); /** - @brief End text input and close keyboard. + @brief End text input and close keyboard. */ virtual bool detachWithIME(); @@ -166,4 +166,4 @@ private: NS_CC_END -#endif // __CC_TEXT_FIELD_H__ \ No newline at end of file +#endif // __CC_TEXT_FIELD_H__ diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index c34a077b68..637a6f93de 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -163,7 +163,7 @@ void CCTexture2D::releaseData(void *data) void* CCTexture2D::keepData(void *data, unsigned int length) { CC_UNUSED_PARAM(length); - //The texture data mustn't be saved becuase it isn't a mutable texture. + //The texture data mustn't be saved because it isn't a mutable texture. return data; } @@ -600,7 +600,7 @@ void CCTexture2D::PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied) void CCTexture2D::generateMipmap() { - CCAssert( m_uPixelsWide == ccNextPOT(m_uPixelsWide) && m_uPixelsHigh == ccNextPOT(m_uPixelsHigh), "Mimpap texture only works in POT textures"); + CCAssert( m_uPixelsWide == ccNextPOT(m_uPixelsWide) && m_uPixelsHigh == ccNextPOT(m_uPixelsHigh), "Mipmap texture only works in POT textures"); ccGLBindTexture2D( m_uName ); glGenerateMipmap(GL_TEXTURE_2D); m_bHasMipmaps = true; @@ -703,7 +703,7 @@ const char* CCTexture2D::stringForFormat() return "PVRTC2"; default: - CCAssert(false , "unrecognised pixel format"); + CCAssert(false , "unrecognized pixel format"); CCLOG("stringForFormat: %ld, cannot give useful result", (long)m_ePixelFormat); break; } @@ -766,7 +766,7 @@ unsigned int CCTexture2D::bitsPerPixelForFormat(CCTexture2DPixelFormat format) break; default: ret = -1; - CCAssert(false , "unrecognised pixel format"); + CCAssert(false , "unrecognized pixel format"); CCLOG("bitsPerPixelForFormat: %ld, cannot give useful result", (long)format); break; } diff --git a/cocos2dx/textures/CCTexture2D.h b/cocos2dx/textures/CCTexture2D.h index 9c8370b88f..f4e1928a2f 100644 --- a/cocos2dx/textures/CCTexture2D.h +++ b/cocos2dx/textures/CCTexture2D.h @@ -114,7 +114,7 @@ public: void releaseData(void *data); void* keepData(void *data, unsigned int length); - /** Intializes with a texture2d with data */ + /** Initializes with a texture2d with data */ bool initWithData(const void* data, CCTexture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const CCSize& contentSize); /** @@ -251,7 +251,7 @@ private: CC_PROPERTY_READONLY(CCTexture2DPixelFormat, m_ePixelFormat, PixelFormat) /** width in pixels */ CC_PROPERTY_READONLY(unsigned int, m_uPixelsWide, PixelsWide) - /** hight in pixels */ + /** height in pixels */ CC_PROPERTY_READONLY(unsigned int, m_uPixelsHigh, PixelsHigh) /** texture name */ diff --git a/cocos2dx/textures/CCTextureAtlas.cpp b/cocos2dx/textures/CCTextureAtlas.cpp index 9dd22e3c56..04532049fb 100644 --- a/cocos2dx/textures/CCTextureAtlas.cpp +++ b/cocos2dx/textures/CCTextureAtlas.cpp @@ -384,7 +384,7 @@ void CCTextureAtlas::insertQuadFromIndex(unsigned int oldIndex, unsigned int new { return; } - // because it is ambigious in iphone, so we implement abs ourself + // because it is ambiguous in iphone, so we implement abs ourselves // unsigned int howMany = abs( oldIndex - newIndex); unsigned int howMany = (oldIndex - newIndex) > 0 ? (oldIndex - newIndex) : (newIndex - oldIndex); unsigned int dst = oldIndex; diff --git a/cocos2dx/textures/CCTextureAtlas.h b/cocos2dx/textures/CCTextureAtlas.h index fd8be63e78..ee9376cfcb 100644 --- a/cocos2dx/textures/CCTextureAtlas.h +++ b/cocos2dx/textures/CCTextureAtlas.h @@ -43,8 +43,8 @@ class CCTexture2D; /** @brief A class that implements a Texture Atlas. Supported features: -* The atlas file can be a PVRTC, PNG or any other fomrat supported by Texture2D -* Quads can be udpated in runtime +* The atlas file can be a PVRTC, PNG or any other format supported by Texture2D +* Quads can be updated in runtime * Quads can be added in runtime * Quads can be removed in runtime * Quads can be re-ordered in runtime diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 7daf06cd58..c150af905b 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -151,7 +151,7 @@ static void* loadImage(void* data) CCImage::EImageFormat imageType = computeImageFormatType(pAsyncStruct->filename); if (imageType == CCImage::kFmtUnKnown) { - CCLOG("unsupportted format %s",filename); + CCLOG("unsupported format %s",filename); delete pAsyncStruct; continue; @@ -475,7 +475,7 @@ CCTexture2D * CCTextureCache::addImage(const char * path) #ifdef CC_SUPPORT_PVRTC CCTexture2D* CCTextureCache::addPVRTCImage(const char* path, int bpp, bool hasAlpha, int width) { - CCAssert(path != NULL, "TextureCache: fileimage MUST not be nill"); + CCAssert(path != NULL, "TextureCache: fileimage MUST not be nil"); CCAssert( bpp==2 || bpp==4, "TextureCache: bpp must be either 2 or 4"); CCTexture2D * texture; @@ -513,7 +513,7 @@ CCTexture2D* CCTextureCache::addPVRTCImage(const char* path, int bpp, bool hasAl CCTexture2D * CCTextureCache::addPVRImage(const char* path) { - CCAssert(path != NULL, "TextureCache: fileimage MUST not be nill"); + CCAssert(path != NULL, "TextureCache: fileimage MUST not be nil"); CCTexture2D* texture = NULL; std::string key(path); @@ -546,7 +546,7 @@ CCTexture2D * CCTextureCache::addPVRImage(const char* path) CCTexture2D* CCTextureCache::addUIImage(CCImage *image, const char *key) { - CCAssert(image != NULL, "TextureCache: image MUST not be nill"); + CCAssert(image != NULL, "TextureCache: image MUST not be nil"); CCTexture2D * texture = NULL; // textureForKey() use full path,so the key should be full path diff --git a/cocos2dx/textures/CCTextureCache.h b/cocos2dx/textures/CCTextureCache.h index d21bf1a663..3f7bb1ef01 100644 --- a/cocos2dx/textures/CCTextureCache.h +++ b/cocos2dx/textures/CCTextureCache.h @@ -72,7 +72,7 @@ public: CCDictionary* snapshotTextures(); - /** Retruns ths shared instance of the cache */ + /** Returns the shared instance of the cache */ static CCTextureCache * sharedTextureCache(); /** purges the cache. It releases the retained instance. @@ -83,7 +83,7 @@ public: /** Returns a Texture2D object given an file image * If the file image was not previously loaded, it will create a new CCTexture2D * object and it will return it. It will use the filename as a key. - * Otherwise it will return a reference of a previosly loaded image. + * Otherwise it will return a reference of a previously loaded image. * Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr, .gif */ CCTexture2D* addImage(const char* fileimage); @@ -128,7 +128,7 @@ public: /** Removes unused textures * Textures that have a retain count of 1 will be deleted - * It is convinient to call this method after when starting a new Scene + * It is convenient to call this method after when starting a new Scene * @since v0.8 */ void removeUnusedTextures(); @@ -152,7 +152,7 @@ public: #ifdef CC_SUPPORT_PVRTC /** Returns a Texture2D object given an PVRTC RAW filename * If the file image was not previously loaded, it will create a new CCTexture2D - * object and it will return it. Otherwise it will return a reference of a previosly loaded image + * object and it will return it. Otherwise it will return a reference of a previously loaded image * * It can only load square images: width == height, and it must be a power of 2 (128,256,512...) * bpp can only be 2 or 4. 2 means more compression but lower quality. @@ -163,7 +163,7 @@ public: /** Returns a Texture2D object given an PVR filename * If the file image was not previously loaded, it will create a new CCTexture2D - * object and it will return it. Otherwise it will return a reference of a previosly loaded image + * object and it will return it. Otherwise it will return a reference of a previously loaded image */ CCTexture2D* addPVRImage(const char* filename); diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp old mode 100755 new mode 100644 index 5e1e10eb78..eb28b96134 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -47,7 +47,7 @@ enum { kPVRTextureFlagBumpmap = (1<<10), // has normals encoded for a bump map kPVRTextureFlagTiling = (1<<11), // is bordered for tiled pvr kPVRTextureFlagCubemap = (1<<12), // is a cubemap/skybox - kPVRTextureFlagFalseMipCol = (1<<13), // are there false coloured MIP levels + kPVRTextureFlagFalseMipCol = (1<<13), // are there false colored MIP levels kPVRTextureFlagVolume = (1<<14), // is this a volume texture kPVRTextureFlagAlpha = (1<<15), // v2.1 is there transparency info in the texture kPVRTextureFlagVerticalFlip = (1<<16), // v2.1 is the texture vertically flipped @@ -195,7 +195,7 @@ bool CCTexturePVR::unpackPVRData(unsigned char* data, unsigned int len) if (! configuration->supportsNPOT() && (header->width != ccNextPOT(header->width) || header->height != ccNextPOT(header->height))) { - CCLOG("cocos2d: ERROR: Loding an NPOT texture (%dx%d) but is not supported on this device", header->width, header->height); + CCLOG("cocos2d: ERROR: Loading an NPOT texture (%dx%d) but is not supported on this device", header->width, header->height); return false; } @@ -207,7 +207,7 @@ bool CCTexturePVR::unpackPVRData(unsigned char* data, unsigned int len) //Reset num of mipmaps m_uNumberOfMipmaps = 0; - //Get size of maimap + //Get size of mipmap m_uWidth = width = CC_SWAP_INT32_LITTLE_TO_HOST(header->width); m_uHeight = height = CC_SWAP_INT32_LITTLE_TO_HOST(header->height); @@ -270,14 +270,14 @@ bool CCTexturePVR::unpackPVRData(unsigned char* data, unsigned int len) unsigned int packetLength = (dataLength - dataOffset); packetLength = packetLength > dataSize ? dataSize : packetLength; - //Make record to the mipmaps array and increment coutner + //Make record to the mipmaps array and increment counter m_asMipmaps[m_uNumberOfMipmaps].address = bytes + dataOffset; m_asMipmaps[m_uNumberOfMipmaps].len = packetLength; m_uNumberOfMipmaps++; //Check that we didn't overflow CCAssert(m_uNumberOfMipmaps < CC_PVRMIPMAP_MAX, - "TexturePVR: Maximum number of mimpaps reached. Increate the CC_PVRMIPMAP_MAX value"); + "TexturePVR: Maximum number of mipmaps reached. Increase the CC_PVRMIPMAP_MAX value"); dataOffset += packetLength; diff --git a/cocos2dx/textures/CCTexturePVR.h b/cocos2dx/textures/CCTexturePVR.h index 2893cf3c93..6ebb031b0e 100644 --- a/cocos2dx/textures/CCTexturePVR.h +++ b/cocos2dx/textures/CCTexturePVR.h @@ -39,7 +39,7 @@ NS_CC_BEGIN */ /** - @brief Structure which can tell where mimap begins and how long is it + @brief Structure which can tell where mipmap begins and how long is it */ struct CCPVRMipmap { unsigned char *address; @@ -47,7 +47,7 @@ struct CCPVRMipmap { }; /** - @brief Detemine how many mipmaps can we have. + @brief Determine how many mipmaps can we have. Its same as define but it respects namespaces */ enum { diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp index 91cc21bd7b..a45d7a900d 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp @@ -199,7 +199,7 @@ void CCTMXLayer::setupTiles() } CCAssert( m_uMaxGID >= m_pTileSet->m_uFirstGid && - m_uMinGID >= m_pTileSet->m_uFirstGid, "TMX: Only 1 tilset per layer is supported"); + m_uMinGID >= m_pTileSet->m_uFirstGid, "TMX: Only 1 tileset per layer is supported"); } // CCTMXLayer - Properties @@ -306,7 +306,7 @@ CCSprite* CCTMXLayer::reusedTileWithRect(CCRect rect) } else { - // XXX: should not be re-init. Potential memeory leak. Not following best practices + // XXX: should not be re-init. Potential memory leak. Not following best practices // XXX: it shall call directory [setRect:rect] m_pReusedTile->initWithTexture(m_pobTextureAtlas->getTexture(), rect, false); diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h index 018193f690..0ebfc48206 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h @@ -53,12 +53,12 @@ If the layer contains a property named "cc_vertexz" with an integer (in can be p then all the tiles belonging to the layer will use that value as their OpenGL vertex Z for depth. On the other hand, if the "cc_vertexz" property has the "automatic" value, then the tiles will use an automatic vertex Z value. -Also before drawing the tiles, GL_ALPHA_TEST will be enabled, and disabled after drawin them. The used alpha func will be: +Also before drawing the tiles, GL_ALPHA_TEST will be enabled, and disabled after drawing them. The used alpha func will be: glAlphaFunc( GL_GREATER, value ) "value" by default is 0, but you can change it from Tiled by adding the "cc_alpha_func" property to the layer. -The value 0 should work for most cases, but if you have tiles that are semi-transparent, then you might want to use a differnt +The value 0 should work for most cases, but if you have tiles that are semi-transparent, then you might want to use a different value, like 0.5. For further information, please see the programming guide: @@ -75,11 +75,11 @@ class CC_DLL CCTMXLayer : public CCSpriteBatchNode { /** size of the layer in tiles */ CC_SYNTHESIZE_PASS_BY_REF(CCSize, m_tLayerSize, LayerSize); - /** size of the map's tile (could be differnt from the tile's size) */ + /** size of the map's tile (could be different from the tile's size) */ CC_SYNTHESIZE_PASS_BY_REF(CCSize, m_tMapTileSize, MapTileSize); /** pointer to the map of tiles */ CC_SYNTHESIZE(unsigned int*, m_pTiles, Tiles); - /** Tilset information for the layer */ + /** Tileset information for the layer */ CC_PROPERTY(CCTMXTilesetInfo*, m_pTileSet, TileSet); /** Layer orientation, which is the same as the map orientation */ CC_SYNTHESIZE(unsigned int, m_uLayerOrientation, LayerOrientation); @@ -168,7 +168,7 @@ private: CCPoint calculateLayerOffset(const CCPoint& offset); - /* optimization methos */ + /* optimization methods */ CCSprite* appendTileForGID(unsigned int gid, const CCPoint& pos); CCSprite* insertTileForGID(unsigned int gid, const CCPoint& pos); CCSprite* updateTileForGID(unsigned int gid, const CCPoint& pos); diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.h b/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.h index a1013dfd8b..6e672cd625 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.h @@ -42,7 +42,7 @@ class CCTMXMapInfo; * @{ */ -/** Possible oritentations of the TMX map */ +/** Possible orientations of the TMX map */ enum { /** Orthogonal orientation */ @@ -64,7 +64,7 @@ It also supports object groups, objects, and properties. Features: - Each tile will be treated as an CCSprite - The sprites are created on demand. They will be created only when you call "layer->tileAt(position)" -- Each tile can be rotated / moved / scaled / tinted / "opacitied", since each tile is a CCSprite +- Each tile can be rotated / moved / scaled / tinted / "opaqued", since each tile is a CCSprite - Tiles can be added/removed in runtime - The z-order of the tiles can be modified in runtime - Each tile has an anchorPoint of (0,0) @@ -80,7 +80,7 @@ Features: Limitations: - It only supports one tileset per layer. -- Embeded images are not supported +- Embedded images are not supported - It only supports the XML format (the JSON format is not supported) Technical description: @@ -147,7 +147,7 @@ public: /** return the TMXLayer for the specific layer */ CCTMXLayer* layerNamed(const char *layerName); - /** return the TMXObjectGroup for the secific group */ + /** return the TMXObjectGroup for the specific group */ CCTMXObjectGroup* objectGroupNamed(const char *groupName); /** return the value for the specific property name */ diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp index ada929a961..b11d4812d7 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp @@ -43,7 +43,7 @@ using namespace std; #include #include #include -#endf +#endif */ NS_CC_BEGIN @@ -652,7 +652,7 @@ void CCTMXMapInfo::endElement(void *ctx, const char *name) int inflatedLen = ZipUtils::ccInflateMemoryWithHint(buffer, len, &deflated, sizeHint); CCAssert(inflatedLen == sizeHint, ""); - inflatedLen = (size_t)&inflatedLen; // XXX: to avoid warings in compiler + inflatedLen = (size_t)&inflatedLen; // XXX: to avoid warnings in compiler delete [] buffer; buffer = NULL; diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h index fddc70fc2a..c1fe4522bf 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h @@ -106,7 +106,7 @@ public: /** @brief CCTMXTilesetInfo contains the information about the tilesets like: - Tileset name -- Tilset spacing +- Tileset spacing - Tileset margin - size of the tiles - Image used for the tiles @@ -166,7 +166,7 @@ public: CC_SYNTHESIZE(unsigned int, m_uParentGID, ParentGID); /// layer attribs CC_SYNTHESIZE(int, m_nLayerAttribs, LayerAttribs); - /// is stroing characters? + /// is storing characters? CC_SYNTHESIZE(bool, m_bStoringCharacters, StoringCharacters); /// properties CC_PROPERTY(CCDictionary*, m_pProperties, Properties); @@ -177,13 +177,13 @@ public: static CCTMXMapInfo * formatWithTMXFile(const char *tmxFile); /** creates a TMX Format with an XML string and a TMX resource path */ static CCTMXMapInfo * formatWithXML(const char* tmxString, const char* resourcePath); - /** initializes a TMX format witha tmx file */ + /** initializes a TMX format with a tmx file */ bool initWithTMXFile(const char *tmxFile); /** initializes a TMX format with an XML string and a TMX resource path */ bool initWithXML(const char* tmxString, const char* resourcePath); - /** initalises parsing of an XML file, either a tmx (Map) file or tsx (Tileset) file */ + /** initializes parsing of an XML file, either a tmx (Map) file or tsx (Tileset) file */ bool parseXMLFile(const char *xmlFilename); - /* initalises parsing of an XML string, either a tmx (Map) string or tsx (Tileset) string */ + /* initializes parsing of an XML string, either a tmx (Map) string or tsx (Tileset) string */ bool parseXMLString(const char *xmlString); CCDictionary* getTileProperties(); diff --git a/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.cpp b/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.cpp index 8a1b885aae..0b3f375425 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.cpp @@ -131,7 +131,7 @@ void CCTileMapAtlas::loadTGAfile(const char *file) #if 1 if( m_pTGAInfo->status != TGA_OK ) { - CCAssert(0, "TileMapAtlasLoadTGA : TileMapAtas cannot load TGA file"); + CCAssert(0, "TileMapAtlasLoadTGA : TileMapAtlas cannot load TGA file"); } #endif } @@ -156,7 +156,7 @@ void CCTileMapAtlas::setTile(const ccColor3B& tile, const ccGridSize& position) ptr[position.x + position.y * m_pTGAInfo->width] = tile; // XXX: this method consumes a lot of memory - // XXX: a tree of something like that shall be impolemented + // XXX: a tree of something like that shall be implemented CCInteger *num = (CCInteger*)m_pPosToAtlasIndex->objectForKey(CCString::createWithFormat("%ld,%ld", (long)position.x, (long)position.y)->getCString()); diff --git a/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.h b/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.h index 822b4b34ef..0994166cd8 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.h @@ -93,7 +93,7 @@ private: void updateAtlasValues(); protected: - //! x,y to altas dicctionary + //! x,y to atlas dictionary CCDictionary* m_pPosToAtlasIndex; //! numbers of tiles to render int m_nItemsToRender; diff --git a/cocos2dx/touch_dispatcher/CCTouchDelegateProtocol.h b/cocos2dx/touch_dispatcher/CCTouchDelegateProtocol.h index 6770d1e421..4565ae52a4 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDelegateProtocol.h +++ b/cocos2dx/touch_dispatcher/CCTouchDelegateProtocol.h @@ -72,7 +72,7 @@ public: them. You get exactly one UITouch per call. - 2. You can *claim* a UITouch by returning YES in ccTouchBegan. Updates of claimed touches are sent only to the delegate(s) that claimed them. So if you get a move/ - ended/cancelled update you're sure it's your touch. This frees you from doing a + ended/canceled update you're sure it's your touch. This frees you from doing a lot of checks when doing multi-touch. (The name TargetedTouchDelegate relates to updates "targeting" their specific @@ -94,7 +94,7 @@ public: }; /** @brief - This type of delegate is the same one used by CocoaTouch. You will receive all the events (Began,Moved,Ended,Cancelled). + This type of delegate is the same one used by CocoaTouch. You will receive all the events (Began,Moved,Ended,Canceled). @since v0.8 */ class CC_DLL CCStandardTouchDelegate : public CCTouchDelegate diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp index e37f3d053d..315b1a14d9 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp @@ -136,7 +136,7 @@ void CCTouchDispatcher::addStandardDelegate(CCTouchDelegate *pDelegate, int nPri } else { - /* If pHandler is contained in m_pHandlersToRemove, if so remove it from m_pHandlersToRemove and retrun. + /* If pHandler is contained in m_pHandlersToRemove, if so remove it from m_pHandlersToRemove and return. * Refer issue #752(cocos2d-x) */ if (ccCArrayContainsValue(m_pHandlersToRemove, pDelegate)) @@ -159,7 +159,7 @@ void CCTouchDispatcher::addTargetedDelegate(CCTouchDelegate *pDelegate, int nPri } else { - /* If pHandler is contained in m_pHandlersToRemove, if so remove it from m_pHandlersToRemove and retrun. + /* If pHandler is contained in m_pHandlersToRemove, if so remove it from m_pHandlersToRemove and return. * Refer issue #752(cocos2d-x) */ if (ccCArrayContainsValue(m_pHandlersToRemove, pDelegate)) @@ -216,7 +216,7 @@ void CCTouchDispatcher::removeDelegate(CCTouchDelegate *pDelegate) } else { - /* If pHandler is contained in m_pHandlersToAdd, if so remove it from m_pHandlersToAdd and retrun. + /* If pHandler is contained in m_pHandlersToAdd, if so remove it from m_pHandlersToAdd and return. * Refer issue #752(cocos2d-x) */ CCTouchHandler *pHandler = findHandler(m_pHandlersToAdd, pDelegate); @@ -365,7 +365,7 @@ void CCTouchDispatcher::touches(CCSet *pTouches, CCEvent *pEvent, unsigned int u } else if (pHandler->getClaimedTouches()->containsObject(pTouch)) { - // moved ended cancelled + // moved ended canceled bClaimed = true; switch (sHelper.m_type) diff --git a/cocos2dx/touch_dispatcher/CCTouchHandler.h b/cocos2dx/touch_dispatcher/CCTouchHandler.h index 89b9d02a2a..1b6eb222c1 100644 --- a/cocos2dx/touch_dispatcher/CCTouchHandler.h +++ b/cocos2dx/touch_dispatcher/CCTouchHandler.h @@ -73,7 +73,7 @@ protected: }; /** CCStandardTouchHandler - It forwardes each event to the delegate. + It forwards each event to the delegate. */ class CC_DLL CCStandardTouchHandler : public CCTouchHandler { @@ -88,7 +88,7 @@ public: /** CCTargetedTouchHandler - Object than contains the claimed touches and if it swallos touches. + Object than contains the claimed touches and if it swallows touches. Used internally by TouchDispatcher */ class CC_DLL CCTargetedTouchHandler : public CCTouchHandler diff --git a/samples/HelloCpp/Classes/HelloWorldScene.h b/samples/HelloCpp/Classes/HelloWorldScene.h index e202b8c2c3..654c107b3e 100644 --- a/samples/HelloCpp/Classes/HelloWorldScene.h +++ b/samples/HelloCpp/Classes/HelloWorldScene.h @@ -9,7 +9,7 @@ public: // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone virtual bool init(); - // there's no 'id' in cpp, so we recommand to return the exactly class pointer + // there's no 'id' in cpp, so we recommend returning the class instance pointer static cocos2d::CCScene* scene(); // a selector callback diff --git a/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.cpp index 88577cd02c..01eedc43ca 100644 --- a/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.cpp @@ -51,7 +51,7 @@ void AppDelegate::applicationDidEnterBackground() { CCDirector::sharedDirector()->pause(); - // if you use SimpleAudioEngine, it must be pause + // if you use SimpleAudioEngine, it must be paused // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); } diff --git a/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm index 96281719a6..a1f7a904c2 100644 --- a/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm @@ -76,7 +76,7 @@ static AppDelegate s_sharedApplication; - (void)applicationWillEnterForeground:(UIApplication *)application { /* - Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. + Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. */ cocos2d::CCApplication::sharedApplication()->applicationWillEnterForeground(); } diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp index 41237a35e9..0a066f1849 100644 --- a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp @@ -51,7 +51,7 @@ void AppDelegate::applicationDidEnterBackground() { CCDirector::sharedDirector()->stopAnimation(); - // if you use SimpleAudioEngine, it must be pause + // if you use SimpleAudioEngine, it must be paused // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); } From 44e5bdf7a8536551fb319d412919b9662b95fef1 Mon Sep 17 00:00:00 2001 From: dualface Date: Mon, 17 Sep 2012 15:12:13 +0800 Subject: [PATCH 032/181] restore CCDirector --- cocos2dx/CCDirector.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 41b6361faf..a8c3144428 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -73,20 +73,21 @@ NS_CC_BEGIN // XXX it shoul be a Director ivar. Move it there once support for multiple directors is added // singleton stuff -static CCDisplayLinkDirector *s_SharedDirector = NULL; +static CCDisplayLinkDirector s_SharedDirector; #define kDefaultFPS 60 // 60 frames per second extern const char* cocos2dVersion(void); CCDirector* CCDirector::sharedDirector(void) { - if (!s_SharedDirector) + static bool s_bFirstUseDirector = true; + if (s_bFirstUseDirector) { - s_SharedDirector = new CCDisplayLinkDirector(); - s_SharedDirector->init(); + s_bFirstUseDirector = false; + s_SharedDirector.init(); } - return s_SharedDirector; + return &s_SharedDirector; } CCDirector::CCDirector(void) @@ -161,7 +162,7 @@ bool CCDirector::init(void) CCDirector::~CCDirector(void) { - CCLOG("cocos2d: deallocing CCDirector %p", this); + CCLOG("cocos2d: deallocing %p", this); CC_SAFE_RELEASE(m_pFPSLabel); CC_SAFE_RELEASE(m_pSPFLabel); @@ -184,8 +185,6 @@ CCDirector::~CCDirector(void) CC_SAFE_DELETE(m_pLastUpdate); // delete fps string delete []m_pszFPS; - - s_SharedDirector = NULL; } void CCDirector::setGLDefaultValues(void) @@ -594,7 +593,6 @@ void CCDirector::purgeDirector() { // cleanup scheduler getScheduler()->unscheduleAllSelectors(); - getActionManager()->removeAllActions(); // don't release the event handlers // They are needed in case the director is run again @@ -645,9 +643,6 @@ void CCDirector::purgeDirector() // OpenGL view m_pobOpenGLView->end(); m_pobOpenGLView = NULL; - - // delete CCDirector - release(); } void CCDirector::setNextScene(void) From 0c4b5dd3e9d8ae7d07135dfc7f160d8ca832f6c2 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 17 Sep 2012 15:31:07 +0800 Subject: [PATCH 033/181] issue #1470:fix some crashes --- .../HelloCocosBuilder/HelloCocosBuilderLayer.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp index 224f8ca466..d40c3ba3bc 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp +++ b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp @@ -26,7 +26,7 @@ void HelloCocosBuilderLayer::openTest(const char * pCCBFileName, const char * pC /* Create an autorelease CCNodeLoaderLibrary. */ CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary(); - ccNodeLoaderLibrary->registerCCNodeLoader("TestHeader", TestHeaderLayerLoader::loader()); + ccNodeLoaderLibrary->registerCCNodeLoader("TestHeaderLayer", TestHeaderLayerLoader::loader()); if(pCCNodeName != NULL && pCCNodeLoader != NULL) { ccNodeLoaderLibrary->registerCCNodeLoader(pCCNodeName, pCCNodeLoader); } @@ -90,25 +90,25 @@ bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(CCObject * pTarget, CCStr void HelloCocosBuilderLayer::onMenuTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - this->openTest("TestMenus.ccbi", "TestMenus", MenuTestLayerLoader::loader()); + this->openTest("TestMenus.ccbi", "TestMenusLayer", MenuTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onSpriteTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - this->openTest("TestSprites.ccbi", "TestSprites", SpriteTestLayerLoader::loader()); + this->openTest("TestSprites.ccbi", "TestSpritesLayer", SpriteTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onButtonTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - this->openTest("TestButtons.ccbi", "TestButtons", ButtonTestLayerLoader::loader()); + this->openTest("TestButtons.ccbi", "TestButtonsLayer", ButtonTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onLabelTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - this->openTest("TestLabels.ccbi", "TestLabels", LabelTestLayerLoader::loader()); + this->openTest("TestLabels.ccbi", "TestLabelsLayer", LabelTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onParticleSystemTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - this->openTest("TestParticleSystems.ccbi", "TestParticleSystems", ParticleSystemTestLayerLoader::loader()); + this->openTest("TestParticleSystems.ccbi", "TestParticleSystemsLayer", ParticleSystemTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onScrollViewTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - this->openTest("TestScrollViews.ccbi", "TestScrollViews", ScrollViewTestLayerLoader::loader()); + this->openTest("TestScrollViews.ccbi", "TestScrollViewsLayer", ScrollViewTestLayerLoader::loader()); } \ No newline at end of file From cf5f3dedc771dcb6db6c183d15282fddf7c54737 Mon Sep 17 00:00:00 2001 From: dualface Date: Mon, 17 Sep 2012 17:58:21 +0800 Subject: [PATCH 034/181] [Win32] disable CCTextureAtlas use VAO, some windows display adapter driver cannot support VAO --- cocos2dx/include/ccConfig.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2dx/include/ccConfig.h b/cocos2dx/include/ccConfig.h index 4b3c3ba753..6447343a35 100755 --- a/cocos2dx/include/ccConfig.h +++ b/cocos2dx/include/ccConfig.h @@ -165,9 +165,10 @@ Only valid for cocos2d-mac. Not supported on cocos2d-ios. */ #ifndef CC_TEXTURE_ATLAS_USE_VAO - #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) + #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) #define CC_TEXTURE_ATLAS_USE_VAO 1 #else + /* Some Windows display adapter driver cannot support VAO. */ /* Some android devices cannot support VAO very well, so we disable it by default for android platform. */ /* Blackberry also doesn't support this feature. */ #define CC_TEXTURE_ATLAS_USE_VAO 0 From 4b969e35c8fc901906e45680b0b57fb7b521e5ea Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 17 Sep 2012 18:49:05 +0800 Subject: [PATCH 035/181] issue #1470:implement animation --- extensions/CCBReader/CCBAnimationManager.cpp | 13 ++++- extensions/CCBReader/CCBValue.cpp | 1 - extensions/CCBReader/CCNodeLoader.cpp | 5 +- .../AnimationsTest/AnimationsLayerLoader.h | 18 ++++++ .../AnimationsTest/AnimationsTestLayer.cpp | 57 +++++++++++++++++++ .../AnimationsTest/AnimationsTestLayer.h | 33 +++++++++++ .../HelloCocosBuilderLayer.cpp | 45 ++++++++++++++- .../HelloCocosBuilderLayer.h | 2 +- .../project.pbxproj.REMOVED.git-id | 2 +- 9 files changed, 164 insertions(+), 12 deletions(-) create mode 100644 samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsLayerLoader.h create mode 100644 samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp create mode 100644 samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h diff --git a/extensions/CCBReader/CCBAnimationManager.cpp b/extensions/CCBReader/CCBAnimationManager.cpp index 66624b80d6..9ba3bad7b1 100644 --- a/extensions/CCBReader/CCBAnimationManager.cpp +++ b/extensions/CCBReader/CCBAnimationManager.cpp @@ -184,7 +184,7 @@ CCBSequence* CCBAnimationManager::getSequence(int nSequenceId) // Refer to CCBReader::readKeyframe() for the real type of value CCActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const char *pPropName, CCNode *pNode) { - float duration = pKeyframe1->getTime() - pKeyframe0->getTime(); + float duration = pKeyframe1->getTime() - (pKeyframe0 ? pKeyframe0->getTime() : 0); if (strcmp(pPropName, "rotation") == 0) { @@ -325,8 +325,18 @@ void CCBAnimationManager::setAnimatedProperty(const char *pPropName, CCNode *pNo int opacity = ((CCBValue*)pValue)->getByteValue(); (dynamic_cast(pNode))->setOpacity(opacity); } + else if (strcmp(pPropName, "displayFrame") == 0) + { + ((CCSprite*)pNode)->setDisplayFrame((CCSpriteFrame*)pValue); + } + else if (strcmp(pPropName, "color") == 0) + { + ccColor3BWapper *color = (ccColor3BWapper*)pValue; + ((CCSprite*)pNode)->setColor(color->getColor()); + } else { + CCLog("unsupported property name is %s", pPropName); CCAssert(false, "unsupported property now"); } } @@ -489,7 +499,6 @@ void CCBAnimationManager::runAnimations(int nSeqId, float fTweenDuration) if (nodeBaseValues) { CCDictElement* pElement2 = NULL; - //CCLog("nodeBaseValues get value for key %d", pElement->getIntKey()); CCDICT_FOREACH(nodeBaseValues, pElement2) { if (seqNodePropNames.find(pElement2->getStrKey()) != seqNodePropNames.end()) diff --git a/extensions/CCBReader/CCBValue.cpp b/extensions/CCBReader/CCBValue.cpp index a4a72ad9f8..3be6398bc1 100644 --- a/extensions/CCBReader/CCBValue.cpp +++ b/extensions/CCBReader/CCBValue.cpp @@ -95,7 +95,6 @@ CCBValue* CCBValue::create(const void *pPointer) int CCBValue::getIntValue() { - CCLog("type is %d", mType); assert(mType == kIntValue); return mValue.nValue; diff --git a/extensions/CCBReader/CCNodeLoader.cpp b/extensions/CCBReader/CCNodeLoader.cpp index 227798f697..ef1c383ba2 100644 --- a/extensions/CCBReader/CCNodeLoader.cpp +++ b/extensions/CCBReader/CCNodeLoader.cpp @@ -534,9 +534,6 @@ CCSpriteFrame * CCNodeLoader::parsePropTypeSpriteFrame(CCNode * pNode, CCNode * CCString * spriteSheet = pCCBReader->readCachedString(); CCString * spriteFile = pCCBReader->readCachedString(); - CCLog("sprite file %s", spriteFile->getCString()); - CCLog("sprite sheet %s", spriteSheet->getCString()); - CCSpriteFrame *spriteFrame = NULL; if (spriteFile->length() != 0) { @@ -697,7 +694,7 @@ CCString * CCNodeLoader::parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, // CCString * ttfEnding = CCString::create(".ttf"); - // Fix me if it is wrong + // TODO Fix me if it is wrong /* If the fontTTF comes with the ".ttf" extension, prepend the absolute path. * System fonts come without the ".ttf" extension and do not need the path prepended. */ /* diff --git a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsLayerLoader.h b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsLayerLoader.h new file mode 100644 index 0000000000..7038cd9406 --- /dev/null +++ b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsLayerLoader.h @@ -0,0 +1,18 @@ +#ifndef _ANIMATIONSTESTLAYERLOADER_H_ +#define _ANIMATIONSTESTLAYERLOADER_H_ + +#include "AnimationsTestLayer.h" +#include "CCNodeLoader.h" + +/* Forward declaration. */ +class CCBReader; + +class AnimationsTestLayerLoader : public cocos2d::extension::CCLayerLoader { + public: + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(AnimationsTestLayerLoader, loader); + + protected: + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(AnimationsTestLayer); +}; + +#endif diff --git a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp new file mode 100644 index 0000000000..8769d080d4 --- /dev/null +++ b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp @@ -0,0 +1,57 @@ +#include "AnimationsTestLayer.h" +#include "CCBAnimationManager.h" + +USING_NS_CC; +USING_NS_CC_EXT; + +AnimationsTestLayer::AnimationsTestLayer() +: mAnimationManager(NULL) +{} + +AnimationsTestLayer::~AnimationsTestLayer() +{ + CC_SAFE_RELEASE_NULL(mAnimationManager); +} + +SEL_MenuHandler AnimationsTestLayer::onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) +{ + return NULL; +} + +SEL_CCControlHandler AnimationsTestLayer::onResolveCCBCCControlSelector(CCObject *pTarget, CCString*pSelectorName) { + CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onCCControlButtonIdleClicked", AnimationsTestLayer::onCCControlButtonIdleClicked); + CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onCCControlButtonWaveClicked", AnimationsTestLayer::onCCControlButtonWaveClicked); + CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onCCControlButtonJumpClicked", AnimationsTestLayer::onCCControlButtonJumpClicked); + CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onCCControlButtonFunkyClicked", AnimationsTestLayer::onCCControlButtonFunkyClicked); + + return NULL; +} + +bool AnimationsTestLayer::onAssignCCBMemberVariable(CCObject * pTarget, CCString * pMemberVariableName, CCNode * pNode) { + CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mAnimationManager", CCBAnimationManager *, this->mAnimationManager); + + return false; +} + +void AnimationsTestLayer::setAnimationManager(cocos2d::extension::CCBAnimationManager *pAnimationManager) +{ + CC_SAFE_RELEASE_NULL(mAnimationManager); + mAnimationManager = pAnimationManager; + CC_SAFE_RETAIN(mAnimationManager); +} + +void AnimationsTestLayer::onCCControlButtonIdleClicked(CCObject *pSender, CCControlEvent pCCControlEvent) { + mAnimationManager->runAnimations("Idle", 0.3f); +} + +void AnimationsTestLayer::onCCControlButtonWaveClicked(CCObject *pSender, CCControlEvent pCCControlEvent) { + mAnimationManager->runAnimations("Wave", 0.3f); +} + +void AnimationsTestLayer::onCCControlButtonJumpClicked(CCObject *pSender, CCControlEvent pCCControlEvent) { + mAnimationManager->runAnimations("Jump", 0.3f); +} + +void AnimationsTestLayer::onCCControlButtonFunkyClicked(CCObject *pSender, CCControlEvent pCCControlEvent) { + mAnimationManager->runAnimations("Funky", 0.3f); +} \ No newline at end of file diff --git a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h new file mode 100644 index 0000000000..fd37933ad6 --- /dev/null +++ b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h @@ -0,0 +1,33 @@ +#ifndef _ANIMATIONSTESTLAYER_H_ +#define _ANIMATIONSTESTLAYER_H_ + +#include "cocos2d.h" +#include "cocos-ext.h" + +class AnimationsTestLayer +: public cocos2d::CCLayer +, public cocos2d::extension::CCBSelectorResolver +, public cocos2d::extension::CCBMemberVariableAssigner +{ +public: + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(AnimationsTestLayer, create); + + AnimationsTestLayer(); + virtual ~AnimationsTestLayer(); + + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName); + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); + virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, cocos2d::CCString * pMemberVariableName, cocos2d::CCNode * pNode); + + void onCCControlButtonIdleClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + void onCCControlButtonWaveClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + void onCCControlButtonJumpClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + void onCCControlButtonFunkyClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + + void setAnimationManager(cocos2d::extension::CCBAnimationManager *pAnimationManager); + +private: + cocos2d::extension::CCBAnimationManager *mAnimationManager; +}; + +#endif \ No newline at end of file diff --git a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp index d40c3ba3bc..d1b69d3bee 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp +++ b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp @@ -7,6 +7,7 @@ #include "../MenuTest/MenuTestLayerLoader.h" #include "../ParticleSystemTest/ParticleSystemTestLayerLoader.h" #include "../ScrollViewTest/ScrollViewTestLayerLoader.h" +#include "../AnimationsTest/AnimationsLayerLoader.h" USING_NS_CC; USING_NS_CC_EXT; @@ -74,7 +75,7 @@ SEL_CCControlHandler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(CCObj CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onMenuTestClicked", HelloCocosBuilderLayer::onMenuTestClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onSpriteTestClicked", HelloCocosBuilderLayer::onSpriteTestClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onButtonTestClicked", HelloCocosBuilderLayer::onButtonTestClicked); - //CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onLabelTestClicked", HelloCocosBuilderLayer::onLabelTestClicked); + CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onAnimationsTestClicked", HelloCocosBuilderLayer::onAnimationsTestClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onParticleSystemTestClicked", HelloCocosBuilderLayer::onParticleSystemTestClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onScrollViewTestClicked", HelloCocosBuilderLayer::onScrollViewTestClicked); @@ -101,8 +102,46 @@ void HelloCocosBuilderLayer::onButtonTestClicked(CCObject * pSender, cocos2d::ex this->openTest("TestButtons.ccbi", "TestButtonsLayer", ButtonTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onLabelTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - this->openTest("TestLabels.ccbi", "TestLabelsLayer", LabelTestLayerLoader::loader()); +void HelloCocosBuilderLayer::onAnimationsTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { + // Load node graph (TestAnimations is a sub class of CCLayer) and retrieve the ccb action manager + CCBAnimationManager *actionManager = NULL; + + /* Create an autorelease CCNodeLoaderLibrary. */ + CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary(); + + ccNodeLoaderLibrary->registerCCNodeLoader("TestHeaderLayer", TestHeaderLayerLoader::loader()); + ccNodeLoaderLibrary->registerCCNodeLoader("TestAnimationsLayer", AnimationsTestLayerLoader::loader()); + + + /* Create an autorelease CCBReader. */ + cocos2d::extension::CCBReader * ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary); + ccbReader->autorelease(); + + /* Read a ccbi file. */ + // Load the scene from the ccbi-file, setting this class as + // the owner will cause lblTestTitle to be set by the CCBReader. + // lblTestTitle is in the TestHeader.ccbi, which is referenced + // from each of the test scenes. + CCNode *animationsTest = ccbReader->readNodeGraphFromFile("TestAnimations.ccbi", this, &actionManager); + ((AnimationsTestLayer*)animationsTest)->setAnimationManager(actionManager); + + this->mTestTitleLabelTTF->setString("TestAnimations.ccbi"); + + CCScene * scene = CCScene::create(); + if(animationsTest != NULL) { + scene->addChild(animationsTest); + } + + /* Push the new scene with a fancy transition. */ + ccColor3B transitionColor; + transitionColor.r = 0; + transitionColor.g = 0; + transitionColor.b = 0; + + CCDirector::sharedDirector()->pushScene(CCTransitionFade::create(0.5f, scene, transitionColor)); + + + //this->openTest("TestAnimations.ccbi", "TestAnimationsLayer", AnimationsTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onParticleSystemTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { diff --git a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h index 3f1a427f02..4530796b48 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h +++ b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h @@ -36,7 +36,7 @@ class HelloCocosBuilderLayer void onMenuTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); void onSpriteTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); void onButtonTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); - void onLabelTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + void onAnimationsTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); void onParticleSystemTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); void onScrollViewTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); diff --git a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id index fc5a9fd776..70df50979e 100644 --- a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -e2979d2a6cf37624621cb54dbfc8e84a9f5a3666 \ No newline at end of file +545c76af355dd3e2c6950e5ea44243aa85083c43 \ No newline at end of file From d92aa8805a43e436421b2dd2887d1234be5dc829 Mon Sep 17 00:00:00 2001 From: jzgenius Date: Mon, 17 Sep 2012 20:59:11 +0800 Subject: [PATCH 036/181] [template] modify AppController, add viewController & window variant. all Xcode template modified. --- template/xcode4/cocos2dx.xctemplate/ios/AppController.h | 3 +++ template/xcode4/cocos2dx.xctemplate/ios/AppController.mm | 3 +++ template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h | 3 +++ template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm | 3 +++ .../xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h | 3 +++ .../xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm | 3 +++ template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h | 3 +++ template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm | 3 +++ template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h | 3 +++ template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm | 3 +++ 10 files changed, 30 insertions(+) diff --git a/template/xcode4/cocos2dx.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx.xctemplate/ios/AppController.h index 4bd3952824..4f51fc6229 100644 --- a/template/xcode4/cocos2dx.xctemplate/ios/AppController.h +++ b/template/xcode4/cocos2dx.xctemplate/ios/AppController.h @@ -13,5 +13,8 @@ RootViewController *viewController; } +@property (nonatomic, retain) UIWindow *window; +@property (nonatomic, retain) RootViewController *viewController; + @end diff --git a/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm index 96281719a6..82acce0269 100644 --- a/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm @@ -15,6 +15,9 @@ @implementation AppController +@synthesize window; +@synthesize viewController; + #pragma mark - #pragma mark Application lifecycle diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h index 4bd3952824..4f51fc6229 100644 --- a/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h +++ b/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h @@ -13,5 +13,8 @@ RootViewController *viewController; } +@property (nonatomic, retain) UIWindow *window; +@property (nonatomic, retain) RootViewController *viewController; + @end diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm index 520b117ea2..a9bf46f84a 100644 --- a/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm @@ -15,6 +15,9 @@ @implementation AppController +@synthesize window; +@synthesize viewController; + #pragma mark - #pragma mark Application lifecycle diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h index 4bd3952824..4f51fc6229 100644 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h +++ b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h @@ -13,5 +13,8 @@ RootViewController *viewController; } +@property (nonatomic, retain) UIWindow *window; +@property (nonatomic, retain) RootViewController *viewController; + @end diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm index 833f59255d..da90ebfae0 100644 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm @@ -15,6 +15,9 @@ @implementation AppController +@synthesize window; +@synthesize viewController; + #pragma mark - #pragma mark Application lifecycle diff --git a/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h index 3d51064ca0..b05d7bf9f7 100644 --- a/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h +++ b/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h @@ -29,5 +29,8 @@ RootViewController *viewController; } +@property (nonatomic, retain) UIWindow *window; +@property (nonatomic, retain) RootViewController *viewController; + @end diff --git a/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm index 96281719a6..82acce0269 100644 --- a/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm @@ -15,6 +15,9 @@ @implementation AppController +@synthesize window; +@synthesize viewController; + #pragma mark - #pragma mark Application lifecycle diff --git a/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h index 3d51064ca0..b05d7bf9f7 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h +++ b/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h @@ -29,5 +29,8 @@ RootViewController *viewController; } +@property (nonatomic, retain) UIWindow *window; +@property (nonatomic, retain) RootViewController *viewController; + @end diff --git a/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm index 6b27e1dcc9..a9cd27a2fe 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm @@ -31,6 +31,9 @@ @implementation AppController +@synthesize window; +@synthesize viewController; + #pragma mark - #pragma mark Application lifecycle From 4cfb3af68241053ae5786b0f9eb23d830a5872ae Mon Sep 17 00:00:00 2001 From: jzgenius Date: Tue, 18 Sep 2012 09:53:18 +0800 Subject: [PATCH 037/181] Revert "[template] modify AppController, add viewController & window variant. all Xcode template modified." This reverts commit d92aa8805a43e436421b2dd2887d1234be5dc829. --- template/xcode4/cocos2dx.xctemplate/ios/AppController.h | 3 --- template/xcode4/cocos2dx.xctemplate/ios/AppController.mm | 3 --- template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h | 3 --- template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm | 3 --- .../xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h | 3 --- .../xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm | 3 --- template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h | 3 --- template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm | 3 --- template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h | 3 --- template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm | 3 --- 10 files changed, 30 deletions(-) diff --git a/template/xcode4/cocos2dx.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx.xctemplate/ios/AppController.h index 4f51fc6229..4bd3952824 100644 --- a/template/xcode4/cocos2dx.xctemplate/ios/AppController.h +++ b/template/xcode4/cocos2dx.xctemplate/ios/AppController.h @@ -13,8 +13,5 @@ RootViewController *viewController; } -@property (nonatomic, retain) UIWindow *window; -@property (nonatomic, retain) RootViewController *viewController; - @end diff --git a/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm index 82acce0269..96281719a6 100644 --- a/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm @@ -15,9 +15,6 @@ @implementation AppController -@synthesize window; -@synthesize viewController; - #pragma mark - #pragma mark Application lifecycle diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h index 4f51fc6229..4bd3952824 100644 --- a/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h +++ b/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h @@ -13,8 +13,5 @@ RootViewController *viewController; } -@property (nonatomic, retain) UIWindow *window; -@property (nonatomic, retain) RootViewController *viewController; - @end diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm index a9bf46f84a..520b117ea2 100644 --- a/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm @@ -15,9 +15,6 @@ @implementation AppController -@synthesize window; -@synthesize viewController; - #pragma mark - #pragma mark Application lifecycle diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h index 4f51fc6229..4bd3952824 100644 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h +++ b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h @@ -13,8 +13,5 @@ RootViewController *viewController; } -@property (nonatomic, retain) UIWindow *window; -@property (nonatomic, retain) RootViewController *viewController; - @end diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm index da90ebfae0..833f59255d 100644 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm @@ -15,9 +15,6 @@ @implementation AppController -@synthesize window; -@synthesize viewController; - #pragma mark - #pragma mark Application lifecycle diff --git a/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h index b05d7bf9f7..3d51064ca0 100644 --- a/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h +++ b/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h @@ -29,8 +29,5 @@ RootViewController *viewController; } -@property (nonatomic, retain) UIWindow *window; -@property (nonatomic, retain) RootViewController *viewController; - @end diff --git a/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm index 82acce0269..96281719a6 100644 --- a/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm @@ -15,9 +15,6 @@ @implementation AppController -@synthesize window; -@synthesize viewController; - #pragma mark - #pragma mark Application lifecycle diff --git a/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h index b05d7bf9f7..3d51064ca0 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h +++ b/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h @@ -29,8 +29,5 @@ RootViewController *viewController; } -@property (nonatomic, retain) UIWindow *window; -@property (nonatomic, retain) RootViewController *viewController; - @end diff --git a/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm index a9cd27a2fe..6b27e1dcc9 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm @@ -31,9 +31,6 @@ @implementation AppController -@synthesize window; -@synthesize viewController; - #pragma mark - #pragma mark Application lifecycle From 19b22be52ea4e02bd3be3f490cb2996e2d3f03f6 Mon Sep 17 00:00:00 2001 From: jzgenius Date: Tue, 18 Sep 2012 09:55:28 +0800 Subject: [PATCH 038/181] [template] modify AppController, add viewController & window variant. all Xcode template modified. --- template/xcode4/cocos2dx.xctemplate/ios/AppController.h | 3 +++ template/xcode4/cocos2dx.xctemplate/ios/AppController.mm | 3 +++ template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h | 3 +++ template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm | 3 +++ .../xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h | 3 +++ .../xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm | 3 +++ template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h | 3 +++ template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm | 3 +++ template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h | 3 +++ template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm | 3 +++ 10 files changed, 30 insertions(+) diff --git a/template/xcode4/cocos2dx.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx.xctemplate/ios/AppController.h index 4bd3952824..4f51fc6229 100644 --- a/template/xcode4/cocos2dx.xctemplate/ios/AppController.h +++ b/template/xcode4/cocos2dx.xctemplate/ios/AppController.h @@ -13,5 +13,8 @@ RootViewController *viewController; } +@property (nonatomic, retain) UIWindow *window; +@property (nonatomic, retain) RootViewController *viewController; + @end diff --git a/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm index 96281719a6..82acce0269 100644 --- a/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm @@ -15,6 +15,9 @@ @implementation AppController +@synthesize window; +@synthesize viewController; + #pragma mark - #pragma mark Application lifecycle diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h index 4bd3952824..4f51fc6229 100644 --- a/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h +++ b/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h @@ -13,5 +13,8 @@ RootViewController *viewController; } +@property (nonatomic, retain) UIWindow *window; +@property (nonatomic, retain) RootViewController *viewController; + @end diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm index 520b117ea2..a9bf46f84a 100644 --- a/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm @@ -15,6 +15,9 @@ @implementation AppController +@synthesize window; +@synthesize viewController; + #pragma mark - #pragma mark Application lifecycle diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h index 4bd3952824..4f51fc6229 100644 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h +++ b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h @@ -13,5 +13,8 @@ RootViewController *viewController; } +@property (nonatomic, retain) UIWindow *window; +@property (nonatomic, retain) RootViewController *viewController; + @end diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm index 833f59255d..da90ebfae0 100644 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm @@ -15,6 +15,9 @@ @implementation AppController +@synthesize window; +@synthesize viewController; + #pragma mark - #pragma mark Application lifecycle diff --git a/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h index 3d51064ca0..b05d7bf9f7 100644 --- a/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h +++ b/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h @@ -29,5 +29,8 @@ RootViewController *viewController; } +@property (nonatomic, retain) UIWindow *window; +@property (nonatomic, retain) RootViewController *viewController; + @end diff --git a/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm index 96281719a6..82acce0269 100644 --- a/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm @@ -15,6 +15,9 @@ @implementation AppController +@synthesize window; +@synthesize viewController; + #pragma mark - #pragma mark Application lifecycle diff --git a/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h index 3d51064ca0..b05d7bf9f7 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h +++ b/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h @@ -29,5 +29,8 @@ RootViewController *viewController; } +@property (nonatomic, retain) UIWindow *window; +@property (nonatomic, retain) RootViewController *viewController; + @end diff --git a/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm index 6b27e1dcc9..a9cd27a2fe 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm @@ -31,6 +31,9 @@ @implementation AppController +@synthesize window; +@synthesize viewController; + #pragma mark - #pragma mark Application lifecycle From a0feb5f2895701a7ae0844182b5ebf5a53ba11cb Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 18 Sep 2012 17:04:10 +0800 Subject: [PATCH 039/181] issue #1470:fix some logical errors --- extensions/CCBReader/CCBAnimationManager.cpp | 16 +++--- extensions/CCBReader/CCBReader.cpp | 11 +++- extensions/CCBReader/CCBReader.h | 4 +- extensions/CCBReader/CCNodeLoader.cpp | 54 ++++---------------- 4 files changed, 30 insertions(+), 55 deletions(-) diff --git a/extensions/CCBReader/CCBAnimationManager.cpp b/extensions/CCBReader/CCBAnimationManager.cpp index 9ba3bad7b1..466617d5c4 100644 --- a/extensions/CCBReader/CCBAnimationManager.cpp +++ b/extensions/CCBReader/CCBAnimationManager.cpp @@ -299,7 +299,7 @@ void CCBAnimationManager::setAnimatedProperty(const char *pPropName, CCNode *pNo } else if (strcmp(pPropName, "scale") == 0) { - // Get position type + // Get scale type CCArray *array = (CCArray*)getBaseValue(pNode, pPropName); int type = ((CCBValue*)array->objectAtIndex(2))->getIntValue(); @@ -314,7 +314,7 @@ void CCBAnimationManager::setAnimatedProperty(const char *pPropName, CCNode *pNo { // [node setValue:value forKey:name]; - // TODO only handle rotation, opacity, + // TODO only handle rotation, opacity, displayFrame, color if (strcmp(pPropName, "rotation") == 0) { float rotate = ((CCBValue*)pValue)->getFloatValue(); @@ -374,7 +374,7 @@ CCActionInterval* CCBAnimationManager::getEaseAction(CCActionInterval *pAction, } else if (nEasingType == kCCBKeyframeEasingCubicOut) { - return CCEaseInOut::create(pAction, fEasingOpt); + return CCEaseOut::create(pAction, fEasingOpt); } else if (nEasingType == kCCBKeyframeEasingCubicInOut) { @@ -485,9 +485,9 @@ void CCBAnimationManager::runAnimations(int nSeqId, float fTweenDuration) CCDictElement* pElement1 = NULL; CCDICT_FOREACH(seqNodeProps, pElement1) { - const char *propNmae = pElement1->getStrKey(); - CCBSequenceProperty *seqProp = (CCBSequenceProperty*)seqNodeProps->objectForKey(propNmae); - seqNodePropNames.insert(propNmae); + const char *propName = pElement1->getStrKey(); + CCBSequenceProperty *seqProp = (CCBSequenceProperty*)seqNodeProps->objectForKey(propName); + seqNodePropNames.insert(propName); setFirstFrame(node, seqProp, fTweenDuration); runAction(node, seqProp, fTweenDuration); @@ -501,13 +501,13 @@ void CCBAnimationManager::runAnimations(int nSeqId, float fTweenDuration) CCDictElement* pElement2 = NULL; CCDICT_FOREACH(nodeBaseValues, pElement2) { - if (seqNodePropNames.find(pElement2->getStrKey()) != seqNodePropNames.end()) + if (seqNodePropNames.find(pElement2->getStrKey()) == seqNodePropNames.end()) { CCObject *value = pElement2->getObject(); if (value) { - setAnimatedProperty(pElement2->getStrKey(), node, value, fTweenDuration); + setAnimatedProperty(pElement2->getStrKey(), node, value, fTweenDuration); } } } diff --git a/extensions/CCBReader/CCBReader.cpp b/extensions/CCBReader/CCBReader.cpp index a2c44f90df..f4718a4731 100644 --- a/extensions/CCBReader/CCBReader.cpp +++ b/extensions/CCBReader/CCBReader.cpp @@ -64,6 +64,7 @@ CCBReader::CCBReader(CCNodeLoaderLibrary * pCCNodeLoaderLibrary, CCBMemberVariab , mCurrentBit(-1) , mOwner(NULL) , mActionManager(NULL) +, mAnimatedProps(NULL) { this->mCCNodeLoaderLibrary = pCCNodeLoaderLibrary; this->mCCNodeLoaderLibrary->retain(); @@ -79,6 +80,7 @@ CCBReader::CCBReader(CCBReader * pCCBReader) , mCurrentBit(-1) , mOwner(NULL) , mActionManager(NULL) +, mAnimatedProps(NULL) { this->mLoadedSpriteSheets = pCCBReader->mLoadedSpriteSheets; this->mCCNodeLoaderLibrary = pCCBReader->mCCNodeLoaderLibrary; @@ -100,6 +102,7 @@ CCBReader::CCBReader() , mCCNodeLoaderListener(NULL) , mCCBMemberVariableAssigner(NULL) , mCCBSelectorResolver(NULL) +, mAnimatedProps(NULL) {} CCBReader::~CCBReader() { @@ -161,7 +164,7 @@ CCBSelectorResolver * CCBReader::getCCBSelectorResolver() { return this->mCCBSelectorResolver; } -set& CCBReader::getAnimatedProperties() +set* CCBReader::getAnimatedProperties() { return mAnimatedProps; } @@ -477,6 +480,7 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) { // Read animated properties CCDictionary *seqs = CCDictionary::create(); + mAnimatedProps = new set(); int numSequence = readInt(false); for (int i = 0; i < numSequence; ++i) @@ -493,7 +497,7 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) { seqProp->setName(readCachedString()->getCString()); seqProp->setType(readInt(false)); - mAnimatedProps.insert(seqProp->getName()); + mAnimatedProps->insert(seqProp->getName()); int numKeyframes = readInt(false); @@ -569,6 +573,9 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) { } } #endif // CCB_ENABLE_JAVASCRIPT + + delete mAnimatedProps; + mAnimatedProps = NULL; /* Read and add children. */ int numChildren = this->readInt(false); diff --git a/extensions/CCBReader/CCBReader.h b/extensions/CCBReader/CCBReader.h index 534e2198dc..a4314e37d2 100644 --- a/extensions/CCBReader/CCBReader.h +++ b/extensions/CCBReader/CCBReader.h @@ -177,7 +177,7 @@ private: CCObject *mOwner; CCBAnimationManager *mActionManager; - std::set mAnimatedProps; + std::set *mAnimatedProps; CCNodeLoaderLibrary *mCCNodeLoaderLibrary; CCNodeLoaderListener *mCCNodeLoaderListener; @@ -214,7 +214,7 @@ public: void setAnimationManager(CCBAnimationManager *pAnimationManager); // Used in CCNodeLoader::parseProperties() - std::set& getAnimatedProperties(); + std::set* getAnimatedProperties(); std::set& getLoadedSpriteSheet(); CCObject* getOwner(); diff --git a/extensions/CCBReader/CCNodeLoader.cpp b/extensions/CCBReader/CCNodeLoader.cpp index ef1c383ba2..de43f437be 100644 --- a/extensions/CCBReader/CCNodeLoader.cpp +++ b/extensions/CCBReader/CCNodeLoader.cpp @@ -3,6 +3,7 @@ #include "CCBMemberVariableAssigner.h" #include "CCBAnimationManager.h" #include "CCData.h" +#include "CCNode+CCBRelativePositioning.h" using namespace std; @@ -322,43 +323,10 @@ CCPoint CCNodeLoader::parsePropTypePosition(CCNode * pNode, CCNode * pParent, CC CCSize containerSize = pCCBReader->getAnimationManager()->getContainerSize(pParent); - switch (type) - { - case kCCBPositionTypeRelativeBottomLeft: - { - /* Nothing. */ - break; - } - case kCCBPositionTypeRelativeTopLeft: - { - y = containerSize.height - y; - break; - } - case kCCBPositionTypeRelativeTopRight: - { - x = containerSize.width - x; - y = containerSize.height - y; - break; - } - case kCCBPositionTypeRelativeBottomRight: - { - x = containerSize.width - x; - break; - } - case kCCBPositionTypePercent: - { - x = (int)(containerSize.width * x / 100.0f); - y = (int)(containerSize.height * y / 100.0f); - break; - } - case kCCBPositionTypeMultiplyResolution: - { - x *= CCBReader::getResolutionScale(); - y *= CCBReader::getResolutionScale(); - } - } + CCPoint pt = getAbsolutePosition(ccp(x,y), type, containerSize, pPropertyName); + pNode->setPosition(getAbsolutePosition(pt, type, containerSize, pPropertyName));; - if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end()) + if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end()) { CCArray *baseValue = CCArray::create(CCBValue::create(x), CCBValue::create(y), @@ -367,7 +335,7 @@ CCPoint CCNodeLoader::parsePropTypePosition(CCNode * pNode, CCNode * pParent, CC pCCBReader->getAnimationManager()->setBaseValue(baseValue, pNode, pPropertyName); } - return CCPoint(x, y); + return pt; } CCPoint CCNodeLoader::parsePropTypePoint(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) @@ -452,7 +420,7 @@ float * CCNodeLoader::parsePropTypeScaleLock(CCNode * pNode, CCNode * pParent, C scaleLock[0] = x; scaleLock[1] = y; - if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end()) + if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end()) { CCArray *baseValue = CCArray::create(CCBValue::create(x), CCBValue::create(y), @@ -470,7 +438,7 @@ float CCNodeLoader::parsePropTypeFloat(CCNode * pNode, CCNode * pParent, CCBRead float CCNodeLoader::parsePropTypeDegrees(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName) { float ret = pCCBReader->readFloat(); - if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end()) + if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end()) { CCBValue *value = CCBValue::create(ret); pCCBReader->getAnimationManager()->setBaseValue(value, pNode, pPropertyName); @@ -519,7 +487,7 @@ bool CCNodeLoader::parsePropTypeCheck(CCNode * pNode, CCNode * pParent, CCBReade { bool ret = pCCBReader->readBool(); - if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end()) + if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end()) { CCBValue *value = CCBValue::create(ret); pCCBReader->getAnimationManager()->setBaseValue(value, pNode, pPropertyName); @@ -557,7 +525,7 @@ CCSpriteFrame * CCNodeLoader::parsePropTypeSpriteFrame(CCNode * pNode, CCNode * spriteFrame = frameCache->spriteFrameByName(spriteFile->getCString()); } - if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end()) + if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end()) { pCCBReader->getAnimationManager()->setBaseValue(spriteFrame, pNode, pPropertyName); } @@ -607,7 +575,7 @@ unsigned char CCNodeLoader::parsePropTypeByte(CCNode * pNode, CCNode * pParent, { unsigned char ret = pCCBReader->readByte(); - if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end()) + if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end()) { pCCBReader->getAnimationManager()->setBaseValue(CCBValue::create(ret), pNode, pPropertyName); } @@ -621,7 +589,7 @@ ccColor3B CCNodeLoader::parsePropTypeColor3(CCNode * pNode, CCNode * pParent, CC unsigned char blue = pCCBReader->readByte(); ccColor3B color = { red, green, blue }; - if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end()) + if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end()) { ccColor3BWapper *value = ccColor3BWapper::create(color); pCCBReader->getAnimationManager()->setBaseValue(value, pNode, pPropertyName); From 6df8233b0337a75727db3dc203bcb0bff89b8bde Mon Sep 17 00:00:00 2001 From: moadib Date: Tue, 18 Sep 2012 13:15:05 +0400 Subject: [PATCH 041/181] Fixed statement which works but incorrect from point of C++ rules applied to ternary operator and can cause compilation error on compiler different from MSVC --- cocos2dx/platform/win32/CCImage.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cocos2dx/platform/win32/CCImage.cpp b/cocos2dx/platform/win32/CCImage.cpp index d68e3ef098..27d0b69468 100644 --- a/cocos2dx/platform/win32/CCImage.cpp +++ b/cocos2dx/platform/win32/CCImage.cpp @@ -152,7 +152,10 @@ public: pwszBuffer = NULL; } } - fontPath.size()>0?(m_curFontPath = fontPath):(m_curFontPath.clear()); + if (fontPath.size() > 0) + m_curFontPath = fontPath; + else + m_curFontPath.clear(); // register temp font if (m_curFontPath.size() > 0) { From 4bc5e9e41548d293a756b2fa1405eb93fe131e27 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 18 Sep 2012 17:55:03 +0800 Subject: [PATCH 042/181] issue #1470:fix more logical errors --- extensions/CCBReader/CCBAnimationManager.cpp | 7 ++++--- extensions/CCBReader/CCNodeLoader.cpp | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/extensions/CCBReader/CCBAnimationManager.cpp b/extensions/CCBReader/CCBAnimationManager.cpp index 466617d5c4..9448250c6a 100644 --- a/extensions/CCBReader/CCBAnimationManager.cpp +++ b/extensions/CCBReader/CCBAnimationManager.cpp @@ -398,11 +398,11 @@ CCActionInterval* CCBAnimationManager::getEaseAction(CCActionInterval *pAction, } else if (nEasingType == kCCBKeyframeEasingBounceOut) { - return CCEaseBackOut::create(pAction); + return CCEaseBounceOut::create(pAction); } else if (nEasingType == kCCBKeyframeEasingBounceInOut) { - return CCEaseBackInOut::create(pAction); + return CCEaseBounceInOut::create(pAction); } else if (nEasingType == kCCBKeyframeEasingElasticIn) { @@ -677,7 +677,8 @@ void CCBRotateTo::startWithTarget(CCNode *pNode) void CCBRotateTo::update(float time) { - m_pTarget->setRotation(mStartAngle + mDstAngle * time); + m_pTarget->setRotation(mStartAngle + (mDiffAngle * time)) + ; } NS_CC_EXT_END diff --git a/extensions/CCBReader/CCNodeLoader.cpp b/extensions/CCBReader/CCNodeLoader.cpp index de43f437be..5a6ec4919c 100644 --- a/extensions/CCBReader/CCNodeLoader.cpp +++ b/extensions/CCBReader/CCNodeLoader.cpp @@ -410,15 +410,7 @@ float * CCNodeLoader::parsePropTypeScaleLock(CCNode * pNode, CCNode * pParent, C int type = pCCBReader->readInt(false); - if (type == kCCBScaleTypeMultiplyResolution) - { - x *= pCCBReader->getResolutionScale(); - y *= pCCBReader->getResolutionScale(); - } - - float * scaleLock = new float[2]; - scaleLock[0] = x; - scaleLock[1] = y; + setRelativeScale(pNode, x, y, type, pPropertyName); if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end()) { @@ -428,6 +420,16 @@ float * CCNodeLoader::parsePropTypeScaleLock(CCNode * pNode, CCNode * pParent, C NULL); pCCBReader->getAnimationManager()->setBaseValue(baseValue, pNode, pPropertyName); } + + if (type == kCCBScaleTypeMultiplyResolution) + { + x *= pCCBReader->getResolutionScale(); + y *= pCCBReader->getResolutionScale(); + } + + float * scaleLock = new float[2]; + scaleLock[0] = x; + scaleLock[1] = y; return scaleLock; } From 48062e222d5c06ac2216d553576b98b81ffa7e25 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Tue, 18 Sep 2012 11:01:31 -0700 Subject: [PATCH 043/181] Reverted change in scripting/javascript/bindings/Android.mk. --- scripting/javascript/bindings/Android.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/scripting/javascript/bindings/Android.mk b/scripting/javascript/bindings/Android.mk index 4e79ea930c..8923f2aba2 100644 --- a/scripting/javascript/bindings/Android.mk +++ b/scripting/javascript/bindings/Android.mk @@ -9,6 +9,7 @@ LOCAL_MODULE_FILENAME := libscriptingcore-spidermonkey LOCAL_SRC_FILES := ScriptingCore.cpp \ cocos2d_specifics.cpp \ CCPhysicsSprite.cpp \ + cocos2dx.cpp \ js_manual_conversions.cpp \ js_bindings_chipmunk_manual.cpp \ js_bindings_chipmunk_functions.cpp From ad5836a3caddfe2a5de5a6858d1cee4817b6e1e3 Mon Sep 17 00:00:00 2001 From: Byung Choi Date: Wed, 19 Sep 2012 04:42:57 +0900 Subject: [PATCH 044/181] debug & release makefiles for cocos2dx, box2d, chipmunk, cocosdenshion --- CocosDenshion/proj.linux/Makefile | 17 +++++++--- cocos2dx/proj.linux/Makefile | 17 +++++++--- external/Box2D/proj.linux/Makefile | 16 ++++++--- external/chipmunk/proj.linux/Makefile | 17 +++++++--- make-all-linux-project.sh | 48 +++++++++++++++++++-------- 5 files changed, 86 insertions(+), 29 deletions(-) diff --git a/CocosDenshion/proj.linux/Makefile b/CocosDenshion/proj.linux/Makefile index 75066dfe94..14a1383bf1 100644 --- a/CocosDenshion/proj.linux/Makefile +++ b/CocosDenshion/proj.linux/Makefile @@ -1,8 +1,8 @@ CC = gcc CXX = g++ TARGET = libcocosdenshion.so -CCFLAGS = -Wall -g -O2 -fPIC -CXXFLAGS = -Wall -g -O2 -fPIC +CCFLAGS = -Wall -fPIC +CXXFLAGS = -Wall -fPIC VISIBILITY = LBITS := $(shell getconf LONG_BIT) @@ -32,17 +32,26 @@ SHAREDLIBS_DIR = ../third_party/fmod/api/lib SHAREDLIBS = -L$(SHAREDLIBS_DIR) -lfmodex endif +debug: CCFLAGS += -g3 -O0 +debug: CXXFLAGS += -g3 -O0 +debug: DEFINES += -DDEBUG +debug: $(TARGET) + +release: CCFLAGS += -O3 +release: CXXFLAGS += -O3 +release: DEFINES += -DNDEBUG +release: $(TARGET) ####### Build rules $(TARGET): $(OBJECTS) $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(OBJECTS) -shared -o $(TARGET) $(SHAREDLIBS) $(STATICLIBS) - + ####### Compile %.o: %.cpp $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ %.o: %.c $(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ - + clean: rm -f $(OBJECTS) $(TARGET) core diff --git a/cocos2dx/proj.linux/Makefile b/cocos2dx/proj.linux/Makefile index b5d02bbe8e..6cd83fbec4 100644 --- a/cocos2dx/proj.linux/Makefile +++ b/cocos2dx/proj.linux/Makefile @@ -1,8 +1,8 @@ CC = gcc CXX = g++ TARGET = libcocos2d.so -CCFLAGS = -Wall -g -fPIC #-O2 -CXXFLAGS = -Wall -g -fPIC #-O2 +CCFLAGS = -Wall -fPIC +CXXFLAGS = -Wall -fPIC VISIBILITY = LIBS = @@ -202,17 +202,26 @@ SHAREDLIBS += -lglfw -lGL -lcurl SHAREDLIBS += -Wl,-rpath,../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib SHAREDLIBS += -L../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib -lGLEW +debug: CCFLAGS += -g3 -O0 +debug: CXXFLAGS += -g3 -O0 +debug: DEFINES += -DDEBUG +debug: $(TARGET) + +release: CCFLAGS += -O3 +release: CXXFLAGS += -O3 +release: DEFINES += -DNDEBUG +release: $(TARGET) ####### Build rules $(TARGET): $(OBJECTS) $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(OBJECTS) -shared -o $(TARGET) $(SHAREDLIBS) $(STATICLIBS) $(LIBS) - + ####### Compile %.o: %.cpp $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ %.o: %.c $(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ - + clean: rm -f $(OBJECTS) $(TARGET) core diff --git a/external/Box2D/proj.linux/Makefile b/external/Box2D/proj.linux/Makefile index 3e09ed0925..536450aab9 100644 --- a/external/Box2D/proj.linux/Makefile +++ b/external/Box2D/proj.linux/Makefile @@ -2,8 +2,8 @@ CC = gcc CXX = g++ AR = ar TARGET = libbox2d.a -CCFLAGS = -Wall -g -O2 -CXXFLAGS = -Wall -g -O2 +CCFLAGS = -Wall +CXXFLAGS = -Wall ARFLAGS = cr INCLUDES = -I../../ @@ -56,18 +56,26 @@ OBJECTS = ../Collision/Shapes/b2ChainShape.o \ ../Dynamics/b2WorldCallbacks.o \ ../Rope/b2Rope.o +debug: CCFLAGS += -g3 -O0 +debug: CXXFLAGS += -g3 -O0 +debug: DEFINES += -DDEBUG +debug: $(TARGET) +release: CCFLAGS += -O3 +release: CXXFLAGS += -O3 +release: DEFINES += -DNDEBUG +release: $(TARGET) ####### Build rules $(TARGET): $(OBJECTS) $(AR) $(ARFLAGS) $(TARGET) $(OBJECTS) - + ####### Compile %.o: %.cpp $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ %.o: %.c $(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ - + clean: rm -f $(OBJECTS) $(TARGET) core diff --git a/external/chipmunk/proj.linux/Makefile b/external/chipmunk/proj.linux/Makefile index fca7af6d2a..437e66cbc2 100644 --- a/external/chipmunk/proj.linux/Makefile +++ b/external/chipmunk/proj.linux/Makefile @@ -2,8 +2,8 @@ CC = gcc CXX = g++ AR = ar TARGET = libchipmunk.a -CCFLAGS = -Wall -g -O2 -std=gnu99 -CXXFLAGS = -Wall -g -O2 +CCFLAGS = -Wall -std=gnu99 +CXXFLAGS = -Wall ARFLAGS = cr INCLUDES = -I../include/chipmunk @@ -40,17 +40,26 @@ OBJECTS = ../src/chipmunk.o \ ../src/constraints/cpSlideJoint.o \ ../src/constraints/cpPinJoint.o \ +debug: CCFLAGS += -g3 -O0 +debug: CXXFLAGS += -g3 -O0 +debug: DEFINES += -DDEBUG +debug: $(TARGET) + +release: CCFLAGS += -O3 +release: CXXFLAGS += -O3 +release: DEFINES += -DNDEBIG +release: $(TARGET) ####### Build rules $(TARGET): $(OBJECTS) $(AR) $(ARFLAGS) $(TARGET) $(OBJECTS) - + ####### Compile %.o: %.cpp $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ %.o: %.c $(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ - + clean: rm -f $(OBJECTS) $(TARGET) core diff --git a/make-all-linux-project.sh b/make-all-linux-project.sh index 93e12a4225..6fb94bc783 100755 --- a/make-all-linux-project.sh +++ b/make-all-linux-project.sh @@ -6,6 +6,7 @@ TXTCOLOR_GREEN="\033[0;32m" COCOS2DX20_TRUNK=`pwd` OUTPUT_DEBUG=$COCOS2DX20_TRUNK/lib/linux/Debug/ +OUTPUT_RELEASE=$COCOS2DX20_TRUNK/lib/linux/Release/ check_make_result() { @@ -55,30 +56,51 @@ if ! test -d $OUTPUT_DEBUG; then mkdir $OUTPUT_DEBUG -p fi -make -C $COCOS2DX20_TRUNK/external/Box2D/proj.linux +make -C $COCOS2DX20_TRUNK/external/Box2D/proj.linux clean +make -C $COCOS2DX20_TRUNK/external/Box2D/proj.linux debug check_make_result cp $COCOS2DX20_TRUNK/external/Box2D/proj.linux/libbox2d.a $OUTPUT_DEBUG -make -C $COCOS2DX20_TRUNK/external/chipmunk/proj.linux +make -C $COCOS2DX20_TRUNK/external/Box2D/proj.linux clean +make -C $COCOS2DX20_TRUNK/external/Box2D/proj.linux release +check_make_result +cp $COCOS2DX20_TRUNK/external/Box2D/proj.linux/libbox2d.a $OUTPUT_RELEASE + +make -C $COCOS2DX20_TRUNK/external/chipmunk/proj.linux clean +make -C $COCOS2DX20_TRUNK/external/chipmunk/proj.linux debug check_make_result cp $COCOS2DX20_TRUNK/external/chipmunk/proj.linux/libchipmunk.a $OUTPUT_DEBUG -make -C $COCOS2DX20_TRUNK/cocos2dx/proj.linux +make -C $COCOS2DX20_TRUNK/external/chipmunk/proj.linux clean +make -C $COCOS2DX20_TRUNK/external/chipmunk/proj.linux release +check_make_result +cp $COCOS2DX20_TRUNK/external/chipmunk/proj.linux/libchipmunk.a $OUTPUT_RELEASE + +make -C $COCOS2DX20_TRUNK/cocos2dx/proj.linux clean +make -C $COCOS2DX20_TRUNK/cocos2dx/proj.linux debug check_make_result cp $COCOS2DX20_TRUNK/cocos2dx/proj.linux/libcocos2d.so $OUTPUT_DEBUG +rm $COCOS2DX20_TRUNK/cocos2dx/proj.linux/libcocos2d.so -make -C $COCOS2DX20_TRUNK/CocosDenshion/proj.linux +make -C $COCOS2DX20_TRUNK/cocos2dx/proj.linux clean +make -C $COCOS2DX20_TRUNK/cocos2dx/proj.linux release +check_make_result +cp $COCOS2DX20_TRUNK/cocos2dx/proj.linux/libcocos2d.so $OUTPUT_RELEASE +rm $COCOS2DX20_TRUNK/cocos2dx/proj.linux/libcocos2d.so + +make -C $COCOS2DX20_TRUNK/CocosDenshion/proj.linux clean +make -C $COCOS2DX20_TRUNK/CocosDenshion/proj.linux debug check_make_result cp $COCOS2DX20_TRUNK/CocosDenshion/proj.linux/libcocosdenshion.so $OUTPUT_DEBUG - -make -C $COCOS2DX20_TRUNK/samples/TestCpp/proj.linux clean -make -C $COCOS2DX20_TRUNK/samples/TestCpp/proj.linux -check_make_result -make -C $COCOS2DX20_TRUNK/samples/HelloCpp/proj.linux clean -make -C $COCOS2DX20_TRUNK/samples/HelloCpp/proj.linux +make -C $COCOS2DX20_TRUNK/CocosDenshion/proj.linux clean +make -C $COCOS2DX20_TRUNK/CocosDenshion/proj.linux release check_make_result +cp $COCOS2DX20_TRUNK/CocosDenshion/proj.linux/libcocosdenshion.so $OUTPUT_RELEASE -#cd $COCOS2DX20_TRUNK/tests/proj.linux -#./cocos2dx-test -#cd - +#make -C $COCOS2DX20_TRUNK/samples/TestCpp/proj.linux clean +#make -C $COCOS2DX20_TRUNK/samples/TestCpp/proj.linux +#check_make_result +#make -C $COCOS2DX20_TRUNK/samples/HelloCpp/proj.linux clean +#make -C $COCOS2DX20_TRUNK/samples/HelloCpp/proj.linux +#check_make_result From 4a4ef87163500b5ca2e38161869bc0d9908ce5e2 Mon Sep 17 00:00:00 2001 From: Byung Choi Date: Wed, 19 Sep 2012 04:59:33 +0900 Subject: [PATCH 045/181] Fixes #1317 by http://gcc.gnu.org/wiki/Visibility --- cocos2dx/platform/linux/CCPlatformDefine.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2dx/platform/linux/CCPlatformDefine.h b/cocos2dx/platform/linux/CCPlatformDefine.h index 485d01c6b4..d427303599 100644 --- a/cocos2dx/platform/linux/CCPlatformDefine.h +++ b/cocos2dx/platform/linux/CCPlatformDefine.h @@ -4,9 +4,9 @@ #include #if defined(_USRDLL) - #define CC_DLL +#define CC_DLL __attribute__ ((visibility ("default"))) #else /* use a DLL library */ - #define CC_DLL +#define CC_DLL __attribute__ ((visibility ("default"))) #endif #include From 22dba972d050c74bd8d4f1edc713725f139f60a4 Mon Sep 17 00:00:00 2001 From: Ed Bartley Date: Tue, 18 Sep 2012 18:43:50 -0400 Subject: [PATCH 046/181] ignore and android updates --- .gitignore | 1 + create-android-project.sh | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f90ffabac9..9f7f344bcf 100644 --- a/.gitignore +++ b/.gitignore @@ -74,3 +74,4 @@ Device-Release/ # Ignore vim swaps *.swp +projects diff --git a/create-android-project.sh b/create-android-project.sh index 79d63ff2c8..c49445f40f 100755 --- a/create-android-project.sh +++ b/create-android-project.sh @@ -5,8 +5,8 @@ # Don't modify the script until you know what you do. # set environment paramters -NDK_ROOT_LOCAL="/home/laschweinski/android/android-ndk-r5" -ANDROID_SDK_ROOT_LOCAL="/home/laschweinski/android/android-sdk-linux_86" +NDK_ROOT_LOCAL="/Users/ed/dev/android-ndk-r8" +ANDROID_SDK_ROOT_LOCAL="/Users/ed/dev/android-sdk" NEED_BOX2D=false NEED_CHIPMUNK=false From e837cad67bc5aba2afaac5bef8e860a762bc1943 Mon Sep 17 00:00:00 2001 From: Ed Bartley Date: Tue, 18 Sep 2012 18:56:26 -0400 Subject: [PATCH 047/181] Revert "ignore and android updates" This reverts commit 22dba972d050c74bd8d4f1edc713725f139f60a4. --- .gitignore | 1 - create-android-project.sh | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 9f7f344bcf..f90ffabac9 100644 --- a/.gitignore +++ b/.gitignore @@ -74,4 +74,3 @@ Device-Release/ # Ignore vim swaps *.swp -projects diff --git a/create-android-project.sh b/create-android-project.sh index c49445f40f..79d63ff2c8 100755 --- a/create-android-project.sh +++ b/create-android-project.sh @@ -5,8 +5,8 @@ # Don't modify the script until you know what you do. # set environment paramters -NDK_ROOT_LOCAL="/Users/ed/dev/android-ndk-r8" -ANDROID_SDK_ROOT_LOCAL="/Users/ed/dev/android-sdk" +NDK_ROOT_LOCAL="/home/laschweinski/android/android-ndk-r5" +ANDROID_SDK_ROOT_LOCAL="/home/laschweinski/android/android-sdk-linux_86" NEED_BOX2D=false NEED_CHIPMUNK=false From f54566ac031edfa259ad19577f9c8c1736fb5932 Mon Sep 17 00:00:00 2001 From: folecr Date: Tue, 18 Sep 2012 17:00:51 -0700 Subject: [PATCH 048/181] More robust script exits on errors and ... * Remove source build command (source repos for dependencies are not submodules) --- .../proj.android/build_native.sh | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/samples/TestJavascript/proj.android/build_native.sh b/samples/TestJavascript/proj.android/build_native.sh index 217c268791..8027997056 100755 --- a/samples/TestJavascript/proj.android/build_native.sh +++ b/samples/TestJavascript/proj.android/build_native.sh @@ -28,6 +28,9 @@ exit 0 esac done +# exit this script if any commmand fails +set -e + # paths if [ -z "${NDK_ROOT+aaa}" ];then @@ -41,10 +44,13 @@ COCOS2DX_ROOT="$DIR/../../.." APP_ROOT="$DIR/.." APP_ANDROID_ROOT="$DIR" -echo "NDK_ROOT = $NDK_ROOT" -echo "COCOS2DX_ROOT = $COCOS2DX_ROOT" -echo "APP_ROOT = $APP_ROOT" -echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT" +echo +echo "Paths" +echo " NDK_ROOT = $NDK_ROOT" +echo " COCOS2DX_ROOT = $COCOS2DX_ROOT" +echo " APP_ROOT = $APP_ROOT" +echo " APP_ANDROID_ROOT = $APP_ANDROID_ROOT" +echo # make sure assets is exist if [ -d "$APP_ANDROID_ROOT"/assets ]; then @@ -79,12 +85,10 @@ rm -f "$APP_ANDROID_ROOT"/assets/Images/texture1024x1024_rgba4444.pvr.gz rm -f "$APP_ANDROID_ROOT"/assets/Images/PlanetCute-1024x1024-rgba4444.pvr.gz -if [[ "$buildexternalsfromsource" ]]; then - echo "Building external dependencies from source" - "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \ - "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source" -else - echo "Using prebuilt externals" - "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \ - "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt" -fi +echo "Using prebuilt externals" +echo + +set -x + +"$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \ + "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt" From 8a688ef424c4e04e9add9e8c995f43610a37754c Mon Sep 17 00:00:00 2001 From: folecr Date: Fri, 14 Sep 2012 17:29:38 -0700 Subject: [PATCH 049/181] Script and config file for generating bindings --- tools/tojs/cocos2dx.ini | 102 ++++++++++++++++++++++++++++++++++++++ tools/tojs/genbindings.sh | 43 ++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 tools/tojs/cocos2dx.ini create mode 100644 tools/tojs/genbindings.sh diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini new file mode 100644 index 0000000000..9128922108 --- /dev/null +++ b/tools/tojs/cocos2dx.ini @@ -0,0 +1,102 @@ +[cocos2d-x] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = cocos2dx + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = cc + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/lib/clang/3.1/include +clang_flags = -nostdinc -x c++ + +cocos_headers = -I%(cocosdir)s/cocos2dx/include -I%(cocosdir)s/cocos2dx/platform -I%(cocosdir)s/cocos2dx/platform/android -I%(cocosdir)s/cocos2dx -I%(cocosdir)s/cocos2dx/kazmath/include +cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT + +cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common +spidermonkey_headers = -I%(mozilladir)s/spidermonkey/dist/include + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(spidermonkey_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s + +# what headers to parse +headers = %(cocosdir)s/cocos2dx/include/cocos2d.h + +# what classes to produce code for. You can use regular expressions here. When testing the regular +# expression, it will be enclosed in "^$", like this: "^CCMenu*$". +classes = CCSprite.* CCScene CCNode CCDirector CCLayer.* CCMenu.* CCTouch CC.*Action.* CCMove.* CCRotate.* CCBlink.* CCTint.* CCSequence CCRepeat.* CCFade.* CCEase.* CCScale.* CCTransition.* CCSpawn CCSequence CCAnimat.* CCFlip.* CCDelay.* CCSkew.* CCJump.* CCPlace.* CCShow.* CCProgress.* CCToggleVisibility.* CCHide CCParticle.* CCLabel.* CCAtlas.* CCTextureCache.* CCTexture2D CCParallaxNode CCTileMap.* CCTMX.* CCCallFunc CCRenderTexture CCGridAction CCGrid3DAction CCShaky3D CCWaves3D CCFlipX3D CCFlipY3D CCSpeed + +# what should we skip? in the format ClassName::[function function] +# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. +skip = CCNode::[.*Transform convertToWindowSpace getChildren getGrid setGLServerState description getActionManager getCamera getShaderProgram getUserObject .*UserData getGLServerState], + CCSprite::[getQuad displayFrame getTexture getBlendFunc setBlendFunc getTextureAtlas setSpriteBatchNode getSpriteBatchNode], + CCDirector::[getAccelerometer getKeypadDispatcher getTouchDispatcher getActionManager setWatcherCallbackFun getOpenGLView getScheduler getProjection], + CCLayer.*::[didAccelerate (g|s)etBlendFunc], + CCMenu.*::[.*Target getSubItems create], + CCMenuItem.*::[create], + CCRGBAProtocol::[*], + CCObject::[*], + CCCopying::[*], + CC.*Protocol::[*], + CC.*Delegate::[*], + CCPoolManager::[*], + CCIMEDispatcher::[*], + CCSAXParser::[*], + CCThread::[*], + CCProfiler::[*], + CCProfilingTimer::[*], + CCCallFunc::[create], + CCSAXDelegator::[*], + CCColor3bObject::[*], + CCTouchDispatcher::[*], + EGLTouchDelegate::[*], + CCScriptEngineManager::[*], + CCKeypadHandler::[*], + CCInvocation::[*], + CCEGLView::[*], + CCSchedulerScriptHandlerEntry::[*], + CCSize::[*], + CCPoint::[*], + CCRect::[*], + CCSize::[*], + CCString::[*], + CCDictionary::[*], + CCArray::[*], + CCSet::[*], + CCRange::[*], + CCNotificationObserver::[*], + CCListView.*::[*], + CCImage::[initWithString initWithImageData], + CCSequence::[create], + CCSpawn::[create], + CCAnimation::[create], + CCGrid3DAction::[create actionWith.*], + CCTiledGrid3DAction::[create actionWith.*], + CCTMXMapInfo::[startElement endElement textHandler], + CCTMXObjectGroup::[getObjects], + CCTexture2D::[initWithPVRTCData addPVRTCImage], + CCTextureCache::[addPVRTCImage], + *::[copyWith.* onEnter.* onExit.* description getObjectType .*RGB.* .*HSV.*] + +rename = CCDirector::[sharedDirector=getInstance], + CCSpriteFrameCache::[sharedSpriteFrameCache=getInstance addSpriteFramesWithFile=addSpriteFrames], + CCMenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize fontSizeObj=fontSize fontNameObj=fontName], + CCProgressTimer::[setReverseProgress=setReverseDirection], + CCTextureCache::[sharedTextureCache=getInstance], + CCMenuItem::[setEnabled=setIsEnabled] + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = CC + +# objects for which there will be no "parent" lookup +base_objects = CCNode CCDirector + +# classes that create no constructor +abstract_classes = CCDirector CCSpriteFrameCache CCTransitionEaseScene diff --git a/tools/tojs/genbindings.sh b/tools/tojs/genbindings.sh new file mode 100644 index 0000000000..1cc2373f4b --- /dev/null +++ b/tools/tojs/genbindings.sh @@ -0,0 +1,43 @@ +# exit this script if any commmand fails +set -e + +# read user.cfg if it exists and is readable + +_CFG_FILE=$(dirname "$0")"/user.cfg" +if [ -e "$_CFG_FILE" ] +then + [ -r "$_CFG_FILE" ] || die "Fatal Error: $_CFG_FILE exists but is unreadable" + . "$_CFG_FILE" +fi + +# paths + +if [ -z "${CLANG_ROOT+aaa}" ]; then +# ... if CLANG_ROOT is not set, use "$HOME/bin/clang+llvm-3.1" + CLANG_ROOT="$HOME/bin/clang+llvm-3.1" +fi + +if [ -z "${PYTHON_BIN+aaa}" ]; then +# ... if PYTHON_BIN is not set, use "/usr/bin/python2.7" + PYTHON_BIN="/usr/bin/python2.7" +fi + +# paths with defaults hardcoded to relative paths + +if [ -z "${CXX_GENERATOR_ROOT+aaa}" ]; then + CXX_GENERATOR_ROOT="$PWD/submodules/cxx-generator" +fi + +if [ -z "${COCOS2DX_ROOT+aaa}" ]; then + COCOS2DX_ROOT="$PWD/submodules/cocos2d-x" +fi + +echo "CLANG_ROOT: $CLANG_ROOT" +echo "CXX_GENERATOR_ROOT: $CXX_GENERATOR_ROOT" +echo "COCOS2DX_ROOT: $COCOS2DX_ROOT" +echo "PYTHON_BIN: $PYTHON_BIN" + +# Generate bindings for cocos2dx again +echo "Generating bindings for cocos2dx again..." +set -x +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${APP_ANDROID_ROOT}/cocos2dx.ini -s cocos2d-x -o ${COCOS2DX_ROOT}/scripting/javascript/bindings/generated From e6275f5f27ba6f72bb3cca2a72142f4edc62ebc6 Mon Sep 17 00:00:00 2001 From: folecr Date: Tue, 18 Sep 2012 12:27:44 -0700 Subject: [PATCH 050/181] Update gitignore for tojs --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index f90ffabac9..6b8ea43aa3 100644 --- a/.gitignore +++ b/.gitignore @@ -74,3 +74,7 @@ Device-Release/ # Ignore vim swaps *.swp + +# Ignore config files in javascript bindings generator +tools/tojs/user.cfg +tools/tojs/userconf.ini From 4c1fad1c6c1438d6c301672968d16de6e66021e9 Mon Sep 17 00:00:00 2001 From: folecr Date: Tue, 18 Sep 2012 13:46:17 -0700 Subject: [PATCH 051/181] chmod u+x genbindings.sh --- tools/tojs/genbindings.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tools/tojs/genbindings.sh diff --git a/tools/tojs/genbindings.sh b/tools/tojs/genbindings.sh old mode 100644 new mode 100755 From 2c1c58eeb915a353c978491a81d57a79c8326f0e Mon Sep 17 00:00:00 2001 From: folecr Date: Tue, 18 Sep 2012 14:01:29 -0700 Subject: [PATCH 052/181] Update path calculation. --- tools/tojs/genbindings.sh | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/tools/tojs/genbindings.sh b/tools/tojs/genbindings.sh index 1cc2373f4b..945f61d1d4 100755 --- a/tools/tojs/genbindings.sh +++ b/tools/tojs/genbindings.sh @@ -22,22 +22,31 @@ if [ -z "${PYTHON_BIN+aaa}" ]; then PYTHON_BIN="/usr/bin/python2.7" fi +# find current dir +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + # paths with defaults hardcoded to relative paths -if [ -z "${CXX_GENERATOR_ROOT+aaa}" ]; then - CXX_GENERATOR_ROOT="$PWD/submodules/cxx-generator" -fi - if [ -z "${COCOS2DX_ROOT+aaa}" ]; then - COCOS2DX_ROOT="$PWD/submodules/cocos2d-x" + COCOS2DX_ROOT="$DIR/../../" fi -echo "CLANG_ROOT: $CLANG_ROOT" -echo "CXX_GENERATOR_ROOT: $CXX_GENERATOR_ROOT" -echo "COCOS2DX_ROOT: $COCOS2DX_ROOT" -echo "PYTHON_BIN: $PYTHON_BIN" +if [ -z "${CXX_GENERATOR_ROOT+aaa}" ]; then + CXX_GENERATOR_ROOT="$COCOS2DX_ROOT/tools/cxx-generator" +fi -# Generate bindings for cocos2dx again -echo "Generating bindings for cocos2dx again..." +if [ -z "${TOJS_ROOT+aaa}" ]; then + TO_JS_ROOT="$COCOS2DX_ROOT/tools/tojs" +fi + +echo "Paths" +echo " CLANG_ROOT: $CLANG_ROOT" +echo " PYTHON_BIN: $PYTHON_BIN" +echo " COCOS2DX_ROOT: $COCOS2DX_ROOT" +echo " CXX_GENERATOR_ROOT: $CXX_GENERATOR_ROOT" +echo " TO_JS_ROOT: $TO_JS_ROOT" + +# Generate bindings for cocos2dx +echo "Generating bindings for cocos2dx..." set -x -LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${APP_ANDROID_ROOT}/cocos2dx.ini -s cocos2d-x -o ${COCOS2DX_ROOT}/scripting/javascript/bindings/generated +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx.ini -s cocos2d-x -o ${COCOS2DX_ROOT}/scripting/javascript/bindings/generated From 60fd3c5b9ceeeb222a2081427d8c0d0f9ec20751 Mon Sep 17 00:00:00 2001 From: folecr Date: Tue, 18 Sep 2012 14:22:22 -0700 Subject: [PATCH 053/181] Remove generated files... * ... in favour of automatically generated bindings * ... in the generated/ subfolder. --- scripting/javascript/bindings/cocos2dx.cpp.REMOVED.git-id | 1 - scripting/javascript/bindings/cocos2dx.hpp.REMOVED.git-id | 1 - 2 files changed, 2 deletions(-) delete mode 100644 scripting/javascript/bindings/cocos2dx.cpp.REMOVED.git-id delete mode 100644 scripting/javascript/bindings/cocos2dx.hpp.REMOVED.git-id diff --git a/scripting/javascript/bindings/cocos2dx.cpp.REMOVED.git-id b/scripting/javascript/bindings/cocos2dx.cpp.REMOVED.git-id deleted file mode 100644 index 3726a6d305..0000000000 --- a/scripting/javascript/bindings/cocos2dx.cpp.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -e63ae7e9891ffc117d0773ea208a818c73ceaabb \ No newline at end of file diff --git a/scripting/javascript/bindings/cocos2dx.hpp.REMOVED.git-id b/scripting/javascript/bindings/cocos2dx.hpp.REMOVED.git-id deleted file mode 100644 index 8308e8f958..0000000000 --- a/scripting/javascript/bindings/cocos2dx.hpp.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -7432280bb264dae5297eec03a32592aa515f48d6 \ No newline at end of file From c6f06ddcedeee0f202781229b07e61542eeca429 Mon Sep 17 00:00:00 2001 From: folecr Date: Tue, 18 Sep 2012 16:54:53 -0700 Subject: [PATCH 054/181] Refer to cocos2dx.cpp from the generated subdirectory --- scripting/javascript/bindings/Android.mk | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripting/javascript/bindings/Android.mk b/scripting/javascript/bindings/Android.mk index 1ecdfb1099..4436ae377a 100644 --- a/scripting/javascript/bindings/Android.mk +++ b/scripting/javascript/bindings/Android.mk @@ -8,11 +8,11 @@ LOCAL_MODULE_FILENAME := libscriptingcore-spidermonkey LOCAL_SRC_FILES := ScriptingCore.cpp \ cocos2d_specifics.cpp \ - cocos2dx.cpp \ CCPhysicsSprite.cpp \ js_manual_conversions.cpp \ js_bindings_chipmunk_manual.cpp \ - js_bindings_chipmunk_functions.cpp + js_bindings_chipmunk_functions.cpp \ + generated/cocos2dx.cpp LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT @@ -20,7 +20,8 @@ LOCAL_EXPORT_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ + $(LOCAL_PATH)/generated LOCAL_WHOLE_STATIC_LIBRARIES := spidermonkey_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static From 5d816bfaf6ab65f9b4ec000f2a34cbc79c47aee8 Mon Sep 17 00:00:00 2001 From: folecr Date: Tue, 18 Sep 2012 17:08:37 -0700 Subject: [PATCH 055/181] Verbose logging of build process --- samples/TestJavascript/proj.android/build_native.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/TestJavascript/proj.android/build_native.sh b/samples/TestJavascript/proj.android/build_native.sh index 8027997056..6ce5e724e4 100755 --- a/samples/TestJavascript/proj.android/build_native.sh +++ b/samples/TestJavascript/proj.android/build_native.sh @@ -91,4 +91,5 @@ echo set -x "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \ - "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt" + "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt" \ + NDK_LOG=1 V=1 From 9db2df3f7b9580549b81d44f4b5e0a88ee7d7c48 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 19 Sep 2012 09:40:02 +0800 Subject: [PATCH 056/181] issue #1470:modify resources path --- .../proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id index 70df50979e..c81a436a53 100644 --- a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -545c76af355dd3e2c6950e5ea44243aa85083c43 \ No newline at end of file +0af7a026c4eb39765ba79c3fe62816078549365c \ No newline at end of file From 16d3466f3932b9a4d123b990118b8773aafa0b03 Mon Sep 17 00:00:00 2001 From: nichos1983 Date: Wed, 19 Sep 2012 15:28:36 +0800 Subject: [PATCH 057/181] fix bug of not checking object before post notification --- cocos2dx/support/CCNotificationCenter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/support/CCNotificationCenter.cpp b/cocos2dx/support/CCNotificationCenter.cpp index 4ba8e8d0a9..71b0af28dc 100644 --- a/cocos2dx/support/CCNotificationCenter.cpp +++ b/cocos2dx/support/CCNotificationCenter.cpp @@ -138,7 +138,7 @@ void CCNotificationCenter::postNotification(const char *name, CCObject *object) if (!observer) continue; - if (!strcmp(name,observer->getName())) + if (!strcmp(name,observer->getName()) && (observer->getObject() == object || observer->getObject() == NULL || object == NULL)) observer->performSelector(object); } From 4bff6927b8b5db5aad3be7818de8623010902a42 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 19 Sep 2012 17:43:11 +0800 Subject: [PATCH 058/181] issue #1470:re-publish ccb --- extensions/Android.mk | 7 +++++++ samples/TestCpp/Android.mk | 1 + .../CocosBuilderTest/CocosBuilderTest.cpp | 2 +- .../HelloCocosBuilder/HelloCocosBuilderLayer.cpp | 15 ++++++++------- .../project.pbxproj.REMOVED.git-id | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/extensions/Android.mk b/extensions/Android.mk index 4df756463a..e475e74556 100644 --- a/extensions/Android.mk +++ b/extensions/Android.mk @@ -22,6 +22,13 @@ CCBReader/CCParticleSystemQuadLoader.cpp \ CCBReader/CCScale9SpriteLoader.cpp \ CCBReader/CCScrollViewLoader.cpp \ CCBReader/CCSpriteLoader.cpp \ +CCBReader/CCBAnimationManager.cpp \ +CCBReader/CCBKeyframe.cpp \ +CCBReader/CCBSequence.cpp \ +CCBReader/CCBSequenceProperty.cpp \ +CCBReader/CCBValue.cpp \ +CCBReader/CCData.cpp \ +CCBReader/CCNode+CCBRelativePositioning.cpp \ GUI/CCControlExtension/CCControl.cpp \ GUI/CCControlExtension/CCControlButton.cpp \ GUI/CCControlExtension/CCControlColourPicker.cpp \ diff --git a/samples/TestCpp/Android.mk b/samples/TestCpp/Android.mk index 8ca97058ac..03b1baf841 100644 --- a/samples/TestCpp/Android.mk +++ b/samples/TestCpp/Android.mk @@ -49,6 +49,7 @@ Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp \ Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp \ Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp \ +Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp \ Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp \ Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp \ Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp \ diff --git a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp index 66c0c4834b..e0f4cd044a 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp +++ b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp @@ -39,7 +39,7 @@ void CocosBuilderTestScene::runThisTest() { cocos2d::extension::CCBReader * ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary); /* Read a ccbi file. */ - CCNode * node = ccbReader->readNodeGraphFromFile("HelloCocosBuilder.ccbi", this); + CCNode * node = ccbReader->readNodeGraphFromFile("ccb/HelloCocosBuilder.ccbi", this); ccbReader->release(); diff --git a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp index d1b69d3bee..e4d204bbf3 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp +++ b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp @@ -91,15 +91,15 @@ bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(CCObject * pTarget, CCStr void HelloCocosBuilderLayer::onMenuTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - this->openTest("TestMenus.ccbi", "TestMenusLayer", MenuTestLayerLoader::loader()); + this->openTest("ccb/ccb/TestMenus.ccbi", "TestMenusLayer", MenuTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onSpriteTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - this->openTest("TestSprites.ccbi", "TestSpritesLayer", SpriteTestLayerLoader::loader()); + this->openTest("ccb/ccb/TestSprites.ccbi", "TestSpritesLayer", SpriteTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onButtonTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - this->openTest("TestButtons.ccbi", "TestButtonsLayer", ButtonTestLayerLoader::loader()); + this->openTest("ccb/ccb/TestButtons.ccbi", "TestButtonsLayer", ButtonTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onAnimationsTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { @@ -122,7 +122,7 @@ void HelloCocosBuilderLayer::onAnimationsTestClicked(CCObject * pSender, cocos2d // the owner will cause lblTestTitle to be set by the CCBReader. // lblTestTitle is in the TestHeader.ccbi, which is referenced // from each of the test scenes. - CCNode *animationsTest = ccbReader->readNodeGraphFromFile("TestAnimations.ccbi", this, &actionManager); + CCNode *animationsTest = ccbReader->readNodeGraphFromFile("ccb/ccb/TestAnimations.ccbi", this, &actionManager); ((AnimationsTestLayer*)animationsTest)->setAnimationManager(actionManager); this->mTestTitleLabelTTF->setString("TestAnimations.ccbi"); @@ -145,9 +145,10 @@ void HelloCocosBuilderLayer::onAnimationsTestClicked(CCObject * pSender, cocos2d } void HelloCocosBuilderLayer::onParticleSystemTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - this->openTest("TestParticleSystems.ccbi", "TestParticleSystemsLayer", ParticleSystemTestLayerLoader::loader()); + this->openTest("ccb/ccb/TestParticleSystems.ccbi", "TestParticleSystemsLayer", ParticleSystemTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onScrollViewTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - this->openTest("TestScrollViews.ccbi", "TestScrollViewsLayer", ScrollViewTestLayerLoader::loader()); +void HelloCocosBuilderLayer::onScrollViewTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) +{ + this->openTest("ccb/ccb/TestScrollViews.ccbi", "TestScrollViewsLayer", ScrollViewTestLayerLoader::loader()); } \ No newline at end of file diff --git a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id index c81a436a53..796dd744b5 100644 --- a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -0af7a026c4eb39765ba79c3fe62816078549365c \ No newline at end of file +4e9a0c8b08e12b2d6d915f77e26eae289a302051 \ No newline at end of file From ebe092661bfb752a2b42e8e0c345c0417eae4d65 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 19 Sep 2012 17:50:30 +0800 Subject: [PATCH 059/181] issue #1470: modify mac project and delete unneeded files --- .../Resources/hd/ccb/official/pub/res/burst.png.REMOVED.git-id | 1 - .../Resources/hd/ccb/official/src/res/burst.png.REMOVED.git-id | 1 - .../ipad/ccb/official/pub/res/burst.png.REMOVED.git-id | 1 - .../ipad/ccb/official/src/res/burst.png.REMOVED.git-id | 1 - .../proj.mac/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 5 files changed, 1 insertion(+), 5 deletions(-) delete mode 100644 samples/TestCpp/Resources/hd/ccb/official/pub/res/burst.png.REMOVED.git-id delete mode 100644 samples/TestCpp/Resources/hd/ccb/official/src/res/burst.png.REMOVED.git-id delete mode 100644 samples/TestCpp/Resources/ipad/ccb/official/pub/res/burst.png.REMOVED.git-id delete mode 100644 samples/TestCpp/Resources/ipad/ccb/official/src/res/burst.png.REMOVED.git-id diff --git a/samples/TestCpp/Resources/hd/ccb/official/pub/res/burst.png.REMOVED.git-id b/samples/TestCpp/Resources/hd/ccb/official/pub/res/burst.png.REMOVED.git-id deleted file mode 100644 index 4b8037d9b8..0000000000 --- a/samples/TestCpp/Resources/hd/ccb/official/pub/res/burst.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -723ff604c8b83d6b1c5a72aea87e9c904fe6c699 \ No newline at end of file diff --git a/samples/TestCpp/Resources/hd/ccb/official/src/res/burst.png.REMOVED.git-id b/samples/TestCpp/Resources/hd/ccb/official/src/res/burst.png.REMOVED.git-id deleted file mode 100644 index 4b8037d9b8..0000000000 --- a/samples/TestCpp/Resources/hd/ccb/official/src/res/burst.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -723ff604c8b83d6b1c5a72aea87e9c904fe6c699 \ No newline at end of file diff --git a/samples/TestCpp/Resources/ipad/ccb/official/pub/res/burst.png.REMOVED.git-id b/samples/TestCpp/Resources/ipad/ccb/official/pub/res/burst.png.REMOVED.git-id deleted file mode 100644 index 4b8037d9b8..0000000000 --- a/samples/TestCpp/Resources/ipad/ccb/official/pub/res/burst.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -723ff604c8b83d6b1c5a72aea87e9c904fe6c699 \ No newline at end of file diff --git a/samples/TestCpp/Resources/ipad/ccb/official/src/res/burst.png.REMOVED.git-id b/samples/TestCpp/Resources/ipad/ccb/official/src/res/burst.png.REMOVED.git-id deleted file mode 100644 index 4b8037d9b8..0000000000 --- a/samples/TestCpp/Resources/ipad/ccb/official/src/res/burst.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -723ff604c8b83d6b1c5a72aea87e9c904fe6c699 \ No newline at end of file diff --git a/samples/TestCpp/proj.mac/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/TestCpp/proj.mac/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id index 9888556745..86484a7483 100644 --- a/samples/TestCpp/proj.mac/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/TestCpp/proj.mac/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -05fb7e1549cf656c61a502a07712b042ff7eec9b \ No newline at end of file +35ee36aee350134dbe3d44c7a91b309972ea00ad \ No newline at end of file From 5e169eb0af55decc5d6a16caf505a72b87f92726 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 19 Sep 2012 17:54:45 +0800 Subject: [PATCH 060/181] issue #1470: put hd/ipad resources into corresponding directory --- .../ccb/burst.png.REMOVED.git-id} | 0 .../ccb/burst.png.REMOVED.git-id} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename samples/TestCpp/Resources/{ccb/burst-hd.png.REMOVED.git-id => hd/ccb/burst.png.REMOVED.git-id} (100%) rename samples/TestCpp/Resources/{ccb/burst-ipad.png.REMOVED.git-id => ipad/ccb/burst.png.REMOVED.git-id} (100%) diff --git a/samples/TestCpp/Resources/ccb/burst-hd.png.REMOVED.git-id b/samples/TestCpp/Resources/hd/ccb/burst.png.REMOVED.git-id similarity index 100% rename from samples/TestCpp/Resources/ccb/burst-hd.png.REMOVED.git-id rename to samples/TestCpp/Resources/hd/ccb/burst.png.REMOVED.git-id diff --git a/samples/TestCpp/Resources/ccb/burst-ipad.png.REMOVED.git-id b/samples/TestCpp/Resources/ipad/ccb/burst.png.REMOVED.git-id similarity index 100% rename from samples/TestCpp/Resources/ccb/burst-ipad.png.REMOVED.git-id rename to samples/TestCpp/Resources/ipad/ccb/burst.png.REMOVED.git-id From 2f3cdc6538f54334e128f0ad0e8f61f703d68a86 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 19 Sep 2012 18:05:10 +0800 Subject: [PATCH 061/181] issue #1470:modify linux makefile and re-create xcode template --- cocos2dx/proj.linux/Makefile | 7 +++++++ samples/TestCpp/proj.linux/Makefile | 1 + 2 files changed, 8 insertions(+) diff --git a/cocos2dx/proj.linux/Makefile b/cocos2dx/proj.linux/Makefile index b5d02bbe8e..928c16a551 100644 --- a/cocos2dx/proj.linux/Makefile +++ b/cocos2dx/proj.linux/Makefile @@ -144,6 +144,13 @@ OBJECTS = ../actions/CCAction.o \ ../../extensions/CCBReader/CCLayerGradientLoader.o \ ../../extensions/CCBReader/CCSpriteLoader.o \ ../../extensions/CCBReader/CCLayerLoader.o \ + ../../extensions/CCBReader/CCBAnimationManager.o \ + ../../extensions/CCBReader/CCBKeyframe.o \ + ../../extensions/CCBReader/CCBSequence.o \ + ../../extensions/CCBReader/CCBSequenceProperty.o \ + ../../extensions/CCBReader/CCBValue.o \ + ../../extensions/CCBReader/CCData.o \ + ../../extensions/CCBReader/CCNode+CCBRelativePositioning.o \ ../../extensions/GUI/CCScrollView/CCScrollView.o \ ../../extensions/GUI/CCScrollView/CCSorting.o \ ../../extensions/GUI/CCScrollView/CCTableView.o \ diff --git a/samples/TestCpp/proj.linux/Makefile b/samples/TestCpp/proj.linux/Makefile index 67cdce1d3a..3da6f740f4 100644 --- a/samples/TestCpp/proj.linux/Makefile +++ b/samples/TestCpp/proj.linux/Makefile @@ -69,6 +69,7 @@ OBJECTS = ../Classes/AccelerometerTest/AccelerometerTest.o \ ../Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.o \ ../Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.o \ ../Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.o \ + ../Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsLayer.o \ ../Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.o \ ../Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.o \ ../Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.o \ From 9fabf3a45b3c07e91698303624c08d5a5ad5c3c9 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 19 Sep 2012 18:41:50 +0800 Subject: [PATCH 062/181] fixed #1470: Made CCBReader support cocosbuilder v2.1-beta0. --- extensions/CCBReader/CCBSequence.h | 3 +- extensions/cocos-ext.h | 7 + extensions/proj.win32/libExtensions.vcproj | 56 ++++ extensions/proj.win32/libExtensions.vcxproj | 14 + .../proj.win32/libExtensions.vcxproj.filters | 270 ++++++++++-------- .../AnimationsTest/AnimationsLayerLoader.h | 1 - .../AnimationsTest/AnimationsTestLayer.cpp | 1 - samples/TestCpp/proj.win32/TestCpp.vcproj | 16 ++ samples/TestCpp/proj.win32/TestCpp.vcxproj | 3 + .../proj.win32/TestCpp.vcxproj.filters | 12 + 10 files changed, 266 insertions(+), 117 deletions(-) diff --git a/extensions/CCBReader/CCBSequence.h b/extensions/CCBReader/CCBSequence.h index 55a4a8013a..b253f19888 100644 --- a/extensions/CCBReader/CCBSequence.h +++ b/extensions/CCBReader/CCBSequence.h @@ -1,8 +1,9 @@ #ifndef __CCB_CCSEQUENCE_H__ #define __CCB_CCSEQUENCE_H__ -#include "cocos-ext.h" #include +#include "cocos2d.h" +#include "ExtensionMacros.h" NS_CC_EXT_BEGIN diff --git a/extensions/cocos-ext.h b/extensions/cocos-ext.h index 8842b1ceeb..55d9bb6f04 100644 --- a/extensions/cocos-ext.h +++ b/extensions/cocos-ext.h @@ -24,6 +24,13 @@ #include "CCBReader/CCScale9SpriteLoader.h" #include "CCBReader/CCScrollViewLoader.h" #include "CCBReader/CCSpriteLoader.h" +#include "CCBReader/CCBAnimationManager.h" +#include "CCBReader/CCBKeyframe.h" +#include "CCBReader/CCBSequence.h" +#include "CCBReader/CCBSequenceProperty.h" +#include "CCBReader/CCBValue.h" +#include "CCBReader/CCData.h" +#include "CCBReader/CCNode+CCBRelativePositioning.h" #include "GUI/CCControlExtension/CCControlExtensions.h" #include "GUI/CCScrollView/CCScrollView.h" diff --git a/extensions/proj.win32/libExtensions.vcproj b/extensions/proj.win32/libExtensions.vcproj index 36ad9bc313..8853c4df2e 100644 --- a/extensions/proj.win32/libExtensions.vcproj +++ b/extensions/proj.win32/libExtensions.vcproj @@ -150,6 +150,14 @@ + + + + @@ -158,6 +166,14 @@ RelativePath="..\CCBReader\CCBFileLoader.h" > + + + + @@ -174,6 +190,30 @@ RelativePath="..\CCBReader\CCBSelectorResolver.h" > + + + + + + + + + + + + @@ -190,6 +230,14 @@ RelativePath="..\CCBReader\CCControlLoader.h" > + + + + @@ -250,6 +298,14 @@ RelativePath="..\CCBReader\CCMenuLoader.h" > + + + + diff --git a/extensions/proj.win32/libExtensions.vcxproj b/extensions/proj.win32/libExtensions.vcxproj index 32f9ed95a9..66047eb66e 100644 --- a/extensions/proj.win32/libExtensions.vcxproj +++ b/extensions/proj.win32/libExtensions.vcxproj @@ -79,10 +79,16 @@ + + + + + + @@ -90,6 +96,7 @@ + @@ -115,12 +122,18 @@ + + + + + + @@ -129,6 +142,7 @@ + diff --git a/extensions/proj.win32/libExtensions.vcxproj.filters b/extensions/proj.win32/libExtensions.vcxproj.filters index 3dfab3a3d7..19f47f527d 100644 --- a/extensions/proj.win32/libExtensions.vcxproj.filters +++ b/extensions/proj.win32/libExtensions.vcxproj.filters @@ -18,57 +18,6 @@ - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - GUI\CCControlExtension @@ -120,71 +69,80 @@ GUI\CCScrollView + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - GUI\CCControlExtension @@ -247,5 +205,89 @@ GUI\CCScrollView + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + \ No newline at end of file diff --git a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsLayerLoader.h b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsLayerLoader.h index 7038cd9406..3cc435c93f 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsLayerLoader.h +++ b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsLayerLoader.h @@ -2,7 +2,6 @@ #define _ANIMATIONSTESTLAYERLOADER_H_ #include "AnimationsTestLayer.h" -#include "CCNodeLoader.h" /* Forward declaration. */ class CCBReader; diff --git a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp index 8769d080d4..b03b5e9939 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp +++ b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp @@ -1,5 +1,4 @@ #include "AnimationsTestLayer.h" -#include "CCBAnimationManager.h" USING_NS_CC; USING_NS_CC_EXT; diff --git a/samples/TestCpp/proj.win32/TestCpp.vcproj b/samples/TestCpp/proj.win32/TestCpp.vcproj index f664a59cc3..0ccd95ae80 100644 --- a/samples/TestCpp/proj.win32/TestCpp.vcproj +++ b/samples/TestCpp/proj.win32/TestCpp.vcproj @@ -1010,6 +1010,22 @@ > + + + + + + + + + @@ -191,6 +192,8 @@ + + diff --git a/samples/TestCpp/proj.win32/TestCpp.vcxproj.filters b/samples/TestCpp/proj.win32/TestCpp.vcxproj.filters index 0f76196539..ee747ea454 100644 --- a/samples/TestCpp/proj.win32/TestCpp.vcxproj.filters +++ b/samples/TestCpp/proj.win32/TestCpp.vcxproj.filters @@ -193,6 +193,9 @@ {2603ae57-b062-4281-9daf-c925634eaeb4} + + {e8752620-8414-4f43-a572-5fa82650f223} + @@ -441,6 +444,9 @@ Classes\ExtensionsTest\TableViewTest + + Classes\ExtensionsTest\AnimationsTest + @@ -863,5 +869,11 @@ Classes\ExtensionsTest\TableViewTest + + Classes\ExtensionsTest\AnimationsTest + + + Classes\ExtensionsTest\AnimationsTest + \ No newline at end of file From 92ce4d47832d0fc18625c25769f90443520a2329 Mon Sep 17 00:00:00 2001 From: folecr Date: Wed, 19 Sep 2012 13:21:26 -0700 Subject: [PATCH 063/181] Update cocos2dx.ini so that the generated bindings and the TestJavascript app compile. --- tools/tojs/cocos2dx.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index 9128922108..8962a0e55f 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -27,7 +27,7 @@ headers = %(cocosdir)s/cocos2dx/include/cocos2d.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^CCMenu*$". -classes = CCSprite.* CCScene CCNode CCDirector CCLayer.* CCMenu.* CCTouch CC.*Action.* CCMove.* CCRotate.* CCBlink.* CCTint.* CCSequence CCRepeat.* CCFade.* CCEase.* CCScale.* CCTransition.* CCSpawn CCSequence CCAnimat.* CCFlip.* CCDelay.* CCSkew.* CCJump.* CCPlace.* CCShow.* CCProgress.* CCToggleVisibility.* CCHide CCParticle.* CCLabel.* CCAtlas.* CCTextureCache.* CCTexture2D CCParallaxNode CCTileMap.* CCTMX.* CCCallFunc CCRenderTexture CCGridAction CCGrid3DAction CCShaky3D CCWaves3D CCFlipX3D CCFlipY3D CCSpeed +classes = CCSprite.* CCScene CCNode CCDirector CCLayer.* CCMenu.* CCTouch CC.*Action.* CCMove.* CCRotate.* CCBlink.* CCTint.* CCSequence CCRepeat.* CCFade.* CCEase.* CCScale.* CCTransition.* CCSpawn CCSequence CCAnimat.* CCFlip.* CCDelay.* CCSkew.* CCJump.* CCPlace.* CCShow.* CCProgress.* CCToggleVisibility.* CCHide CCParticle.* CCLabel.* CCAtlas.* CCTextureCache.* CCTexture2D CCParallaxNode CCTileMap.* CCTMX.* CCCallFunc CCRenderTexture CCGridAction CCGrid3DAction CCShaky3D CCWaves3D CCFlipX3D CCFlipY3D CCSpeed CCSet # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -39,7 +39,7 @@ skip = CCNode::[.*Transform convertToWindowSpace getChildren getGrid setGLServer CCSprite::[getQuad displayFrame getTexture getBlendFunc setBlendFunc getTextureAtlas setSpriteBatchNode getSpriteBatchNode], CCDirector::[getAccelerometer getKeypadDispatcher getTouchDispatcher getActionManager setWatcherCallbackFun getOpenGLView getScheduler getProjection], CCLayer.*::[didAccelerate (g|s)etBlendFunc], - CCMenu.*::[.*Target getSubItems create], + CCMenu.*::[.*Target getSubItems create alignItemsInColumns initWithItems alignItemsInRows], CCMenuItem.*::[create], CCRGBAProtocol::[*], CCObject::[*], @@ -69,7 +69,6 @@ skip = CCNode::[.*Transform convertToWindowSpace getChildren getGrid setGLServer CCString::[*], CCDictionary::[*], CCArray::[*], - CCSet::[*], CCRange::[*], CCNotificationObserver::[*], CCListView.*::[*], @@ -82,6 +81,7 @@ skip = CCNode::[.*Transform convertToWindowSpace getChildren getGrid setGLServer CCTMXMapInfo::[startElement endElement textHandler], CCTMXObjectGroup::[getObjects], CCTexture2D::[initWithPVRTCData addPVRTCImage], + CCLayerMultiplex::[*], CCTextureCache::[addPVRTCImage], *::[copyWith.* onEnter.* onExit.* description getObjectType .*RGB.* .*HSV.*] @@ -99,4 +99,4 @@ remove_prefix = CC base_objects = CCNode CCDirector # classes that create no constructor -abstract_classes = CCDirector CCSpriteFrameCache CCTransitionEaseScene +abstract_classes = CCDirector CCSpriteFrameCache CCTransitionEaseScene CCSet From a9305fd4df03234eb53cdf435b52b5751e5a9211 Mon Sep 17 00:00:00 2001 From: folecr Date: Wed, 19 Sep 2012 14:00:38 -0700 Subject: [PATCH 064/181] Update tools/cxx-generator --- tools/cxx-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cxx-generator b/tools/cxx-generator index 5154f8898b..db61f83996 160000 --- a/tools/cxx-generator +++ b/tools/cxx-generator @@ -1 +1 @@ -Subproject commit 5154f8898bb8755bda496a84fa39abe97d6a9b44 +Subproject commit db61f8399655dd90f09d550259b45ae8289364fe From 36908396d236d45b3c38038d8913383cc1d7e28d Mon Sep 17 00:00:00 2001 From: dualface Date: Thu, 20 Sep 2012 09:29:20 +0800 Subject: [PATCH 065/181] [Lua] disable CCLayer remove script touch handler on exit --- cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index f0b3347a6e..9a838d7531 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -257,11 +257,7 @@ void CCLayer::onEnter() void CCLayer::onExit() { CCDirector* pDirector = CCDirector::sharedDirector(); - if( m_bIsTouchEnabled ) - { - pDirector->getTouchDispatcher()->removeDelegate(this); - unregisterScriptTouchHandler(); - } + pDirector->getTouchDispatcher()->removeDelegate(this); // remove this layer from the delegates who concern Accelerometer Sensor if (m_bIsAccelerometerEnabled) From 1a162a09ad10c7abf710675e62de2c32f0f072b7 Mon Sep 17 00:00:00 2001 From: dualface Date: Thu, 20 Sep 2012 11:32:02 +0800 Subject: [PATCH 066/181] restore CCLayer:onExit() --- cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index 9a838d7531..11f39feae2 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -257,7 +257,10 @@ void CCLayer::onEnter() void CCLayer::onExit() { CCDirector* pDirector = CCDirector::sharedDirector(); - pDirector->getTouchDispatcher()->removeDelegate(this); + if( m_bIsTouchEnabled ) + { + pDirector->getTouchDispatcher()->removeDelegate(this); + } // remove this layer from the delegates who concern Accelerometer Sensor if (m_bIsAccelerometerEnabled) From b4b9a1be2be5fb5c7aef9eca145e78211170df47 Mon Sep 17 00:00:00 2001 From: "M.W. Park" Date: Thu, 20 Sep 2012 12:32:37 +0900 Subject: [PATCH 067/181] fixed log output. --- extensions/CCBReader/CCNodeLoader.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/CCBReader/CCNodeLoader.cpp b/extensions/CCBReader/CCNodeLoader.cpp index 5a6ec4919c..7f092916f0 100644 --- a/extensions/CCBReader/CCNodeLoader.cpp +++ b/extensions/CCBReader/CCNodeLoader.cpp @@ -705,7 +705,7 @@ BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, C } if(selMenuHandler == 0) { - CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName); + CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName->getCString()); } else { BlockData * blockData = new BlockData(); blockData->mSELMenuHandler = selMenuHandler; @@ -755,7 +755,7 @@ BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, C } if(selCCControlHandler == 0) { - CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName); + CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName->getCString()); } else { BlockCCControlData * blockCCControlData = new BlockCCControlData(); blockCCControlData->mSELCCControlHandler = selCCControlHandler; @@ -948,4 +948,4 @@ void CCNodeLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCS ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -NS_CC_EXT_END \ No newline at end of file +NS_CC_EXT_END From d042e8557dd7e35d6e624fe2e6f1d40d4a705492 Mon Sep 17 00:00:00 2001 From: "M.W. Park" Date: Thu, 20 Sep 2012 12:47:45 +0900 Subject: [PATCH 068/181] fixed CCSpriteLoader's flipX bug. --- extensions/CCBReader/CCSpriteLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/CCBReader/CCSpriteLoader.cpp b/extensions/CCBReader/CCSpriteLoader.cpp index bad04ce546..6c487b54d1 100644 --- a/extensions/CCBReader/CCSpriteLoader.cpp +++ b/extensions/CCBReader/CCSpriteLoader.cpp @@ -21,7 +21,7 @@ void CCSpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParen void CCSpriteLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool * pFlip, CCBReader * pCCBReader) { if(pPropertyName->compare(PROPERTY_FLIP) == 0) { ((CCSprite *)pNode)->setFlipX(pFlip[0]); - ((CCSprite *)pNode)->setFlipX(pFlip[1]); + ((CCSprite *)pNode)->setFlipY(pFlip[1]); } else { CCNodeLoader::onHandlePropTypeFlip(pNode, pParent, pPropertyName, pFlip, pCCBReader); } From 2e900da66d1f1c937878b1d466dab5d087161f9d Mon Sep 17 00:00:00 2001 From: dualface Date: Thu, 20 Sep 2012 11:48:34 +0800 Subject: [PATCH 069/181] add comment --- cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index 11f39feae2..4d78611f79 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -260,6 +260,8 @@ void CCLayer::onExit() if( m_bIsTouchEnabled ) { pDirector->getTouchDispatcher()->removeDelegate(this); + // fix: CCLayer re-added to the scene after the loss of scripting touch events + // unregisterScriptTouchHandler(); } // remove this layer from the delegates who concern Accelerometer Sensor From 72e1bdc8cd52d497bad32ca15569ef0105653863 Mon Sep 17 00:00:00 2001 From: dualface Date: Thu, 20 Sep 2012 11:55:12 +0800 Subject: [PATCH 070/181] add ccDrawCircle overloaded function, for jsbinding --- cocos2dx/CCDrawingPrimitives.cpp | 5 +++++ cocos2dx/CCDrawingPrimitives.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cocos2dx/CCDrawingPrimitives.cpp b/cocos2dx/CCDrawingPrimitives.cpp index bd6c49ec86..a8f90027d9 100644 --- a/cocos2dx/CCDrawingPrimitives.cpp +++ b/cocos2dx/CCDrawingPrimitives.cpp @@ -291,6 +291,11 @@ void ccDrawCircle( const CCPoint& center, float radius, float angle, unsigned in CC_INCREMENT_GL_DRAWS(1); } +void CC_DLL ccDrawCircle( const CCPoint& center, float radius, float angle, unsigned int segments, bool drawLineToCenter) +{ + ccDrawCircle(center, radius, angle, segments, drawLineToCenter, 1.0f, 1.0f); +} + void ccDrawQuadBezier(const CCPoint& origin, const CCPoint& control, const CCPoint& destination, unsigned int segments) { lazy_init(); diff --git a/cocos2dx/CCDrawingPrimitives.h b/cocos2dx/CCDrawingPrimitives.h index c8014cee18..2cf5c4dd96 100644 --- a/cocos2dx/CCDrawingPrimitives.h +++ b/cocos2dx/CCDrawingPrimitives.h @@ -88,7 +88,8 @@ void CC_DLL ccDrawPoly( const CCPoint *vertices, unsigned int numOfVertices, boo void CC_DLL ccDrawSolidPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor4F color ); /** draws a circle given the center, radius and number of segments. */ -void CC_DLL ccDrawCircle( const CCPoint& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX = 1.0f, float scaleY = 1.0f); +void CC_DLL ccDrawCircle( const CCPoint& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY); +void CC_DLL ccDrawCircle( const CCPoint& center, float radius, float angle, unsigned int segments, bool drawLineToCenter); /** draws a quad bezier path @warning This function could be pretty slow. Use it only for debugging purposes. From e84606aa478d18be13ed2468b3e8d700cd606044 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 20 Sep 2012 16:15:00 +0800 Subject: [PATCH 071/181] Update cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp --- cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index 4d78611f79..53944e0fdc 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -1,4 +1,3 @@ - /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada @@ -260,7 +259,7 @@ void CCLayer::onExit() if( m_bIsTouchEnabled ) { pDirector->getTouchDispatcher()->removeDelegate(this); - // fix: CCLayer re-added to the scene after the loss of scripting touch events + // [lua]:don't unregister script touch handler, or the handler will be destroyed // unregisterScriptTouchHandler(); } From 1313398335c165b944fc1b08cf1a3f4452a536b1 Mon Sep 17 00:00:00 2001 From: dualface Date: Thu, 20 Sep 2012 23:22:45 +0800 Subject: [PATCH 072/181] [Lua] fix lua function reference error --- .../lua/cocos2dx_support/CCLuaEngine.cpp | 32 +++++++++++--- scripting/lua/cocos2dx_support/tolua_fix.c | 44 +++++++++++++++++-- scripting/lua/cocos2dx_support/tolua_fix.h | 6 ++- 3 files changed, 69 insertions(+), 13 deletions(-) diff --git a/scripting/lua/cocos2dx_support/CCLuaEngine.cpp b/scripting/lua/cocos2dx_support/CCLuaEngine.cpp index e31bd5acd4..1453ad51df 100644 --- a/scripting/lua/cocos2dx_support/CCLuaEngine.cpp +++ b/scripting/lua/cocos2dx_support/CCLuaEngine.cpp @@ -303,6 +303,8 @@ int CCLuaEngine::executeNodeEvent(CCNode* pNode, int nAction) { int nScriptHandler = pNode->getScriptHandler(); CC_BREAK_IF(0 == nScriptHandler); + + cleanStack(); CCLuaValueDict dict; if (nAction == kCCNodeOnEnter) { @@ -327,7 +329,9 @@ int CCLuaEngine::executeMenuItemEvent(CCMenuItem* pMenuItem) { int nScriptHandler = pMenuItem->getScriptTapHandler(); CC_BREAK_IF(0 == nScriptHandler); - ret = pushInt(pMenuItem->getTag()); + + cleanStack(); + pushInt(pMenuItem->getTag()); ret = executeFunctionByHandler(nScriptHandler, 1); } while (0); return ret; @@ -340,7 +344,9 @@ int CCLuaEngine::executeNotificationEvent(CCNotificationCenter* pNotificationCen { int nScriptHandler = pNotificationCenter->getScriptHandler(); CC_BREAK_IF(0 == nScriptHandler); - ret = pushString(pszName); + + cleanStack(); + pushString(pszName); ret = executeFunctionByHandler(nScriptHandler, 1); } while (0); return ret; @@ -353,9 +359,15 @@ int CCLuaEngine::executeCallFuncActionEvent(CCCallFunc* pAction, CCObject* pTarg { int nScriptHandler = pAction->getScriptHandler(); CC_BREAK_IF(0 == nScriptHandler); + + cleanStack(); if (pTarget != NULL) { - ret = pushCCObject(pTarget, "CCNode"); + pushCCObject(pTarget, "CCNode"); + } + else + { + pushNil(); } ret = executeFunctionByHandler(nScriptHandler, 1); } while (0); @@ -369,7 +381,9 @@ int CCLuaEngine::executeSchedule(CCTimer* pTimer, float dt, CCNode* pNode/* = NU { int nScriptHandler = pTimer->getScriptHandler(); CC_BREAK_IF(0 == nScriptHandler); - ret = pushFloat(dt); + + cleanStack(); + pushFloat(dt); ret = executeFunctionByHandler(nScriptHandler, 1); } while (0); return ret; @@ -385,6 +399,8 @@ int CCLuaEngine::executeLayerTouchEvent(CCLayer* pLayer, int eventType, CCTouch CC_BREAK_IF(NULL == pScriptHandlerEntry); int nScriptHandler = pScriptHandlerEntry->getHandler(); CC_BREAK_IF(0 == nScriptHandler); + + cleanStack(); CCPoint pt = CCDirector::sharedDirector()->convertToGL(pTouch->getLocationInView()); lua_pushinteger(m_state, eventType); lua_pushnumber(m_state, pt.x); @@ -403,6 +419,8 @@ int CCLuaEngine::executeLayerTouchesEvent(CCLayer* pLayer, int eventType, CCSet CC_BREAK_IF(NULL == pScriptHandlerEntry); int nScriptHandler = pScriptHandlerEntry->getHandler(); CC_BREAK_IF(0 == nScriptHandler); + + cleanStack(); lua_pushinteger(m_state, eventType); lua_newtable(m_state); @@ -564,7 +582,7 @@ int CCLuaEngine::pushCCLuaValueDict(const CCLuaValueDict& dict) for (CCLuaValueDictIterator it = dict.begin(); it != dict.end(); ++it) { lua_pushstring(m_state, it->first.c_str()); /* stack: table key */ - pushCCLuaValue(it->second); /* stack: table key value */ + pushCCLuaValue(it->second); /* stack: table key value */ lua_rawset(m_state, -3); /* table.key = value, stack: table */ } @@ -577,7 +595,7 @@ int CCLuaEngine::pushCCLuaValueArray(const CCLuaValueArray& array) int index = 1; for (CCLuaValueArrayIterator it = array.begin(); it != array.end(); ++it) { - pushCCLuaValue(*it); /* stack: table value */ + pushCCLuaValue(*it); /* stack: table value */ lua_rawseti(m_state, -2, index); /* table[index] = value, stack: table */ ++index; } @@ -617,7 +635,7 @@ void CCLuaEngine::addLuaLoader(lua_CFunction func) bool CCLuaEngine::pushFunction(int nHandler) { - lua_rawgeti(m_state, LUA_REGISTRYINDEX, nHandler); /* stack: ... func */ + toluafix_get_function_by_refid(m_state, nHandler); /* stack: ... func */ if (!lua_isfunction(m_state, -1)) { CCLOG("[LUA ERROR] function refid '%d' does not reference a Lua function", nHandler); diff --git a/scripting/lua/cocos2dx_support/tolua_fix.c b/scripting/lua/cocos2dx_support/tolua_fix.c index 1f98871efa..489052a7be 100644 --- a/scripting/lua/cocos2dx_support/tolua_fix.c +++ b/scripting/lua/cocos2dx_support/tolua_fix.c @@ -2,6 +2,8 @@ #include "tolua_fix.h" #include +static int s_function_ref_id = 0; + TOLUA_API void toluafix_open(lua_State* L) { lua_pushstring(L, TOLUA_REFID_PTR_MAPPING); @@ -11,6 +13,10 @@ TOLUA_API void toluafix_open(lua_State* L) lua_pushstring(L, TOLUA_REFID_TYPE_MAPPING); lua_newtable(L); lua_rawset(L, LUA_REGISTRYINDEX); + + lua_pushstring(L, TOLUA_REFID_FUNCTION_MAPPING); + lua_newtable(L); + lua_rawset(L, LUA_REGISTRYINDEX); } TOLUA_API int toluafix_pushusertype_ccobject(lua_State* L, @@ -145,15 +151,45 @@ TOLUA_API int toluafix_remove_ccobject_by_refid(lua_State* L, int refid) } TOLUA_API int toluafix_ref_function(lua_State* L, int lo, int def) -{ +{ + // function at lo if (!lua_isfunction(L, lo)) return 0; - lua_pushvalue(L, lo); /* stack: ... func */ - return luaL_ref(L, LUA_REGISTRYINDEX); + + s_function_ref_id++; + + lua_pushstring(L, TOLUA_REFID_FUNCTION_MAPPING); + lua_rawget(L, LUA_REGISTRYINDEX); /* stack: fun ... refid_fun */ + lua_pushinteger(L, s_function_ref_id); /* stack: fun ... refid_fun refid */ + lua_pushvalue(L, lo); /* stack: fun ... refid_fun refid fun */ + + lua_rawset(L, -3); /* refid_fun[refid] = fun, stack: fun ... refid_ptr */ + lua_pop(L, 1); /* stack: fun ... */ + + return s_function_ref_id; + + // lua_pushvalue(L, lo); /* stack: ... func */ + // return luaL_ref(L, LUA_REGISTRYINDEX); +} + +TOLUA_API void toluafix_get_function_by_refid(lua_State* L, int refid) +{ + lua_pushstring(L, TOLUA_REFID_FUNCTION_MAPPING); + lua_rawget(L, LUA_REGISTRYINDEX); /* stack: ... refid_fun */ + lua_pushinteger(L, refid); /* stack: ... refid_fun refid */ + lua_rawget(L, -2); /* stack: ... refid_fun fun */ + lua_remove(L, -2); /* stack: ... fun */ } TOLUA_API void toluafix_remove_function_by_refid(lua_State* L, int refid) { - luaL_unref(L, LUA_REGISTRYINDEX, refid); + lua_pushstring(L, TOLUA_REFID_FUNCTION_MAPPING); + lua_rawget(L, LUA_REGISTRYINDEX); /* stack: ... refid_fun */ + lua_pushinteger(L, refid); /* stack: ... refid_fun refid */ + lua_pushnil(L); /* stack: ... refid_fun refid nil */ + lua_rawset(L, -3); /* refid_fun[refid] = fun, stack: ... refid_ptr */ + lua_pop(L, 1); /* stack: ... */ + + // luaL_unref(L, LUA_REGISTRYINDEX, refid); } // check lua value is funciton diff --git a/scripting/lua/cocos2dx_support/tolua_fix.h b/scripting/lua/cocos2dx_support/tolua_fix.h index 88c3ff4b27..fde275ca48 100644 --- a/scripting/lua/cocos2dx_support/tolua_fix.h +++ b/scripting/lua/cocos2dx_support/tolua_fix.h @@ -11,7 +11,8 @@ extern "C" #define TOLUA_REFID_PTR_MAPPING "toluafix_refid_ptr_mapping" #define TOLUA_REFID_TYPE_MAPPING "toluafix_refid_type_mapping" - +#define TOLUA_REFID_FUNCTION_MAPPING "toluafix_refid_function_mapping" + TOLUA_API void toluafix_open(lua_State* L); TOLUA_API int toluafix_pushusertype_ccobject(lua_State* L, int uid, @@ -20,12 +21,13 @@ TOLUA_API int toluafix_pushusertype_ccobject(lua_State* L, const char* type); TOLUA_API int toluafix_remove_ccobject_by_refid(lua_State* L, int refid); TOLUA_API int toluafix_ref_function(lua_State* L, int lo, int def); +TOLUA_API void toluafix_get_function_by_refid(lua_State* L, int refid); TOLUA_API void toluafix_remove_function_by_refid(lua_State* L, int refid); TOLUA_API int toluafix_isfunction(lua_State* L, int lo, const char* type, int def, tolua_Error* err); TOLUA_API int toluafix_totable(lua_State* L, int lo, int def); TOLUA_API int toluafix_istable(lua_State* L, int lo, const char* type, int def, tolua_Error* err); TOLUA_API void toluafix_stack_dump(lua_State* L, const char* label); - + #ifdef __cplusplus } // extern "C" #endif From 6eabead4e3700bd71c8fef5e2b7f508080154118 Mon Sep 17 00:00:00 2001 From: dualface Date: Thu, 20 Sep 2012 23:32:26 +0800 Subject: [PATCH 073/181] [iOS] fix: enableRetina() and setDesignResolutionSize() can not be used simultaneously. FROM kunlun.com, THANKS --- cocos2dx/platform/ios/EAGLView.h | 4 +++ cocos2dx/platform/ios/EAGLView.mm | 44 ++++++++++++++++++++++++------- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/cocos2dx/platform/ios/EAGLView.h b/cocos2dx/platform/ios/EAGLView.h index 64c83233ab..2605819266 100755 --- a/cocos2dx/platform/ios/EAGLView.h +++ b/cocos2dx/platform/ios/EAGLView.h @@ -87,6 +87,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. BOOL preserveBackbuffer_; CGSize size_; + CGFloat designContentScaleFactor_; BOOL discardFramebufferSupported_; //fsaa addition @@ -142,6 +143,9 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. @property(nonatomic,readwrite) BOOL multiSampling; +/** call from AppController.mm */ +-(void) setDesignContentScaleFactor:(CGFloat)scale; +-(CGFloat) getDesignContentScaleFactor; /** EAGLView uses double-buffer. This method swaps the buffers */ -(void) swapBuffers; diff --git a/cocos2dx/platform/ios/EAGLView.mm b/cocos2dx/platform/ios/EAGLView.mm index 2f9ba0a360..e1807f3dd4 100755 --- a/cocos2dx/platform/ios/EAGLView.mm +++ b/cocos2dx/platform/ios/EAGLView.mm @@ -134,6 +134,7 @@ static EAGLView *view = 0; { if((self = [super initWithFrame:frame])) { + designContentScaleFactor_ = 1.0; isUseUITextField = YES; pixelformat_ = format; depthFormat_ = depth; @@ -162,6 +163,7 @@ static EAGLView *view = 0; CAEAGLLayer* eaglLayer = (CAEAGLLayer*)[self layer]; + designContentScaleFactor_ = 1.0; pixelformat_ = kEAGLColorFormatRGB565; depthFormat_ = 0; // GL_DEPTH_COMPONENT24_OES; multiSampling_= NO; @@ -200,15 +202,27 @@ static EAGLView *view = 0; -(int) getWidth { CGSize bound = [self bounds].size; - return bound.width; + return bound.width * designContentScaleFactor_; } -(int) getHeight { CGSize bound = [self bounds].size; - return bound.height; + return bound.height * designContentScaleFactor_; } +-(void) setDesignContentScaleFactor:(CGFloat)scale +{ + if ([self respondsToSelector:@selector(setContentScaleFactor:)]) { + [self setContentScaleFactor:scale]; // if val == 2.0, enable retina display + designContentScaleFactor_ = scale; + } +} + +-(CGFloat) getDesignContentScaleFactor +{ + return designContentScaleFactor_; +} -(BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup { @@ -401,8 +415,8 @@ static EAGLView *view = 0; int i = 0; for (UITouch *touch in touches) { ids[i] = (int)touch; - xs[i] = [touch locationInView: [touch view]].x; - ys[i] = [touch locationInView: [touch view]].y; + xs[i] = [touch locationInView: [touch view]].x * designContentScaleFactor_; + ys[i] = [touch locationInView: [touch view]].y * designContentScaleFactor_; ++i; } cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesBegin(i, ids, xs, ys); @@ -421,8 +435,8 @@ static EAGLView *view = 0; int i = 0; for (UITouch *touch in touches) { ids[i] = (int)touch; - xs[i] = [touch locationInView: [touch view]].x; - ys[i] = [touch locationInView: [touch view]].y; + xs[i] = [touch locationInView: [touch view]].x * designContentScaleFactor_; + ys[i] = [touch locationInView: [touch view]].y * designContentScaleFactor_; ++i; } cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesMove(i, ids, xs, ys); @@ -442,8 +456,8 @@ static EAGLView *view = 0; int i = 0; for (UITouch *touch in touches) { ids[i] = (int)touch; - xs[i] = [touch locationInView: [touch view]].x; - ys[i] = [touch locationInView: [touch view]].y; + xs[i] = [touch locationInView: [touch view]].x * designContentScaleFactor_; + ys[i] = [touch locationInView: [touch view]].y * designContentScaleFactor_; ++i; } cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesEnd(i, ids, xs, ys); @@ -463,8 +477,8 @@ static EAGLView *view = 0; int i = 0; for (UITouch *touch in touches) { ids[i] = (int)touch; - xs[i] = [touch locationInView: [touch view]].x; - ys[i] = [touch locationInView: [touch view]].y; + xs[i] = [touch locationInView: [touch view]].x * designContentScaleFactor_; + ys[i] = [touch locationInView: [touch view]].y * designContentScaleFactor_; ++i; } cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesCancel(i, ids, xs, ys); @@ -786,6 +800,15 @@ static EAGLView *view = 0; break; } + begin.origin.x *= designContentScaleFactor_; + begin.origin.y *= designContentScaleFactor_; + begin.size.width *= designContentScaleFactor_; + begin.size.height *= designContentScaleFactor_; + end.origin.x *= designContentScaleFactor_; + end.origin.y *= designContentScaleFactor_; + end.size.width *= designContentScaleFactor_; + end.size.height *= designContentScaleFactor_; + cocos2d::CCIMEKeyboardNotificationInfo notiInfo; notiInfo.begin = cocos2d::CCRect(begin.origin.x, begin.origin.y, @@ -859,6 +882,7 @@ static EAGLView *view = 0; // NSLog(@"[animation] dis = %f\n", dis); if (dis < 0.0f) dis = 0.0f; + dis /= designContentScaleFactor_; if (!cocos2d::CCEGLView::sharedOpenGLView()->isRetinaEnabled()) { From 46a8eb54918e41c533f82ff2549668734421dbf1 Mon Sep 17 00:00:00 2001 From: dualface Date: Thu, 20 Sep 2012 23:37:23 +0800 Subject: [PATCH 074/181] [Lua] add ccTexParams, add new luabinding build script, update luabinding --- .../LuaCocos2d.cpp.REMOVED.git-id | 2 +- tools/tolua++/CCTexture2D.pkg | 8 + tools/tolua++/build.php | 257 ++++++++++++++++++ 3 files changed, 266 insertions(+), 1 deletion(-) create mode 100644 tools/tolua++/build.php diff --git a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 3c867363b0..1bb2a5fbef 100644 --- a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -d33790c08f03c11f8432a3bd2b9be537d00fa8c2 \ No newline at end of file +dab2e1ed075027aac1e137daaa68542dfe2d7c63 \ No newline at end of file diff --git a/tools/tolua++/CCTexture2D.pkg b/tools/tolua++/CCTexture2D.pkg index a667d9fa38..b9966b1cd7 100644 --- a/tools/tolua++/CCTexture2D.pkg +++ b/tools/tolua++/CCTexture2D.pkg @@ -36,6 +36,14 @@ typedef enum { kTexture2DPixelFormat_Default = kCCTexture2DPixelFormat_Default } CCTexture2DPixelFormat; +class ccTexParams { + ccTexParams(void); + GLuint minFilter; + GLuint magFilter; + GLuint wrapS; + GLuint wrapT; +}; + class CCTexture2D : public CCObject { void releaseData(void* data); diff --git a/tools/tolua++/build.php b/tools/tolua++/build.php new file mode 100644 index 0000000000..80403afe7f --- /dev/null +++ b/tools/tolua++/build.php @@ -0,0 +1,257 @@ +_extensionName = $extensionName; + $this->_luabindingFilename = $luabindingFilename; + $this->_inputPath = SRC_DIR . $extensionName . '.pkg'; + $this->_outputCppPath = OUT_DIR . $luabindingFilename . '.cpp'; + $this->_outputHeaderPath = OUT_DIR . $luabindingFilename . '.h'; + $this->_luaopenFunctionName = sprintf('tolua_%s_open', $extensionName); + $this->_fix = $fix; + } + + function build() + { + $command = sprintf('%s -L basic.lua -o %s %s', + TOLUA_BIN, $this->_outputCppPath, $this->_inputPath); + + printf(" creating file: %s.cpp\n", $this->_luabindingFilename); + printf(" command: %s\n", $command); + passthru($command); + + if (file_exists($this->_outputCppPath)) + { + $this->_fixLuabindingFile(); + } + + $includeOnce = sprintf('__%s_H_', strtoupper($this->_luabindingFilename)); + $functionName = $this->_luaopenFunctionName; + $header = <<_luabindingFilename); + // file_put_contents($this->_outputHeaderPath, $header); + } + + function getLuaopenFunctionName() + { + return $this->_luaopenFunctionName; + } + + private function _fixLuabindingFile() + { + $contents = file_get_contents($this->_outputCppPath); + $contents = str_replace("\t", ' ', $contents); + foreach ($this->_fix as $find => $replace) + { + $find = str_replace('##EXTENSION_NAME##', $this->_extensionName, $find); + $replace = str_replace('##EXTENSION_NAME##', $this->_extensionName, $replace); + + $contents = str_replace($find, $replace, $contents); + } + + file_put_contents($this->_outputCppPath, $contents); + } +} + +$FIX = array(); + +// remove unused header +$find = <<m_uID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->m_nLuaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret +EOT; +$FIX[$find] = $replace; + +// fix LUA_STRING +$find = '((LUA_STRING*)'; +$replace = '('; +$FIX[$find] = $replace; + +$find = 'tolua_usertype(tolua_S,"LUA_STRING");'; +$replace = ''; +$FIX[$find] = $replace; + +$find = <<build(); From 5128f0e1a8a6353bac4e82f14a5ccb90be4fa278 Mon Sep 17 00:00:00 2001 From: Sergey Buravtsov Date: Thu, 20 Sep 2012 19:47:54 +0400 Subject: [PATCH 075/181] To be able to handle 302 redirects with curl we need to set option CURLOPT_FOLLOWLOCATION --- extensions/network/HttpClient.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/extensions/network/HttpClient.cpp b/extensions/network/HttpClient.cpp index 9227771575..02e1556ea3 100644 --- a/extensions/network/HttpClient.cpp +++ b/extensions/network/HttpClient.cpp @@ -251,6 +251,12 @@ int processGetTask(CCHttpRequest *request, write_callback callback, void *stream break; } + code = curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, request->getUrl()); + if (code != CURLE_OK) + { + break; + } + code = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, callback); if (code != CURLE_OK) { From e36c4abb6525957c9619fb31ef2b7f885ec4e299 Mon Sep 17 00:00:00 2001 From: dualface Date: Fri, 21 Sep 2012 00:21:24 +0800 Subject: [PATCH 076/181] [Lua] remove Lua script handler on CCNode destroy --- cocos2dx/base_nodes/CCNode.cpp | 2 ++ .../layers_scenes_transitions_nodes/CCLayer.cpp | 17 ++++++----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index be9e7c0913..57c36a97f1 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -99,6 +99,8 @@ CCNode::CCNode(void) CCNode::~CCNode(void) { CCLOGINFO( "cocos2d: deallocing" ); + + unregisterScriptHandler(); CC_SAFE_RELEASE(m_pActionManager); CC_SAFE_RELEASE(m_pScheduler); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index 53944e0fdc..ac2966fecb 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -97,18 +97,18 @@ CCLayer *CCLayer::create() void CCLayer::registerWithTouchDispatcher() { - CCDirector* pDirector = CCDirector::sharedDirector(); + CCTouchDispatcher* pDispatcher = CCDirector::sharedDirector()->getTouchDispatcher(); if (m_pScriptHandlerEntry) { if (m_pScriptHandlerEntry->isMultiTouches()) { - pDirector->getTouchDispatcher()->addStandardDelegate(this, 0); + pDispatcher->addStandardDelegate(this, 0); LUALOG("[LUA] Add multi-touches event handler: %d", m_pScriptHandlerEntry->getHandler()); } else { - pDirector->getTouchDispatcher()->addTargetedDelegate(this, + pDispatcher->addTargetedDelegate(this, m_pScriptHandlerEntry->getPriority(), m_pScriptHandlerEntry->getSwallowsTouches()); LUALOG("[LUA] Add touch event handler: %d", m_pScriptHandlerEntry->getHandler()); @@ -116,7 +116,7 @@ void CCLayer::registerWithTouchDispatcher() return; } - pDirector->getTouchDispatcher()->addStandardDelegate(this, 0); + pDispatcher->addStandardDelegate(this, 0); } void CCLayer::registerScriptTouchHandler(int nHandler, bool bIsMultiTouches, int nPriority, bool bSwallowsTouches) @@ -128,12 +128,8 @@ void CCLayer::registerScriptTouchHandler(int nHandler, bool bIsMultiTouches, int void CCLayer::unregisterScriptTouchHandler(void) { - if (m_pScriptHandlerEntry) - { - m_pScriptHandlerEntry->release(); - m_pScriptHandlerEntry = NULL; + CC_SAFE_RELEASE_NULL(m_pScriptHandlerEntry); } -} int CCLayer::excuteScriptTouchHandler(int nEventType, CCTouch *pTouch) { @@ -165,8 +161,7 @@ void CCLayer::setTouchEnabled(bool enabled) else { // have problems? - CCDirector* pDirector = CCDirector::sharedDirector(); - pDirector->getTouchDispatcher()->removeDelegate(this); + CCDirector::sharedDirector()->getTouchDispatcher()->removeDelegate(this); } } } From 10fa04796597f93987c3742a06afa2f43a1d81f5 Mon Sep 17 00:00:00 2001 From: dualface Date: Fri, 21 Sep 2012 00:29:16 +0800 Subject: [PATCH 077/181] Complete delete CCDirector after called CCDirector::purgeDirector() --- cocos2dx/CCDirector.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 5b86564aad..676fe0d6ed 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -73,21 +73,20 @@ NS_CC_BEGIN // XXX it should be a Director ivar. Move it there once support for multiple directors is added // singleton stuff -static CCDisplayLinkDirector s_SharedDirector; +static CCDisplayLinkDirector *s_SharedDirector = NULL; #define kDefaultFPS 60 // 60 frames per second extern const char* cocos2dVersion(void); CCDirector* CCDirector::sharedDirector(void) { - static bool s_bFirstUseDirector = true; - if (s_bFirstUseDirector) + if (!s_SharedDirector) { - s_bFirstUseDirector = false; - s_SharedDirector.init(); + s_SharedDirector = new CCDisplayLinkDirector(); + s_SharedDirector->init(); } - return &s_SharedDirector; + return s_SharedDirector; } CCDirector::CCDirector(void) @@ -162,7 +161,7 @@ bool CCDirector::init(void) CCDirector::~CCDirector(void) { - CCLOG("cocos2d: deallocing %p", this); + CCLOG("cocos2d: deallocing CCDirector %p", this); CC_SAFE_RELEASE(m_pFPSLabel); CC_SAFE_RELEASE(m_pSPFLabel); @@ -185,6 +184,8 @@ CCDirector::~CCDirector(void) CC_SAFE_DELETE(m_pLastUpdate); // delete fps string delete []m_pszFPS; + + s_SharedDirector = NULL; } void CCDirector::setGLDefaultValues(void) @@ -640,6 +641,9 @@ void CCDirector::purgeDirector() // OpenGL view m_pobOpenGLView->end(); m_pobOpenGLView = NULL; + + // delete CCDirector + release(); } void CCDirector::setNextScene(void) From 0fc7feb3f02dab98c8d6f2a8cbf024be39f8e344 Mon Sep 17 00:00:00 2001 From: Rohan Kuruvilla Date: Tue, 18 Sep 2012 17:38:33 -0700 Subject: [PATCH 078/181] Updating CCBReader to support Scripting Owners --- extensions/CCBReader/CCBReader.h | 6 ++++-- extensions/CCBReader/CCBSelectorResolver.h | 12 ++++++++++-- extensions/CCBReader/CCNodeLoader.cpp | 11 +++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/extensions/CCBReader/CCBReader.h b/extensions/CCBReader/CCBReader.h index a4314e37d2..459fe23416 100644 --- a/extensions/CCBReader/CCBReader.h +++ b/extensions/CCBReader/CCBReader.h @@ -235,7 +235,8 @@ public: static float getResolutionScale(); CCNode* readFileWithCleanUp(bool bCleanUp); - + bool hasScriptingOwner = false; + private: void cleanUpNodeGraph(CCNode *pNode); bool readSequences(); @@ -250,6 +251,7 @@ private: bool getBit(); void alignBits(); CCString* readUTF8(); + }; // end of effects group @@ -257,4 +259,4 @@ private: NS_CC_EXT_END -#endif \ No newline at end of file +#endif diff --git a/extensions/CCBReader/CCBSelectorResolver.h b/extensions/CCBReader/CCBSelectorResolver.h index 3ec7737e75..97d5c5df5b 100644 --- a/extensions/CCBReader/CCBSelectorResolver.h +++ b/extensions/CCBReader/CCBSelectorResolver.h @@ -3,6 +3,7 @@ #include "cocos2d.h" #include "ExtensionMacros.h" +#include "../GUI/CCControlExtension/CCInvocation.h" USING_NS_CC; NS_CC_EXT_BEGIN @@ -18,11 +19,18 @@ NS_CC_EXT_BEGIN class CCBSelectorResolver { public: virtual ~CCBSelectorResolver() {}; - - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) = 0; + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) = 0; + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) = 0; }; + +class CCBScriptOwnerProtocol { +public: + virtual ~CCBScriptOwnerProtocol() {}; + virtual CCBSelectorResolver * createNew() = 0; +}; + NS_CC_EXT_END #endif diff --git a/extensions/CCBReader/CCNodeLoader.cpp b/extensions/CCBReader/CCNodeLoader.cpp index 7f092916f0..a482a867ad 100644 --- a/extensions/CCBReader/CCNodeLoader.cpp +++ b/extensions/CCBReader/CCNodeLoader.cpp @@ -686,6 +686,17 @@ BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, C target = pCCBReader->getAnimationManager()->getRootNode(); } else if(selectorTarget == kCCBTargetTypeOwner) { target = pCCBReader->getOwner(); + + /* Scripting specific code because selector function is common for all callbacks. + * So if we had 1 target and 1 selector function, the context (callback function name) + * would get lost. Hence the need for a new target for each callback. + */ + if(pCCBReader->hasScriptingOwner) { + CCBScriptOwnerProtocol *proxy = dynamic_cast(pCCBReader->getOwner()); + if(proxy) { + target = dynamic_cast(proxy->createNew()); + } + } } if(target != NULL) { From 57680ec2d61c62472ee3dfc16ddb4721ce754ee3 Mon Sep 17 00:00:00 2001 From: Rohan Kuruvilla Date: Tue, 18 Sep 2012 18:19:28 -0700 Subject: [PATCH 079/181] Adding CCBuilderReader JS bindings --- .../bindings/js_bindings_ccbreader.cpp | 148 ++++++++++++++++++ .../bindings/js_bindings_ccbreader.h | 62 ++++++++ 2 files changed, 210 insertions(+) create mode 100644 scripting/javascript/bindings/js_bindings_ccbreader.cpp create mode 100644 scripting/javascript/bindings/js_bindings_ccbreader.h diff --git a/scripting/javascript/bindings/js_bindings_ccbreader.cpp b/scripting/javascript/bindings/js_bindings_ccbreader.cpp new file mode 100644 index 0000000000..0e4ae90323 --- /dev/null +++ b/scripting/javascript/bindings/js_bindings_ccbreader.cpp @@ -0,0 +1,148 @@ +// +// js_bindings_ccbreader.cpp +// watermelon +// +// Created by Rohan Kuruvilla on 14/08/2012. +// +// + +#include "js_bindings_ccbreader.h" +#include "ScriptingCore.h" +#include "CCNodeLoaderLibrary.h" + +USING_NS_CC; +USING_NS_CC_EXT; + + +SEL_MenuHandler CCBScriptCallbackProxy::onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, + cocos2d::CCString * pSelectorName) { + this->callBackProp = pSelectorName->getCString(); + return menu_selector(CCBScriptCallbackProxy::menuItemCallback); +} + +SEL_CCControlHandler CCBScriptCallbackProxy::onResolveCCBCCControlSelector(CCObject * pTarget, + CCString * pSelectorName) { + + this->callBackProp = pSelectorName->getCString(); + return cccontrol_selector(CCBScriptCallbackProxy::controlCallback); +} + +bool CCBScriptCallbackProxy::onAssignCCBMemberVariable(CCObject * pTarget, + CCString * pMemberVariableName, + CCNode * pNode) { +} + +void CCBScriptCallbackProxy::onNodeLoaded(CCNode * pNode, + CCNodeLoader * pNodeLoader) {} + +CCBSelectorResolver * CCBScriptCallbackProxy::createNew() { + CCBScriptCallbackProxy * ret = new CCBScriptCallbackProxy(); + ret->setJSOwner(this->owner); + return dynamic_cast(ret); +} + +void CCBScriptCallbackProxy::menuItemCallback(CCObject *pSender) { + ScriptingCore::getInstance()->executeFunctionWithOwner(owner, callBackProp.c_str() , JSVAL_NULL); +} + +void CCBScriptCallbackProxy::controlCallback(CCObject *pSender, CCControlEvent event) { + ScriptingCore::getInstance()->executeFunctionWithOwner(owner, callBackProp.c_str() , JSVAL_NULL); +} + +void CCBScriptCallbackProxy::setCallbackProperty(const char *prop) { + callBackProp = prop; +} + +void CCBScriptCallbackProxy::setJSOwner(jsval ownr) { + owner = ownr; +} + +jsval CCBScriptCallbackProxy::getJSOwner() { + return owner; +} + + +static CCNode* loadReader(const char *file, jsval owner) { + /* Create an autorelease CCNodeLoaderLibrary. */ + + /* Create an autorelease CCBReader. */ + CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary(); + + ccNodeLoaderLibrary->registerCCNodeLoader("", JSLayerLoader::loader()); + + cocos2d::extension::CCBReader * ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary); + ccbReader->autorelease(); + + /* Read a ccbi file. */ + ccbReader->hasScriptingOwner = true; + + CCBScriptCallbackProxy *ccBCallbackProxy = new CCBScriptCallbackProxy(); + ccBCallbackProxy->setJSOwner(owner); + //ccbReader->setOwner(dynamic_cast(ccBCallbackProxy)); + + CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast(ccBCallbackProxy); + if(targetAsCCBSelectorResolver != NULL) { + js_log("NOT NULL"); + } + + CCNode * node = ccbReader->readNodeGraphFromFile("./", file, dynamic_cast(ccBCallbackProxy)); + + return node; +} + + +JSBool js_CocosBuilder_Run(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc >= 1) { + jsval *argv = JS_ARGV(cx, vp); + const char *arg0; + do { + JSString *tmp = JS_ValueToString(cx, argv[0]); + arg0 = JS_EncodeString(cx, tmp); + } + while (0); + + jsval obj = argc >= 2 ? argv[1] : JSVAL_NULL; + js_log("%s: + ", JSVAL_TO_OBJECT(obj)); + CCNode * ret = loadReader(arg0, obj); + jsval jsret; + if (ret) { + js_proxy_t *proxy; + JS_GET_PROXY(proxy, ret); + if (proxy) { + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + // create a new js obj of that class + proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + + } + return JS_FALSE; +} + + +void register_CCBuilderReader(JSContext *cx, JSObject *obj) { + + + jsval nsval; + JSObject *ns; + JS_GetProperty(cx, obj, "cc", &nsval); + if (nsval == JSVAL_VOID) { + ns = JS_NewObject(cx, NULL, NULL, NULL); + nsval = OBJECT_TO_JSVAL(ns); + JS_SetProperty(cx, obj, "cc", &nsval); + } else { + JS_ValueToObject(cx, nsval, &ns); + } + obj = ns; + + JSObject *tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, obj, "(function () { cc = cc || {}; cc.Reader = cc.Reader || {}; return cc.Reader; })()")); + JS_DefineFunction(cx, tmpObj, "load", js_CocosBuilder_Run, 2, JSPROP_READONLY | JSPROP_PERMANENT) ; + +} diff --git a/scripting/javascript/bindings/js_bindings_ccbreader.h b/scripting/javascript/bindings/js_bindings_ccbreader.h new file mode 100644 index 0000000000..2ddc9f60c0 --- /dev/null +++ b/scripting/javascript/bindings/js_bindings_ccbreader.h @@ -0,0 +1,62 @@ +// +// js_bindings_ccbreader.h +// watermelon +// +// Created by Rohan Kuruvilla on 14/08/2012. +// +// +#include "jsapi.h" +#include "CCBReader.h" +#include "CCBSelectorResolver.h" +#include "CCBMemberVariableAssigner.h" +#include "CCInvocation.h" +#include "ExtensionMacros.h" +#include "CCLayerLoader.h" + +#include "cocos2d_specifics.hpp" + + +class CCBScriptCallbackProxy: public cocos2d::CCLayer +, public cocos2d::extension::CCBScriptOwnerProtocol +, public cocos2d::extension::CCBSelectorResolver +, public cocos2d::extension::CCBMemberVariableAssigner { + + std::string callBackProp; + jsval owner; + +public: + + + CCBScriptCallbackProxy () {} + virtual ~CCBScriptCallbackProxy() {} + + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(CCBScriptCallbackProxy, create); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, + cocos2d::CCString * pSelectorName); + + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, + cocos2d::CCString * pSelectorName); + virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, cocos2d::CCString * pMemberVariableName, + cocos2d::CCNode * pNode); + virtual void onNodeLoaded(cocos2d::CCNode * pNode, + cocos2d::extension::CCNodeLoader * pNodeLoader); + + virtual CCBSelectorResolver * createNew(); + void menuItemCallback(CCObject *pSender); + void controlCallback(CCObject *pSender, cocos2d::extension::CCControlEvent event); + void setCallbackProperty(const char *prop); + void setJSOwner(jsval ownr); + jsval getJSOwner(); +}; + + +class JSLayerLoader : public cocos2d::extension::CCLayerLoader { +public: + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(JSLayerLoader, loader); + +protected: + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCBScriptCallbackProxy); +}; + +void register_CCBuilderReader(JSContext *cx, JSObject *global); +JSBool js_CocosBuilder_Run(JSContext *cx, uint32_t argc, jsval *vp); From dde8d50d1576c90f6162bbf17483b05f8160c34c Mon Sep 17 00:00:00 2001 From: Rohan Kuruvilla Date: Tue, 18 Sep 2012 18:21:07 -0700 Subject: [PATCH 080/181] Adding member function executeFunctionWithOwner to ScriptingCore --- scripting/javascript/bindings/ScriptingCore.cpp | 8 ++++++++ scripting/javascript/bindings/ScriptingCore.h | 1 + 2 files changed, 9 insertions(+) diff --git a/scripting/javascript/bindings/ScriptingCore.cpp b/scripting/javascript/bindings/ScriptingCore.cpp index d516ba38bd..3cc51f897b 100644 --- a/scripting/javascript/bindings/ScriptingCore.cpp +++ b/scripting/javascript/bindings/ScriptingCore.cpp @@ -565,6 +565,14 @@ int ScriptingCore::executeFunctionWithObjectData(CCNode *self, const char *name, return 1; } +int ScriptingCore::executeFunctionWithOwner(jsval owner, const char *name, jsval data) { + jsval retval; + + executeJSFunctionWithName(this->cx, JSVAL_TO_OBJECT(owner), name, data, retval); + + return 1; +} + int ScriptingCore::executeCustomTouchesEvent(int eventType, CCSet *pTouches, JSObject *obj) { diff --git a/scripting/javascript/bindings/ScriptingCore.h b/scripting/javascript/bindings/ScriptingCore.h index 3597796854..3a5464ac37 100644 --- a/scripting/javascript/bindings/ScriptingCore.h +++ b/scripting/javascript/bindings/ScriptingCore.h @@ -81,6 +81,7 @@ public: virtual int executeLayerTouchEvent(CCLayer* pLayer, int eventType, CCTouch *pTouch); int executeFunctionWithObjectData(CCNode *self, const char *name, JSObject *obj); + int executeFunctionWithOwner(jsval owner, const char *name, jsval data); void executeJSFunctionWithThisObj(jsval thisObj, jsval callback, jsval data); From d1493a862f27348d0d8f3c6d700bfdb5128ed0b7 Mon Sep 17 00:00:00 2001 From: Rohan Kuruvilla Date: Tue, 18 Sep 2012 18:33:34 -0700 Subject: [PATCH 081/181] Updating template to support CCBuilderReader --- template/xcode4/cocos2dx_js.xctemplate/Classes/AppDelegate.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/template/xcode4/cocos2dx_js.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_js.xctemplate/Classes/AppDelegate.cpp index 2a4f303e40..c0b3a774af 100644 --- a/template/xcode4/cocos2dx_js.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx_js.xctemplate/Classes/AppDelegate.cpp @@ -8,6 +8,7 @@ #include "cocos2d_specifics.hpp" #include "js_bindings_chipmunk_manual.hpp" #include "js_bindings_chipmunk_functions.hpp" +#include "js_bindings_ccbreader.h" USING_NS_CC; using namespace CocosDenshion; @@ -43,6 +44,7 @@ bool AppDelegate::applicationDidFinishLaunching() sc->addRegisterCallback(register_cocos2dx_js_extensions); sc->addRegisterCallback(register_chipmunk_manual); sc->addRegisterCallback(register_CCPhysicsSprite); + sc->addRegisterCallback(register_CCBuilderReader); From 9e1e64509bfd77178cf8d828d9b48d015b6b691c Mon Sep 17 00:00:00 2001 From: Rohan Kuruvilla Date: Tue, 18 Sep 2012 18:44:21 -0700 Subject: [PATCH 082/181] Copying changes previously made into cxx-generator/targets/spidermonkey/common 1. Fixed memory leak while removing proxy objects 2. Fixed JS Context restart 3. Added JS conversion for CCArray 4. Updated generated bindings with some more classes --- .../javascript/bindings/ScriptingCore.cpp | 34 +++++++++++++++++-- scripting/javascript/bindings/ScriptingCore.h | 3 ++ .../javascript/bindings/cocos2d_specifics.cpp | 2 ++ .../bindings/spidermonkey_specifics.h | 4 +-- tools/tojs/cocos2dx.ini | 5 ++- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/scripting/javascript/bindings/ScriptingCore.cpp b/scripting/javascript/bindings/ScriptingCore.cpp index 3cc51f897b..dc4019e376 100644 --- a/scripting/javascript/bindings/ScriptingCore.cpp +++ b/scripting/javascript/bindings/ScriptingCore.cpp @@ -14,6 +14,7 @@ #include #include "ScriptingCore.h" #include "cocos2d.h" +#include "cocos2d_specifics.hpp" #ifdef ANDROID #include @@ -275,8 +276,19 @@ void ScriptingCore::addRegisterCallback(sc_register_sth callback) { registrationList.push_back(callback); } +void ScriptingCore::removeAllRoots(JSContext *cx) { + js_proxy_t *current, *tmp; + HASH_ITER(hh, _js_native_global_ht, current, tmp) { + JS_RemoveObjectRoot(cx, ¤t->obj); + } + HASH_CLEAR(hh, _js_native_global_ht); + HASH_CLEAR(hh, _native_js_global_ht); + HASH_CLEAR(hh, _js_global_type_ht); +} + void ScriptingCore::createGlobalContext() { - if (this->cx && this->rt) { + if (this->cx && this->rt) { + ScriptingCore::removeAllRoots(this->cx); JS_DestroyContext(this->cx); JS_DestroyRuntime(this->rt); this->cx = NULL; @@ -368,8 +380,8 @@ void ScriptingCore::removeScriptObjectByCCObject(CCObject* pObj) JS_GET_PROXY(nproxy, ptr); if (nproxy) { JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); - JS_RemoveObjectRoot(cx, &nproxy->obj); JS_GET_NATIVE_PROXY(jsproxy, nproxy->obj); + JS_RemoveObjectRoot(cx, &jsproxy->obj); JS_REMOVE_PROXY(nproxy, jsproxy); } } @@ -784,7 +796,23 @@ CCArray* jsval_to_ccarray(JSContext* cx, jsval v) { return NULL; } -// from native + +jsval ccarray_to_jsval(JSContext* cx, CCArray *arr) { + + JSObject *jsretArr = JS_NewArrayObject(cx, 0, NULL); + + for(int i = 0; i < arr->count(); ++i) { + + CCObject *obj = arr->objectAtIndex(i); + js_proxy_t *proxy = js_get_or_create_proxy(cx, obj); + jsval arrElement = OBJECT_TO_JSVAL(proxy->obj); + + if(!JS_SetElement(cx, jsretArr, i, &arrElement)) { + break; + } + } + return OBJECT_TO_JSVAL(jsretArr); +} jsval long_long_to_jsval(JSContext* cx, long long v) { JSObject *tmp = JS_NewUint32Array(cx, 2); diff --git a/scripting/javascript/bindings/ScriptingCore.h b/scripting/javascript/bindings/ScriptingCore.h index 3a5464ac37..b3cc01dfe3 100644 --- a/scripting/javascript/bindings/ScriptingCore.h +++ b/scripting/javascript/bindings/ScriptingCore.h @@ -115,6 +115,8 @@ public: * and create a new one. */ void createGlobalContext(); + + static void removeAllRoots(JSContext *cx); int executeCustomTouchEvent(int eventType, @@ -181,6 +183,7 @@ ccColor4B jsval_to_cccolor4b(JSContext *cx, jsval v); ccColor4F jsval_to_cccolor4f(JSContext *cx, jsval v); ccColor3B jsval_to_cccolor3b(JSContext *cx, jsval v); CCArray* jsval_to_ccarray(JSContext* cx, jsval v); +jsval ccarray_to_jsval(JSContext* cx, CCArray *arr); // from native jsval long_long_to_jsval(JSContext* cx, long long v); jsval std_string_to_jsval(JSContext* cx, std::string& v); diff --git a/scripting/javascript/bindings/cocos2d_specifics.cpp b/scripting/javascript/bindings/cocos2d_specifics.cpp index 70a0e1f0d2..f3b4151b38 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.cpp +++ b/scripting/javascript/bindings/cocos2d_specifics.cpp @@ -451,6 +451,8 @@ JSBool js_cocos2dx_swap_native_object(JSContext *cx, uint32_t argc, jsval *vp) js_proxy_t *jsproxy; JS_GET_PROXY(jsproxy, ptrTwo); if (jsproxy) { + JS_RemoveObjectRoot(cx, &nproxy->obj); + JS_REMOVE_PROXY(jsproxy, nproxy); JS_NEW_PROXY(nproxy, ptrTwo, one); } diff --git a/scripting/javascript/bindings/spidermonkey_specifics.h b/scripting/javascript/bindings/spidermonkey_specifics.h index d482c56e01..a166b15356 100644 --- a/scripting/javascript/bindings/spidermonkey_specifics.h +++ b/scripting/javascript/bindings/spidermonkey_specifics.h @@ -77,8 +77,8 @@ do { \ #define JS_REMOVE_PROXY(nproxy, jsproxy) \ do { \ - if (nproxy) HASH_DEL(_native_js_global_ht, nproxy); \ - if (jsproxy) HASH_DEL(_js_native_global_ht, jsproxy); \ + if (nproxy) { HASH_DEL(_native_js_global_ht, nproxy); free(nproxy); } \ + if (jsproxy) { HASH_DEL(_js_native_global_ht, jsproxy); free(jsproxy); } \ } while (0) #define TEST_NATIVE_OBJECT(cx, native_obj) \ diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index 8962a0e55f..e06a960fe8 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -27,7 +27,8 @@ headers = %(cocosdir)s/cocos2dx/include/cocos2d.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^CCMenu*$". -classes = CCSprite.* CCScene CCNode CCDirector CCLayer.* CCMenu.* CCTouch CC.*Action.* CCMove.* CCRotate.* CCBlink.* CCTint.* CCSequence CCRepeat.* CCFade.* CCEase.* CCScale.* CCTransition.* CCSpawn CCSequence CCAnimat.* CCFlip.* CCDelay.* CCSkew.* CCJump.* CCPlace.* CCShow.* CCProgress.* CCToggleVisibility.* CCHide CCParticle.* CCLabel.* CCAtlas.* CCTextureCache.* CCTexture2D CCParallaxNode CCTileMap.* CCTMX.* CCCallFunc CCRenderTexture CCGridAction CCGrid3DAction CCShaky3D CCWaves3D CCFlipX3D CCFlipY3D CCSpeed CCSet + +classes = CCSprite.* CCScene CCNode CCDirector CCLayer.* CCMenu.* CCTouch CC.*Action.* CCMove.* CCRotate.* CCBlink.* CCTint.* CCSequence CCRepeat.* CCFade.* CCEase.* CCScale.* CCTransition.* CCSpawn CCSequence CCAnimat.* CCFlip.* CCDelay.* CCSkew.* CCJump.* CCPlace.* CCShow.* CCProgress.* CCToggleVisibility.* CCHide CCParticle.* CCLabel.* CCAtlas.* CCTextureCache.* CCTexture2D CCParallaxNode CCTileMap.* CCTMX.* CCCallFunc CCRenderTexture CCGridAction CCGrid3DAction CCShaky3D CCWaves3D CCFlipX3D CCFlipY3D CCSpeed CCSet CCObject # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -42,7 +43,6 @@ skip = CCNode::[.*Transform convertToWindowSpace getChildren getGrid setGLServer CCMenu.*::[.*Target getSubItems create alignItemsInColumns initWithItems alignItemsInRows], CCMenuItem.*::[create], CCRGBAProtocol::[*], - CCObject::[*], CCCopying::[*], CC.*Protocol::[*], CC.*Delegate::[*], @@ -79,7 +79,6 @@ skip = CCNode::[.*Transform convertToWindowSpace getChildren getGrid setGLServer CCGrid3DAction::[create actionWith.*], CCTiledGrid3DAction::[create actionWith.*], CCTMXMapInfo::[startElement endElement textHandler], - CCTMXObjectGroup::[getObjects], CCTexture2D::[initWithPVRTCData addPVRTCImage], CCLayerMultiplex::[*], CCTextureCache::[addPVRTCImage], From d097406f18e82718076eb25c39c16ce2a1ed1bc8 Mon Sep 17 00:00:00 2001 From: Rohan Kuruvilla Date: Tue, 18 Sep 2012 18:56:54 -0700 Subject: [PATCH 083/181] Modifying MenuItemToggle bindings to make it work --- .../javascript/bindings/cocos2d_specifics.cpp | 52 +++++++++++++------ 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/scripting/javascript/bindings/cocos2d_specifics.cpp b/scripting/javascript/bindings/cocos2d_specifics.cpp index f3b4151b38..db3e0ec738 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.cpp +++ b/scripting/javascript/bindings/cocos2d_specifics.cpp @@ -326,27 +326,45 @@ JSBool js_cocos2dx_CCMenuItemFont_create(JSContext *cx, uint32_t argc, jsval *vp return JS_FALSE; } + JSBool js_cocos2dx_CCMenuItemToggle_create(JSContext *cx, uint32_t argc, jsval *vp) { - if (argc >= 1) { - jsval *argv = JS_ARGV(cx, vp); - cocos2d::CCMenuItemToggle* ret = cocos2d::CCMenuItemToggle::create(); - JSObject *obj = bind_menu_item(cx, ret, (argc == 2 ? argv[1] : JSVAL_VOID), argv[0]); - for (int i=1; i < argc; i++) { - js_proxy_t *proxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[i]); - JS_GET_NATIVE_PROXY(proxy, tmpObj); - cocos2d::CCMenuItem* item = (cocos2d::CCMenuItem*)(proxy ? proxy->ptr : NULL); - TEST_NATIVE_OBJECT(cx, item) - ret->addSubItem(item); - } - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); - return JS_TRUE; - } - return JS_FALSE; + if (argc >= 1) { + jsval *argv = JS_ARGV(cx, vp); + cocos2d::CCMenuItemToggle* ret = cocos2d::CCMenuItemToggle::create(); + + + for (int i=0; i < argc; i++) { + js_proxy_t *proxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[i]); + JS_GET_NATIVE_PROXY(proxy, tmpObj); + cocos2d::CCMenuItem* item = (cocos2d::CCMenuItem*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, item) + if(i == 0) ret->initWithItem(item); + else ret->addSubItem(item); + } + + jsval jsret; + if (ret) { + js_proxy_t *proxy; + JS_GET_PROXY(proxy, ret); + if (proxy) { + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + // create a new js obj of that class + proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + } + return JS_FALSE; } - JSBool js_cocos2dx_setCallback(JSContext *cx, uint32_t argc, jsval *vp) { if(argc == 2) { From 423bdf3f5a37d13fa67ef70bad75d4c3b069d4fa Mon Sep 17 00:00:00 2001 From: Rohan Kuruvilla Date: Thu, 20 Sep 2012 17:24:18 -0700 Subject: [PATCH 084/181] Adding createWithTotalParticles static function to CCParticleSystemQuad --- cocos2dx/particle_nodes/CCParticleSystemQuad.cpp | 12 ++++++++++++ cocos2dx/particle_nodes/CCParticleSystemQuad.h | 1 + 2 files changed, 13 insertions(+) diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp index 35fe1f0e02..8619371b8f 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp @@ -120,6 +120,18 @@ CCParticleSystemQuad * CCParticleSystemQuad::create(const char *plistFile) return pRet; } +CCParticleSystemQuad * CCParticleSystemQuad::createWithTotalParticles(unsigned int numberOfParticles) { + CCParticleSystemQuad *pRet = new CCParticleSystemQuad(); + if (pRet && pRet->initWithTotalParticles(numberOfParticles)) + { + pRet->autorelease(); + return pRet; + } + CC_SAFE_DELETE(pRet); + return pRet; +} + + // pointRect should be in Texture coordinates, not pixel coordinates void CCParticleSystemQuad::initTexCoordsWithRect(const CCRect& pointRect) { diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.h b/cocos2dx/particle_nodes/CCParticleSystemQuad.h index 10822f4a24..e546bffdf1 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.h +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.h @@ -110,6 +110,7 @@ public: CC_DEPRECATED_ATTRIBUTE static CCParticleSystemQuad * node(); static CCParticleSystemQuad * create(); + static CCParticleSystemQuad * createWithTotalParticles(unsigned int numberOfParticles); private: #if CC_TEXTURE_ATLAS_USE_VAO void setupVBOandVAO(); From bc35e7317990d2e26c018ca081df0a14cbdd6d6e Mon Sep 17 00:00:00 2001 From: Rohan Kuruvilla Date: Thu, 20 Sep 2012 14:49:14 -0700 Subject: [PATCH 085/181] Updating cocos2dx.ini including, 1. Adding key "rename_classes" 2. Renaming key "rename" to "rename_functions" 3. Adding CCParticleSystemQuad specific stuff --- tools/tojs/cocos2dx.ini | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index e06a960fe8..fe721313d6 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -79,18 +79,21 @@ skip = CCNode::[.*Transform convertToWindowSpace getChildren getGrid setGLServer CCGrid3DAction::[create actionWith.*], CCTiledGrid3DAction::[create actionWith.*], CCTMXMapInfo::[startElement endElement textHandler], + CCParticleSystemQuad::[postStep setBatchNode draw setTexture$ setTotalParticles updateQuadWithParticle setupIndices listenBackToForeground initWithTotalParticles particleWithFile node], CCTexture2D::[initWithPVRTCData addPVRTCImage], CCLayerMultiplex::[*], CCTextureCache::[addPVRTCImage], *::[copyWith.* onEnter.* onExit.* description getObjectType .*RGB.* .*HSV.*] -rename = CCDirector::[sharedDirector=getInstance], +rename_functions = CCDirector::[sharedDirector=getInstance], CCSpriteFrameCache::[sharedSpriteFrameCache=getInstance addSpriteFramesWithFile=addSpriteFrames], CCMenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize fontSizeObj=fontSize fontNameObj=fontName], CCProgressTimer::[setReverseProgress=setReverseDirection], CCTextureCache::[sharedTextureCache=getInstance], CCMenuItem::[setEnabled=setIsEnabled] +rename_classes = CCParticleSystemQuad::CCParticleSystem + # for all class names, should we remove something when registering in the target VM? remove_prefix = CC From 100a7a18838c2f78ecde470747644105876208cd Mon Sep 17 00:00:00 2001 From: Rohan Kuruvilla Date: Thu, 20 Sep 2012 17:46:29 -0700 Subject: [PATCH 086/181] Adding sample game wrapper using CCBReader. Also includes small modification to CCBReader --- extensions/CCBReader/CCData.h | 2 +- .../bindings/js_bindings_ccbreader.cpp | 16 +- .../CCB/Abadi40-hd.png.REMOVED.git-id | 1 + .../CCB/Abadi40-ipad.png.REMOVED.git-id | 1 + .../Resources/CCB/Abadi40.png.REMOVED.git-id | 1 + .../Resources/CCB/Gas40-hd.png.REMOVED.git-id | 1 + .../CCB/Gas40-ipad.png.REMOVED.git-id | 1 + .../CCB/konqa32-hd.png.REMOVED.git-id | 1 + .../CCB/konqa32-ipad.png.REMOVED.git-id | 1 + .../Resources/CCB/konqa32.png.REMOVED.git-id | 1 + .../cocos2dx_js.xctemplate/Resources/hello.js | 146 ++++++++++++++++-- 11 files changed, 153 insertions(+), 19 deletions(-) create mode 100644 template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-hd.png.REMOVED.git-id create mode 100644 template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-ipad.png.REMOVED.git-id create mode 100644 template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40.png.REMOVED.git-id create mode 100644 template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-hd.png.REMOVED.git-id create mode 100644 template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-ipad.png.REMOVED.git-id create mode 100644 template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-hd.png.REMOVED.git-id create mode 100644 template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-ipad.png.REMOVED.git-id create mode 100644 template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32.png.REMOVED.git-id diff --git a/extensions/CCBReader/CCData.h b/extensions/CCBReader/CCData.h index 68814ca7be..127b6a69c0 100644 --- a/extensions/CCBReader/CCData.h +++ b/extensions/CCBReader/CCData.h @@ -3,7 +3,7 @@ #define __CCB_CCDATA_H__ #include "cocos2d.h" -#include "cocos-ext.h" +#include "ExtensionMacros.h"" NS_CC_EXT_BEGIN diff --git a/scripting/javascript/bindings/js_bindings_ccbreader.cpp b/scripting/javascript/bindings/js_bindings_ccbreader.cpp index 0e4ae90323..50e7e98a35 100644 --- a/scripting/javascript/bindings/js_bindings_ccbreader.cpp +++ b/scripting/javascript/bindings/js_bindings_ccbreader.cpp @@ -13,10 +13,19 @@ USING_NS_CC; USING_NS_CC_EXT; +static void removeSelector(std::string &str) { + size_t found; + found = str.find(":"); + while (found!=std::string::npos){ + str.replace(found, found+1, ""); + found = str.find(":"); + } +} SEL_MenuHandler CCBScriptCallbackProxy::onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName) { this->callBackProp = pSelectorName->getCString(); + removeSelector(this->callBackProp); return menu_selector(CCBScriptCallbackProxy::menuItemCallback); } @@ -24,12 +33,14 @@ SEL_CCControlHandler CCBScriptCallbackProxy::onResolveCCBCCControlSelector(CCObj CCString * pSelectorName) { this->callBackProp = pSelectorName->getCString(); + removeSelector(this->callBackProp); return cccontrol_selector(CCBScriptCallbackProxy::controlCallback); } bool CCBScriptCallbackProxy::onAssignCCBMemberVariable(CCObject * pTarget, CCString * pMemberVariableName, CCNode * pNode) { + return true; } void CCBScriptCallbackProxy::onNodeLoaded(CCNode * pNode, @@ -81,11 +92,8 @@ static CCNode* loadReader(const char *file, jsval owner) { //ccbReader->setOwner(dynamic_cast(ccBCallbackProxy)); CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast(ccBCallbackProxy); - if(targetAsCCBSelectorResolver != NULL) { - js_log("NOT NULL"); - } - CCNode * node = ccbReader->readNodeGraphFromFile("./", file, dynamic_cast(ccBCallbackProxy)); + CCNode * node = ccbReader->readNodeGraphFromFile(file, dynamic_cast(ccBCallbackProxy)); return node; } diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-hd.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-hd.png.REMOVED.git-id new file mode 100644 index 0000000000..18b9c22de9 --- /dev/null +++ b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-hd.png.REMOVED.git-id @@ -0,0 +1 @@ +f06c047dd32b61f12ad51e981afe518364512be6 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-ipad.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-ipad.png.REMOVED.git-id new file mode 100644 index 0000000000..717ceb89a1 --- /dev/null +++ b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-ipad.png.REMOVED.git-id @@ -0,0 +1 @@ +4b7c1e97acefff48ae3652f023e708245992f553 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40.png.REMOVED.git-id new file mode 100644 index 0000000000..fb1884455b --- /dev/null +++ b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40.png.REMOVED.git-id @@ -0,0 +1 @@ +ae62d7b07ac3e7579ed7d6a2e1f903719e45c6d9 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-hd.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-hd.png.REMOVED.git-id new file mode 100644 index 0000000000..5067e00b74 --- /dev/null +++ b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-hd.png.REMOVED.git-id @@ -0,0 +1 @@ +12db20c3124e1bd864312257eb8cefe95d2ee349 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-ipad.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-ipad.png.REMOVED.git-id new file mode 100644 index 0000000000..8ddebffce2 --- /dev/null +++ b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-ipad.png.REMOVED.git-id @@ -0,0 +1 @@ +e71140c1535f16b49980f3ea0cf7d3a29a8a9788 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-hd.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-hd.png.REMOVED.git-id new file mode 100644 index 0000000000..15f23ffc85 --- /dev/null +++ b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-hd.png.REMOVED.git-id @@ -0,0 +1 @@ +dc235c169030151e337ecbfa1fc6302fc909e500 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-ipad.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-ipad.png.REMOVED.git-id new file mode 100644 index 0000000000..2549ab6362 --- /dev/null +++ b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-ipad.png.REMOVED.git-id @@ -0,0 +1 @@ +9e95a02e6eb2944fea12a49eb3f2c6fe7505a3ce \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32.png.REMOVED.git-id new file mode 100644 index 0000000000..83954562c0 --- /dev/null +++ b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32.png.REMOVED.git-id @@ -0,0 +1 @@ +1423c81273926b3da9fb1cb36c9b710d3f14ee0e \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/hello.js b/template/xcode4/cocos2dx_js.xctemplate/Resources/hello.js index 3e737b8ca6..0d77bcec6d 100644 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/hello.js +++ b/template/xcode4/cocos2dx_js.xctemplate/Resources/hello.js @@ -1,5 +1,6 @@ + try { - + cc.p = cc.p || function( x, y ) { return {x:x, y:y}; }; @@ -7,23 +8,140 @@ try { cc.c4b = cc.c4 || function (r, g, b, o) { return {r: r, g: g, b: b, a: o}; }; + + + cc.c3 = cc.c3 || function (r, g, b) { + return {r: r, g: g, b: b}; + }; + cc.BLACK = cc.c3(0,0,0); + director = cc.Director.getInstance(); winSize = director.getWinSize(); + centerPos = cc.p( winSize.width/2, winSize.height/2 ); - var scene = new cc.Scene(); - var layer = new cc.LayerGradient(); + var GameCreator = function() { + + var self = {}; + self.callbacks = {}; + + self.getPlayScene = function() { + + var scene = new cc.Scene(); + var layer = new cc.LayerGradient(); + + layer.init(cc.c4b(0, 0, 0, 255), cc.c4b(0, 128, 255, 255)); + + var lab = "Houston we have liftoff!"; + var label = cc.LabelTTF.create(lab, "Arial", 28); + layer.addChild(label, 1); + label.setPosition( cc.p(winSize.width / 2, winSize.height / 2)); + + var back = cc.MenuItemFont.create("Back", this.callbacks, this.callbacks.onBack ); + back.setColor( cc.BLACK ); + + var menu = cc.Menu.create( back ); + layer.addChild( menu ); + menu.alignItemsVertically(); + menu.setPosition( cc.p( winSize.width - 50, 50) ); + + scene.addChild(layer); + + return scene; + }; + + self.getMainMenuScene = function() { + var l = cc.Layer.create(); + var scene = cc.Scene.create(); + + var node = cc.Reader.load("MainMenu.ccbi", this, winSize); + l.addChild(node); + + scene.addChild(l); + + return scene; + }; + + self.getOptionsScene = function() { + + var l = cc.LayerGradient.create(); + l.init(cc.c4b(0, 0, 0, 255), cc.c4b(255, 255, 255, 255)); + + var scene = cc.Scene.create(); + + var label1 = cc.LabelBMFont.create("MUSIC ON", "konqa32.fnt" ); + var item1 = cc.MenuItemLabel.create(label1); + var label2 = cc.LabelBMFont.create("MUSIC OFF", "konqa32.fnt" ); + var item2 = cc.MenuItemLabel.create(label2); + var toggle = cc.MenuItemToggle.create( item1, item2 ); + + this.onMusicToggle = function( sender ) { + }; + + toggle.setCallback( this, this.onMusicToggle); + + var back = cc.MenuItemFont.create("Back", this.callbacks, this.callbacks.onBack ); + var menu = cc.Menu.create( toggle, back ); + l.addChild( menu ); + menu.alignItemsVertically(); + menu.setPosition( centerPos ); + + scene.addChild(l); + + return scene; + }; + + + self.getAboutScene = function() { + + var scene = cc.Scene.create(); + var l = cc.Layer.create(); + var about = cc.Reader.load("About.ccbi", this); + l.addChild( about ) + + var back = cc.MenuItemFont.create("Back", this.callbacks, this.callbacks.onBack ); + back.setColor( cc.BLACK ); + var menu = cc.Menu.create( back ); + l.addChild( menu ); + menu.alignItemsVertically(); + menu.setPosition( cc.p( winSize.width - 50, 50) ); + + scene.addChild( l ); + + return scene; + }; + + + // CCBuilder Selectors + + self.onPlay = function() { + director.replaceScene( cc.TransitionFade.create(1, this.getPlayScene()) ); + } + + self.onAbout = function() { + director.replaceScene( cc.TransitionZoomFlipY.create(1, this.getAboutScene()) ); + }; - layer.init(cc.c4b(0, 0, 0, 255), cc.c4b(0, 128, 255, 255)); + self.onOptions = function() { + director.replaceScene( cc.TransitionZoomFlipY.create(1, this.getOptionsScene()) ); + }; + + + // Manual Callbacks + + self.callbacks.onBack = function( sender) { + director.replaceScene( cc.TransitionFlipX.create(1, self.getMainMenuScene()) ); + }; + + return self; - var lab = "Houston we have liftoff!"; - var label = cc.LabelTTF.create(lab, "Arial", 28); - layer.addChild(label, 1); - label.setPosition( cc.p(winSize.width / 2, winSize.height / 2)); + }; + + var game = GameCreator(); + + __jsc__.garbageCollect(); + + director.runWithScene(game.getMainMenuScene()); + +} catch(e) {log(e);} - - scene.addChild(layer); - - director.runWithScene(scene); - -} catch(e) {log(e);} \ No newline at end of file From c7ffe79baf12b75fdb94f9e850d50c0a8633a672 Mon Sep 17 00:00:00 2001 From: Walzer Date: Fri, 21 Sep 2012 10:10:17 +0800 Subject: [PATCH 087/181] remove useless LOCAL_STATIC_LIBRARIES := curl_static_prebuilt in TestCpp/proj.android/jni/android.mk The linking relationship is TestCpp -> cocos_extension_static -> cocos_curl_static now. Applications can link the extension library to use libcurl. And this line still links curl_static_prebuilt which is not exist now, which made developers confused. --- samples/TestCpp/proj.android/jni/Android.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/samples/TestCpp/proj.android/jni/Android.mk b/samples/TestCpp/proj.android/jni/Android.mk index b3ccbfea73..9b05f81c23 100644 --- a/samples/TestCpp/proj.android/jni/Android.mk +++ b/samples/TestCpp/proj.android/jni/Android.mk @@ -10,8 +10,6 @@ LOCAL_SRC_FILES := testcpp/main.cpp LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes -LOCAL_STATIC_LIBRARIES := curl_static_prebuilt - LOCAL_WHOLE_STATIC_LIBRARIES := cocos_testcpp_common LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static From 4d04a1863b8043ff54710326da8f925cc14ae152 Mon Sep 17 00:00:00 2001 From: Byung Choi Date: Fri, 21 Sep 2012 14:34:05 +0900 Subject: [PATCH 088/181] make-all-linux now builds debug & release, testCpp also gets both --- make-all-linux-project.sh | 20 +++++++++------ samples/TestCpp/proj.linux/Makefile | 38 ++++++++++++++++++++--------- samples/TestCpp/proj.linux/main.cpp | 2 +- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/make-all-linux-project.sh b/make-all-linux-project.sh index 6fb94bc783..166f472e92 100755 --- a/make-all-linux-project.sh +++ b/make-all-linux-project.sh @@ -51,10 +51,12 @@ if ! test -d $DIR_GLEW170/glew-1.7.0/; then fi fi -OUTPUT_DEBUG=$COCOS2DX20_TRUNK/lib/linux/Debug/ -if ! test -d $OUTPUT_DEBUG; then - mkdir $OUTPUT_DEBUG -p -fi +#OUTPUT_DEBUG=$COCOS2DX20_TRUNK/lib/linux/Debug/ +#if ! test -d $OUTPUT_DEBUG; then +# mkdir $OUTPUT_DEBUG -p +#fi +mkdir -p $OUTPUT_DEBUG +mkdir -p $OUTPUT_RELEASE make -C $COCOS2DX20_TRUNK/external/Box2D/proj.linux clean make -C $COCOS2DX20_TRUNK/external/Box2D/proj.linux debug @@ -98,9 +100,13 @@ make -C $COCOS2DX20_TRUNK/CocosDenshion/proj.linux release check_make_result cp $COCOS2DX20_TRUNK/CocosDenshion/proj.linux/libcocosdenshion.so $OUTPUT_RELEASE -#make -C $COCOS2DX20_TRUNK/samples/TestCpp/proj.linux clean -#make -C $COCOS2DX20_TRUNK/samples/TestCpp/proj.linux -#check_make_result +make -C $COCOS2DX20_TRUNK/samples/TestCpp/proj.linux clean +make -C $COCOS2DX20_TRUNK/samples/TestCpp/proj.linux debug +check_make_result +make -C $COCOS2DX20_TRUNK/samples/TestCpp/proj.linux clean +make -C $COCOS2DX20_TRUNK/samples/TestCpp/proj.linux release +check_make_result + #make -C $COCOS2DX20_TRUNK/samples/HelloCpp/proj.linux clean #make -C $COCOS2DX20_TRUNK/samples/HelloCpp/proj.linux #check_make_result diff --git a/samples/TestCpp/proj.linux/Makefile b/samples/TestCpp/proj.linux/Makefile index 67cdce1d3a..42ffefbb3b 100644 --- a/samples/TestCpp/proj.linux/Makefile +++ b/samples/TestCpp/proj.linux/Makefile @@ -1,8 +1,8 @@ CC = gcc CXX = g++ TARGET = TestCpp -CCFLAGS = -Wall -g #-O2 -CXXFLAGS = -Wall -g #-O2 +CCFLAGS = -Wall +CXXFLAGS = -Wall VISIBILITY = LIBS = @@ -120,7 +120,7 @@ OBJECTS = ../Classes/AccelerometerTest/AccelerometerTest.o \ ../Classes/AppDelegate.o \ ./main.o - + LBITS := $(shell getconf LONG_BIT) ifeq ($(LBITS),64) STATICLIBS_DIR = ../../../cocos2dx/platform/third_party/linux/libraries/lib64 @@ -136,7 +136,6 @@ STATICLIBS = $(STATICLIBS_DIR)/libfreetype.a \ $(STATICLIBS_DIR)/libtiff.a \ ../../../lib/linux/Debug/libbox2d.a \ ../../../lib/linux/Debug/libchipmunk.a \ -# $(STATICLIBS_DIR)/libGLEW.a \ SHAREDLIBS = ifeq ($(LBITS),64) @@ -148,20 +147,36 @@ SHAREDLIBS = -L$(SHAREDLIBS_DIR) -lfmodex endif SHAREDLIBS += -lglfw -lGL -#SHAREDLIBS += -lGLEW -SHAREDLIBS += -L../../../lib/linux/Debug -lcocos2d -lrt -lz -lcocosdenshion -Wl,-rpath,../../../../lib/linux/Debug/ -SHAREDLIBS += -Wl,-rpath,../$(SHAREDLIBS_DIR) -SHAREDLIBS += -Wl,-rpath,../../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib +#SHAREDLIBS += -L../../../lib/linux/Debug -lcocos2d -lrt -lz -lcocosdenshion -Wl,-rpath,../../../../lib/linux/Debug/ +SHAREDLIBS += -Wl,-rpath,../../$(SHAREDLIBS_DIR) +#SHAREDLIBS += -Wl,-rpath,../../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib SHAREDLIBS += -L../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib -lGLEW +SHAREDLIBS += -Wl,-rpath,../../../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib + SHAREDLIBS += -Wl,-rpath,../$(STATICLIBS_DIR) SHAREDLIBS += -lcurl -BIN_DIR=bin +BIN_DIR_ROOT=bin +BIN_DIR = BIN_DIR_ROOT + +debug: SHAREDLIBS += -L../../../lib/linux/Debug -lcocos2d -lrt -lz -lcocosdenshion -Wl,-rpath,../../../../../lib/linux/Debug +debug: CCFLAGS += -g3 -O0 +debug: CXXFLAGS += -g3 -O0 +debug: DEFINES += -DDEBUG +debug: BIN_DIR = $(BIN_DIR_ROOT)/debug +debug: $(TARGET) + +release: SHAREDLIBS += -L../../../lib/linux/Release -lcocos2d -lrt -lz -lcocosdenshion -Wl,-rpath,../../../../../lib/linux/Release +release: CCFLAGS += -O3 +release: CXXFLAGS += -O3 +release: DEFINES += -DNDEBUG +release: BIN_DIR = $(BIN_DIR_ROOT)/release +release: $(TARGET) ####### Build rules $(TARGET): $(OBJECTS) - test -d $(BIN_DIR) || mkdir $(BIN_DIR) + mkdir -p $(BIN_DIR) $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(OBJECTS) -o $(BIN_DIR)/$(TARGET) $(SHAREDLIBS) $(STATICLIBS) $(LIBS) @@ -171,8 +186,7 @@ $(TARGET): $(OBJECTS) %.o: %.c $(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ - + clean: rm -f $(OBJECTS) $(TARGET) core - rm -r $(BIN_DIR) diff --git a/samples/TestCpp/proj.linux/main.cpp b/samples/TestCpp/proj.linux/main.cpp index f882a2cc66..71776a9eba 100644 --- a/samples/TestCpp/proj.linux/main.cpp +++ b/samples/TestCpp/proj.linux/main.cpp @@ -24,7 +24,7 @@ int main(int argc, char **argv) std::string resourcePath = fullpath; resourcePath = resourcePath.substr(0, resourcePath.find_last_of("/")); - resourcePath += "/../../Resources/"; + resourcePath += "/../../../Resources/"; // create the application instance AppDelegate app; From a83b6a6261319424db80c094a02c1d57c5c8c7d7 Mon Sep 17 00:00:00 2001 From: Byung Choi Date: Fri, 21 Sep 2012 15:35:41 +0900 Subject: [PATCH 089/181] updated sample/helloCpp debug & release makefile for linux --- make-all-linux-project.sh | 9 ++++--- samples/HelloCpp/proj.linux/Makefile | 36 +++++++++++++++++++--------- samples/HelloCpp/proj.linux/main.cpp | 2 +- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/make-all-linux-project.sh b/make-all-linux-project.sh index 166f472e92..fd421a442e 100755 --- a/make-all-linux-project.sh +++ b/make-all-linux-project.sh @@ -107,6 +107,9 @@ make -C $COCOS2DX20_TRUNK/samples/TestCpp/proj.linux clean make -C $COCOS2DX20_TRUNK/samples/TestCpp/proj.linux release check_make_result -#make -C $COCOS2DX20_TRUNK/samples/HelloCpp/proj.linux clean -#make -C $COCOS2DX20_TRUNK/samples/HelloCpp/proj.linux -#check_make_result +make -C $COCOS2DX20_TRUNK/samples/HelloCpp/proj.linux clean +make -C $COCOS2DX20_TRUNK/samples/HelloCpp/proj.linux debug +check_make_result +make -C $COCOS2DX20_TRUNK/samples/HelloCpp/proj.linux clean +make -C $COCOS2DX20_TRUNK/samples/HelloCpp/proj.linux release +check_make_result diff --git a/samples/HelloCpp/proj.linux/Makefile b/samples/HelloCpp/proj.linux/Makefile index 03df0db1f1..581d1700e3 100644 --- a/samples/HelloCpp/proj.linux/Makefile +++ b/samples/HelloCpp/proj.linux/Makefile @@ -1,8 +1,8 @@ CC = gcc CXX = g++ TARGET = HelloCpp -CCFLAGS = -Wall -g -O2 -CXXFLAGS = -Wall -g -O2 +CCFLAGS = -Wall +CXXFLAGS = -Wall VISIBILITY = COCOS2DX_PATH = ../../../cocos2dx @@ -41,28 +41,42 @@ STATICLIBS = $(STATICLIBS_DIR)/libfreetype.a \ $(STATICLIBS_DIR)/libtiff.a \ # $(STATICLIBS_DIR)/libGLEW.a \ - -SHAREDLIBS = -L../../../lib/linux/Debug -lcocos2d -lrt -lz -lcocosdenshion -Wl,-rpath,../../../../lib/linux/Debug/ -SHAREDLIBS += -lglfw -lcurl -SHAREDLIBS += -Wl,-rpath,../../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib +SHAREDLIBS = -lglfw -lcurl +SHAREDLIBS += -Wl,-rpath,../../../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib SHAREDLIBS += -L../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib -lGLEW #$(shell ../../build-linux.sh $<) -BIN_DIR=bin +BIN_DIR_ROOT=bin +BIN_DIR = $(BIN_DIR_ROOT) + +debug: BIN_DIR = $(BIN_DIR_ROOT)/debug +debug: CCFLAGS += -g3 -O0 +debug: CXXFLAGS += -g3 -O0 +debug: SHAREDLIBS += -L../../../lib/linux/Debug -lcocos2d -lrt -lz -lcocosdenshion +debug: SHAREDLIBS += -Wl,-rpath,../../../../../lib/linux/Debug/ +debug: DEFINES += -DDEBUG +debug: $(TARGET) + +release: BIN_DIR = $(BIN_DIR_ROOT)/release +release: CCFLAGS += -O3 +release: CXXFLAGS += -O3 +release: SHAREDLIBS += -L../../../lib/linux/Release -lcocos2d -lrt -lz -lcocosdenshion +release: SHAREDLIBS += -Wl,-rpath,../../../../../lib/linux/Release/ +release: DEFINES += -DNDEBUG +release: $(TARGET) ####### Build rules $(TARGET): $(OBJECTS) - test -d $(BIN_DIR) || mkdir $(BIN_DIR) + mkdir -p $(BIN_DIR) $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(OBJECTS) -o $(BIN_DIR)/$(TARGET) $(SHAREDLIBS) $(STATICLIBS) - + ####### Compile %.o: %.cpp $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ %.o: %.c $(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ - + clean: rm -f $(OBJECTS) $(TARGET) core - rm -r $(BIN_DIR) diff --git a/samples/HelloCpp/proj.linux/main.cpp b/samples/HelloCpp/proj.linux/main.cpp index f99af29189..74529cfc6d 100644 --- a/samples/HelloCpp/proj.linux/main.cpp +++ b/samples/HelloCpp/proj.linux/main.cpp @@ -24,7 +24,7 @@ int main(int argc, char **argv) std::string resourcePath = fullpath; resourcePath = resourcePath.substr(0, resourcePath.find_last_of("/")); - resourcePath += "/../../Resources/"; + resourcePath += "/../../../Resources/"; // create the application instance AppDelegate app; From 0a1f0369e610343d97a18986bbcbd0b050a5535d Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 21 Sep 2012 17:01:19 +0800 Subject: [PATCH 090/181] fixed #1481: merge Nicolas's pull request and do some bug fixes --- CocosDenshion/android/SimpleAudioEngine.cpp | 2 +- .../android/jni/SimpleAudioEngineJni.cpp | 2 +- .../org/cocos2dx/lib/Cocos2dxActivity.java | 65 ++- .../src/org/cocos2dx/lib/Cocos2dxHandler.java | 135 ++++++ .../src/org/cocos2dx/lib/Cocos2dxHelper.java | 8 +- .../Java_org_cocos2dx_lib_Cocos2dxBitmap.h | 41 +- .../Java_org_cocos2dx_lib_Cocos2dxHelper.cpp | 26 +- cocos2dx/platform/android/jni/JniHelper.cpp | 12 - cocos2dx/platform/android/jni/JniHelper.h | 4 - extensions/CCBReader/CCBReader.cpp | 3 + extensions/CCBReader/CCBReader.h | 2 +- extensions/CCBReader/CCData.h | 2 +- .../GUI/CCEditBox/CCEditBoxImplAndroid.cpp | 5 +- samples/HelloCpp/proj.android/.classpath | 17 +- .../HelloCpp/proj.android/project.properties | 1 + .../src/org/cocos2dx/hellocpp/HelloCpp.java | 73 +-- samples/HelloLua/proj.android/.classpath | 17 +- samples/HelloLua/proj.android/.project | 73 ++- .../src/org/cocos2dx/hellolua/HelloLua.java | 76 +-- .../proj.android/project.properties | 1 + .../cocos2dx/lib/Cocos2dxAccelerometer.java | 107 ---- .../org/cocos2dx/lib/Cocos2dxActivity.java | 346 ------------- .../src/org/cocos2dx/lib/Cocos2dxBitmap.java | 455 ------------------ .../cocos2dx/lib/Cocos2dxEditBoxDialog.java | 338 ------------- .../org/cocos2dx/lib/Cocos2dxEditText.java | 65 --- .../cocos2dx/lib/Cocos2dxGLSurfaceView.java | 417 ---------------- .../src/org/cocos2dx/lib/Cocos2dxMusic.java | 228 --------- .../org/cocos2dx/lib/Cocos2dxRenderer.java | 137 ------ .../src/org/cocos2dx/lib/Cocos2dxSound.java | 245 ---------- .../org/cocos2dx/simplegame/SimpleGame.java | 75 +-- samples/TestCpp/proj.android/.classpath | 17 +- samples/TestCpp/proj.android/.project | 73 ++- .../src/org/cocos2dx/testcpp/TestCpp.java | 77 +-- .../TestJavascript/proj.android/.classpath | 17 +- .../testjavascript/TestJavascript.java | 75 +-- samples/TestLua/proj.android/.classpath | 1 - .../src/org/cocos2dx/testlua/TestLua.java | 79 +-- 37 files changed, 365 insertions(+), 2952 deletions(-) create mode 100644 cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHandler.java rename samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxTypefaces.java => cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.h (61%) delete mode 100644 samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java delete mode 100644 samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java delete mode 100644 samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java delete mode 100755 samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java delete mode 100644 samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxEditText.java delete mode 100644 samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java delete mode 100644 samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxMusic.java delete mode 100644 samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxRenderer.java delete mode 100644 samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java diff --git a/CocosDenshion/android/SimpleAudioEngine.cpp b/CocosDenshion/android/SimpleAudioEngine.cpp index 7099dc6bd3..91d6bbfa5d 100644 --- a/CocosDenshion/android/SimpleAudioEngine.cpp +++ b/CocosDenshion/android/SimpleAudioEngine.cpp @@ -40,7 +40,7 @@ static bool s_bI9100 = false; /********************************************************************************** * jni **********************************************************************************/ -#define CLASS_NAME "org/cocos2dx/lib/Cocos2dxActivity" +#define CLASS_NAME "org/cocos2dx/lib/Cocos2dxHelper" #define METHOD_NAME "getDeviceModel" typedef struct JniMethodInfo_ diff --git a/CocosDenshion/android/jni/SimpleAudioEngineJni.cpp b/CocosDenshion/android/jni/SimpleAudioEngineJni.cpp index ec588f8087..829b911896 100644 --- a/CocosDenshion/android/jni/SimpleAudioEngineJni.cpp +++ b/CocosDenshion/android/jni/SimpleAudioEngineJni.cpp @@ -5,7 +5,7 @@ #define LOG_TAG "libSimpleAudioEngine" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) -#define CLASS_NAME "org/cocos2dx/lib/Cocos2dxActivity" +#define CLASS_NAME "org/cocos2dx/lib/Cocos2dxHelper" typedef struct JniMethodInfo_ { diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java index 3722781190..247fb78575 100644 --- a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java @@ -28,6 +28,9 @@ import org.cocos2dx.lib.Cocos2dxHelper.Cocos2dxHelperListener; import android.app.Activity; import android.app.AlertDialog; import android.os.Bundle; +import android.os.Message; +import android.view.ViewGroup; +import android.widget.FrameLayout; public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelperListener { // =========================================================== @@ -39,6 +42,9 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe // =========================================================== // Fields // =========================================================== + + private Cocos2dxGLSurfaceView mGLSurefaceView; + private Cocos2dxHandler mHandler; // =========================================================== // Constructors @@ -47,6 +53,8 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); + + this.init(); Cocos2dxHelper.init(this, this); } @@ -64,6 +72,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe super.onResume(); Cocos2dxHelper.onResume(); + this.mGLSurefaceView.onResume(); } @Override @@ -71,21 +80,71 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe super.onPause(); Cocos2dxHelper.onPause(); + this.mGLSurefaceView.onPause(); } @Override public void showDialog(final String pTitle, final String pMessage) { - new AlertDialog.Builder(this).setTitle(pTitle).setMessage(pMessage).setPositiveButton("OK", null).create().show(); // TODO Dialog will not survive configuration changes + Message msg = new Message(); + msg.what = Cocos2dxHandler.HANDLER_SHOW_DIALOG; + msg.obj = new Cocos2dxHandler.DialogMessage(pTitle, pMessage); + this.mHandler.sendMessage(msg); } @Override - public void showEditTextDialog(final String pTitle, final String pContent, final int pInputMode, final int pInputFlag, final int pReturnType, final int pMaxLength) { // TODO Dialog will not survive configuration changes - new Cocos2dxEditBoxDialog(this, pTitle, pContent, pInputMode, pInputFlag, pReturnType, pMaxLength).show(); + public void showEditTextDialog(final String pTitle, final String pContent, final int pInputMode, final int pInputFlag, final int pReturnType, final int pMaxLength) { + Message msg = new Message(); + msg.what = Cocos2dxHandler.HANDLER_SHOW_EDITBOX_DIALOG; + msg.obj = new Cocos2dxHandler.EditBoxMessage(pTitle, pContent, pInputMode, pInputFlag, pReturnType, pMaxLength); + this.mHandler.sendMessage(msg); + } + + @Override + public void runOnGLThread(final Runnable pRunnable) { + this.mGLSurefaceView.queueEvent(pRunnable); } // =========================================================== // Methods // =========================================================== + + public void init() { + // Init handler + this.mHandler = new Cocos2dxHandler(this); + + // FrameLayout + ViewGroup.LayoutParams framelayout_params = + new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.FILL_PARENT); + FrameLayout framelayout = new FrameLayout(this); + framelayout.setLayoutParams(framelayout_params); + + // Cocos2dxEditText layout + ViewGroup.LayoutParams edittext_layout_params = + new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT); + Cocos2dxEditText edittext = new Cocos2dxEditText(this); + edittext.setLayoutParams(edittext_layout_params); + + // ...add to FrameLayout + framelayout.addView(edittext); + + // Cocos2dxGLSurfaceView + this.mGLSurefaceView = this.onCreateGLSurfaceView(); + + // ...add to FrameLayout + framelayout.addView(mGLSurefaceView); + + mGLSurefaceView.setCocos2dxRenderer(new Cocos2dxRenderer()); + mGLSurefaceView.setCocos2dxEditText(edittext); + + // Set framelayout as the content view + setContentView(framelayout); + } + + public Cocos2dxGLSurfaceView onCreateGLSurfaceView() { + return new Cocos2dxGLSurfaceView(this); + } // =========================================================== // Inner and Anonymous Classes diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHandler.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHandler.java new file mode 100644 index 0000000000..47639afc5e --- /dev/null +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHandler.java @@ -0,0 +1,135 @@ +/**************************************************************************** +Copyright (c) 2010-2011 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + ****************************************************************************/ + +package org.cocos2dx.lib; + +import java.lang.ref.WeakReference; + +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.os.Handler; +import android.os.Message; + +public class Cocos2dxHandler extends Handler { + // =========================================================== + // Constants + // =========================================================== + public final static int HANDLER_SHOW_DIALOG = 1; + public final static int HANDLER_SHOW_EDITBOX_DIALOG = 2; + + // =========================================================== + // Fields + // =========================================================== + private WeakReference mActivity; + + // =========================================================== + // Constructors + // =========================================================== + public Cocos2dxHandler(Cocos2dxActivity activity) { + this.mActivity = new WeakReference(activity); + } + + // =========================================================== + // Getter & Setter + // =========================================================== + + // =========================================================== + // Methods for/from SuperClass/Interfaces + // =========================================================== + + // =========================================================== + // Methods + // =========================================================== + + public void handleMessage(Message msg) { + switch (msg.what) { + case Cocos2dxHandler.HANDLER_SHOW_DIALOG: + showDialog(msg); + break; + case Cocos2dxHandler.HANDLER_SHOW_EDITBOX_DIALOG: + showEditBoxDialog(msg); + break; + } + } + + private void showDialog(Message msg) { + Cocos2dxActivity theActivity = this.mActivity.get(); + DialogMessage dialogMessage = (DialogMessage)msg.obj; + new AlertDialog.Builder(theActivity) + .setTitle(dialogMessage.titile) + .setMessage(dialogMessage.message) + .setPositiveButton("Ok", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + // TODO Auto-generated method stub + + } + }).create().show(); + } + + private void showEditBoxDialog(Message msg) { + EditBoxMessage editBoxMessage = (EditBoxMessage)msg.obj; + new Cocos2dxEditBoxDialog(this.mActivity.get(), + editBoxMessage.title, + editBoxMessage.content, + editBoxMessage.inputMode, + editBoxMessage.inputFlag, + editBoxMessage.returnType, + editBoxMessage.maxLength).show(); + } + + // =========================================================== + // Inner and Anonymous Classes + // =========================================================== + + public static class DialogMessage { + public String titile; + public String message; + + public DialogMessage(String title, String message) { + this.titile = title; + this.message = message; + } + } + + public static class EditBoxMessage { + public String title; + public String content; + public int inputMode; + public int inputFlag; + public int returnType; + public int maxLength; + + public EditBoxMessage(String title, String content, int inputMode, int inputFlag, int returnType, int maxLength){ + this.content = content; + this.title = title; + this.inputMode = inputMode; + this.inputFlag = inputFlag; + this.returnType = returnType; + this.maxLength = maxLength; + } + } +} diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java index 3b9285d70e..b3cd8dbf82 100644 --- a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java @@ -29,6 +29,7 @@ import java.util.Locale; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.res.AssetManager; +import android.os.Build; import android.os.Environment; public class Cocos2dxHelper { @@ -61,7 +62,6 @@ public class Cocos2dxHelper { Cocos2dxHelper.sPackageName = applicationInfo.packageName; Cocos2dxHelper.nativeSetApkPath(applicationInfo.sourceDir); Cocos2dxHelper.nativeSetExternalAssetPath(Cocos2dxHelper.getAbsolutePathOnExternalStorage(applicationInfo, "assets/")); - Cocos2dxHelper.nativeSetAssetManager(pContext.getAssets()); Cocos2dxHelper.sCocos2dxAccelerometer = new Cocos2dxAccelerometer(pContext); Cocos2dxHelper.sCocos2dMusic = new Cocos2dxMusic(pContext); @@ -86,8 +86,6 @@ public class Cocos2dxHelper { private static native void nativeSetExternalAssetPath(final String pExternalAssetPath); - private static native void nativeSetAssetManager(final AssetManager pAssetManager); - private static native void nativeSetEditTextDialogResult(final byte[] pBytes); public static String getCocos2dxPackageName() { @@ -97,6 +95,10 @@ public class Cocos2dxHelper { public static String getCurrentLanguage() { return Locale.getDefault().getLanguage(); } + + public static String getDeviceModel(){ + return Build.MODEL; + } public static AssetManager getAssetManager() { return Cocos2dxHelper.sAssetManager; diff --git a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxTypefaces.java b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.h similarity index 61% rename from samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxTypefaces.java rename to cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.h index 79af1ed3af..38b3811809 100644 --- a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxTypefaces.java +++ b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2012 cocos2d-x.org http://www.cocos2d-x.org @@ -21,24 +21,27 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -package org.cocos2dx.lib; +#ifndef __EDITBOX_JNI_H__ +#define __EDITBOX_JNI_H__ -import java.util.Hashtable; +#include -import android.content.Context; -import android.graphics.Typeface; +typedef void (*EditBoxCallback)(const char* pText, void* ctx); -public class Cocos2dxTypefaces { - private static final Hashtable cache = new Hashtable(); - - public static Typeface get(Context context, String name){ - synchronized(cache){ - if (! cache.containsKey(name)){ - Typeface t = Typeface.createFromAsset(context.getAssets(), name); - cache.put(name, t); - } - - return cache.get(name); - } - } -} +extern "C" +{ +void showEditBoxDialogJni(const char* pszTitle, + const char* pszContent, + int nInputMode, + int nInputFlag, + int nReturnType, + int nMaxLength, + EditBoxCallback pfEditBoxCB, + void* ctx); + +int getFontSizeAccordingHeightJni(int height); +std::string getStringWithEllipsisJni(const char* pszText, float width, float fontSize); + +} // end of extern "C" + +#endif // __EDITBOX_JNI_H__ diff --git a/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp index 49cf84c6b5..2e2216fe87 100644 --- a/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp +++ b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp @@ -1,8 +1,7 @@ #include #include #include -#include -#include +#include #include "JniHelper.h" #include "cocoa/CCString.h" #include "Java_org_cocos2dx_lib_Cocos2dxHelper.h" @@ -17,29 +16,20 @@ static EditTextCallback s_pfEditTextCallback = NULL; static void* s_ctx = NULL; using namespace cocos2d; +using namespace std; extern "C" { - const char * g_pApkPath; + string g_apkPath; - JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetApkPath(JNIEnv* env, jobject thiz, jstring apkPath) { - g_pApkPath = env->GetStringUTFChars(apkPath, NULL); + void Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetApkPath(JNIEnv* env, jobject thiz, jstring apkPath) { + g_apkPath = JniHelper::jstring2string(apkPath); } const char * getApkPath() { - return g_pApkPath; + return g_apkPath.c_str(); } - JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetAssetManager(JNIEnv* env, jobject thiz, jobject java_assetmanager) { - AAssetManager* assetmanager = AAssetManager_fromJava(env, java_assetmanager); - if (assetmanager == NULL) { - LOGD("ERROR: assetmanager == NULL"); - return; - } - - cocos2d::JniHelper::setAssetManager(assetmanager); - } - - JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetExternalAssetPath(JNIEnv* env, jobject thiz, jstring externalAssetPath) { + void Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetExternalAssetPath(JNIEnv* env, jobject thiz, jstring externalAssetPath) { const char* externalAssetPathChars = env->GetStringUTFChars(externalAssetPath, NULL); cocos2d::JniHelper::setExternalAssetPath(externalAssetPathChars); env->ReleaseStringUTFChars(externalAssetPath, externalAssetPathChars); @@ -97,7 +87,7 @@ extern "C" { } } - JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetEditTextDialogResult(JNIEnv * env, jobject obj, jbyteArray text) { + void Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetEditTextDialogResult(JNIEnv * env, jobject obj, jbyteArray text) { jsize size = env->GetArrayLength(text); if (size > 0) { diff --git a/cocos2dx/platform/android/jni/JniHelper.cpp b/cocos2dx/platform/android/jni/JniHelper.cpp index a2ed3c7f99..8b66082b5f 100644 --- a/cocos2dx/platform/android/jni/JniHelper.cpp +++ b/cocos2dx/platform/android/jni/JniHelper.cpp @@ -23,8 +23,6 @@ THE SOFTWARE. ****************************************************************************/ #include "JniHelper.h" #include -#include -#include #include #if 1 @@ -195,16 +193,6 @@ void JniHelper::setJavaVM(JavaVM *javaVM) m_psJavaVM = javaVM; } -AAssetManager* JniHelper::m_assetmanager = NULL; - -AAssetManager* JniHelper::getAssetManager() { - return m_assetmanager; -} - -void JniHelper::setAssetManager(AAssetManager* am) { - m_assetmanager = am; -} - string JniHelper::m_externalAssetPath; const char* JniHelper::getExternalAssetPath() { diff --git a/cocos2dx/platform/android/jni/JniHelper.h b/cocos2dx/platform/android/jni/JniHelper.h index f5c7e63020..56e3d0670d 100644 --- a/cocos2dx/platform/android/jni/JniHelper.h +++ b/cocos2dx/platform/android/jni/JniHelper.h @@ -27,7 +27,6 @@ THE SOFTWARE. #include #include #include "platform/CCPlatformMacros.h" -#include NS_CC_BEGIN @@ -43,8 +42,6 @@ class CC_DLL JniHelper public: static JavaVM* getJavaVM(); static void setJavaVM(JavaVM *javaVM); - static AAssetManager* getAssetManager(); - static void setAssetManager(AAssetManager* am); static const char* getExternalAssetPath(); static void setExternalAssetPath(const char* externalAssetPath); static jclass getClassID(const char *className, JNIEnv *env=0); @@ -54,7 +51,6 @@ public: private: static JavaVM *m_psJavaVM; - static AAssetManager *m_assetmanager; static std::string m_externalAssetPath; }; diff --git a/extensions/CCBReader/CCBReader.cpp b/extensions/CCBReader/CCBReader.cpp index f4718a4731..814952232c 100644 --- a/extensions/CCBReader/CCBReader.cpp +++ b/extensions/CCBReader/CCBReader.cpp @@ -65,6 +65,7 @@ CCBReader::CCBReader(CCNodeLoaderLibrary * pCCNodeLoaderLibrary, CCBMemberVariab , mOwner(NULL) , mActionManager(NULL) , mAnimatedProps(NULL) +, hasScriptingOwner(false) { this->mCCNodeLoaderLibrary = pCCNodeLoaderLibrary; this->mCCNodeLoaderLibrary->retain(); @@ -81,6 +82,7 @@ CCBReader::CCBReader(CCBReader * pCCBReader) , mOwner(NULL) , mActionManager(NULL) , mAnimatedProps(NULL) +, hasScriptingOwner(false) { this->mLoadedSpriteSheets = pCCBReader->mLoadedSpriteSheets; this->mCCNodeLoaderLibrary = pCCBReader->mCCNodeLoaderLibrary; @@ -103,6 +105,7 @@ CCBReader::CCBReader() , mCCBMemberVariableAssigner(NULL) , mCCBSelectorResolver(NULL) , mAnimatedProps(NULL) +, hasScriptingOwner(false) {} CCBReader::~CCBReader() { diff --git a/extensions/CCBReader/CCBReader.h b/extensions/CCBReader/CCBReader.h index 459fe23416..091f2a1007 100644 --- a/extensions/CCBReader/CCBReader.h +++ b/extensions/CCBReader/CCBReader.h @@ -235,7 +235,7 @@ public: static float getResolutionScale(); CCNode* readFileWithCleanUp(bool bCleanUp); - bool hasScriptingOwner = false; + bool hasScriptingOwner; private: void cleanUpNodeGraph(CCNode *pNode); diff --git a/extensions/CCBReader/CCData.h b/extensions/CCBReader/CCData.h index 127b6a69c0..5861339ab5 100644 --- a/extensions/CCBReader/CCData.h +++ b/extensions/CCBReader/CCData.h @@ -3,7 +3,7 @@ #define __CCB_CCDATA_H__ #include "cocos2d.h" -#include "ExtensionMacros.h"" +#include "ExtensionMacros.h" NS_CC_EXT_BEGIN diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp b/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp index a43d55a89e..2be8035381 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp +++ b/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp @@ -25,7 +25,8 @@ #include "CCEditBoxImplAndroid.h" #include "CCEditBox.h" -#include "jni/EditBoxJni.h" +#include "jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.h" +#include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" // This function is implemented in CCLabelBMFont.cpp @@ -217,7 +218,7 @@ void CCEditBoxImplAndroid::openKeyboard() m_pDelegate->editBoxEditingDidBegin(m_pEditBox); } - showEditBoxDialogJni( m_strPlaceHolder.c_str(), + showEditTextDialogJNI( m_strPlaceHolder.c_str(), m_strText.c_str(), m_eEditBoxInputMode, m_eEditBoxInputFlag, diff --git a/samples/HelloCpp/proj.android/.classpath b/samples/HelloCpp/proj.android/.classpath index 58d9761beb..fb4778902b 100644 --- a/samples/HelloCpp/proj.android/.classpath +++ b/samples/HelloCpp/proj.android/.classpath @@ -1,9 +1,8 @@ - - - - - - - - - + + + + + + + + diff --git a/samples/HelloCpp/proj.android/project.properties b/samples/HelloCpp/proj.android/project.properties index d5f90ebab1..95f1525b45 100644 --- a/samples/HelloCpp/proj.android/project.properties +++ b/samples/HelloCpp/proj.android/project.properties @@ -11,3 +11,4 @@ target=android-8 android.library.reference.1=../../../cocos2dx/platform/android/java +android.library=false diff --git a/samples/HelloCpp/proj.android/src/org/cocos2dx/hellocpp/HelloCpp.java b/samples/HelloCpp/proj.android/src/org/cocos2dx/hellocpp/HelloCpp.java index e283af1ad8..327d55fe96 100644 --- a/samples/HelloCpp/proj.android/src/org/cocos2dx/hellocpp/HelloCpp.java +++ b/samples/HelloCpp/proj.android/src/org/cocos2dx/hellocpp/HelloCpp.java @@ -24,85 +24,16 @@ THE SOFTWARE. package org.cocos2dx.hellocpp; import org.cocos2dx.lib.Cocos2dxActivity; -import org.cocos2dx.lib.Cocos2dxEditText; -import org.cocos2dx.lib.Cocos2dxGLSurfaceView; -import org.cocos2dx.lib.Cocos2dxRenderer; -import android.app.ActivityManager; -import android.content.Context; -import android.content.pm.ConfigurationInfo; import android.os.Bundle; -import android.util.Log; -import android.widget.FrameLayout; -import android.view.ViewGroup; public class HelloCpp extends Cocos2dxActivity{ protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); - - if (detectOpenGLES20()) { - // get the packageName,it's used to set the resource path - String packageName = getApplication().getPackageName(); - super.setPackageName(packageName); - - // FrameLayout - ViewGroup.LayoutParams framelayout_params = - new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT); - FrameLayout framelayout = new FrameLayout(this); - framelayout.setLayoutParams(framelayout_params); - - // Cocos2dxEditText layout - ViewGroup.LayoutParams edittext_layout_params = - new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT); - Cocos2dxEditText edittext = new Cocos2dxEditText(this); - edittext.setLayoutParams(edittext_layout_params); - - // ...add to FrameLayout - framelayout.addView(edittext); - - // Cocos2dxGLSurfaceView - mGLView = new Cocos2dxGLSurfaceView(this); - - // ...add to FrameLayout - framelayout.addView(mGLView); - - mGLView.setEGLContextClientVersion(2); - mGLView.setCocos2dxRenderer(new Cocos2dxRenderer()); - mGLView.setTextField(edittext); - - // Set framelayout as the content view - setContentView(framelayout); - } - else { - Log.d("activity", "don't support gles2.0"); - finish(); - } } - @Override - protected void onPause() { - super.onPause(); - mGLView.onPause(); - } - - @Override - protected void onResume() { - super.onResume(); - mGLView.onResume(); - } - - private boolean detectOpenGLES20() - { - ActivityManager am = - (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); - ConfigurationInfo info = am.getDeviceConfigurationInfo(); - return (info.reqGlEsVersion >= 0x20000); - } - - static { + static { System.loadLibrary("hellocpp"); - } + } } diff --git a/samples/HelloLua/proj.android/.classpath b/samples/HelloLua/proj.android/.classpath index dc00167933..a4763d1eec 100644 --- a/samples/HelloLua/proj.android/.classpath +++ b/samples/HelloLua/proj.android/.classpath @@ -1,9 +1,8 @@ - - - - - - - - - + + + + + + + + diff --git a/samples/HelloLua/proj.android/.project b/samples/HelloLua/proj.android/.project index 5cb6cc5308..046823a87b 100644 --- a/samples/HelloLua/proj.android/.project +++ b/samples/HelloLua/proj.android/.project @@ -1,40 +1,33 @@ - - - HelloLua - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - - - src_common - 2 - PARENT-3-PROJECT_LOC/cocos2dx/platform/android/java/src_common - - - + + + HelloLua + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/samples/HelloLua/proj.android/src/org/cocos2dx/hellolua/HelloLua.java b/samples/HelloLua/proj.android/src/org/cocos2dx/hellolua/HelloLua.java index 1f44f9aba8..03a60433ac 100644 --- a/samples/HelloLua/proj.android/src/org/cocos2dx/hellolua/HelloLua.java +++ b/samples/HelloLua/proj.android/src/org/cocos2dx/hellolua/HelloLua.java @@ -23,88 +23,24 @@ THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.hellolua; import org.cocos2dx.lib.Cocos2dxActivity; -import org.cocos2dx.lib.Cocos2dxEditText; import org.cocos2dx.lib.Cocos2dxGLSurfaceView; -import org.cocos2dx.lib.Cocos2dxRenderer; -import android.app.ActivityManager; import android.content.Context; -import android.content.pm.ConfigurationInfo; import android.os.Bundle; -import android.util.Log; import android.view.KeyEvent; -import android.widget.FrameLayout; -import android.view.ViewGroup; public class HelloLua extends Cocos2dxActivity{ protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); - - if (detectOpenGLES20()) { - // get the packageName,it's used to set the resource path - String packageName = getApplication().getPackageName(); - super.setPackageName(packageName); - - // FrameLayout - ViewGroup.LayoutParams framelayout_params = - new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT); - FrameLayout framelayout = new FrameLayout(this); - framelayout.setLayoutParams(framelayout_params); - - // Cocos2dxEditText layout - ViewGroup.LayoutParams edittext_layout_params = - new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT); - Cocos2dxEditText edittext = new Cocos2dxEditText(this); - edittext.setLayoutParams(edittext_layout_params); - - // ...add to FrameLayout - framelayout.addView(edittext); - - // LuaGLSurfaceView - mGLView = new LuaGLSurfaceView(this); - - // ...add to FrameLayout - framelayout.addView(mGLView); - - mGLView.setEGLContextClientVersion(2); - mGLView.setCocos2dxRenderer(new Cocos2dxRenderer()); - mGLView.setTextField(edittext); - - // Set framelayout as the content view - setContentView(framelayout); - } - else { - Log.d("activity", "don't support gles2.0"); - finish(); - } } - @Override - protected void onPause() { - super.onPause(); - mGLView.onPause(); - } - - @Override - protected void onResume() { - super.onResume(); - mGLView.onResume(); - } - - private boolean detectOpenGLES20() - { - ActivityManager am = - (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); - ConfigurationInfo info = am.getDeviceConfigurationInfo(); - return (info.reqGlEsVersion >= 0x20000); - } - + public Cocos2dxGLSurfaceView onCreateGLSurfaceView() { + return new LuaGLSurfaceView(this); + } - static { - System.loadLibrary("hellolua"); - } + static { + System.loadLibrary("hellolua"); + } } class LuaGLSurfaceView extends Cocos2dxGLSurfaceView{ diff --git a/samples/SimpleGame/proj.android/project.properties b/samples/SimpleGame/proj.android/project.properties index 85aac54016..bd396e9f60 100644 --- a/samples/SimpleGame/proj.android/project.properties +++ b/samples/SimpleGame/proj.android/project.properties @@ -12,3 +12,4 @@ # Project target. target=android-8 +android.library.reference.1=../../../cocos2dx/platform/android/java diff --git a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java b/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java deleted file mode 100644 index c515349cab..0000000000 --- a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import android.content.Context; -import android.content.res.Configuration; -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; -import android.view.Display; -import android.view.Surface; -import android.view.WindowManager; - -/** - * - * This class is used for controlling the Accelerometer - * - */ -public class Cocos2dxAccelerometer implements SensorEventListener { - - private static final String TAG = "Cocos2dxAccelerometer"; - private Context mContext; - private SensorManager mSensorManager; - private Sensor mAccelerometer; - private int mNaturalOrientation; - - public Cocos2dxAccelerometer(Context context){ - mContext = context; - - //Get an instance of the SensorManager - mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE); - mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); - - Display display = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); - mNaturalOrientation = display.getOrientation(); - } - - public void enable() { - mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME); - } - - public void disable () { - mSensorManager.unregisterListener(this); - } - - @Override - public void onSensorChanged(SensorEvent event) { - - if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER){ - return; - } - - float x = event.values[0]; - float y = event.values[1]; - float z = event.values[2]; - - /* - * Because the axes are not swapped when the device's screen orientation changes. - * So we should swap it here. - * In tablets such as Motorola Xoom, the default orientation is landscape, so should - * consider this. - */ - int orientation = mContext.getResources().getConfiguration().orientation; - if ((orientation == Configuration.ORIENTATION_LANDSCAPE) && (mNaturalOrientation != Surface.ROTATION_0)){ - float tmp = x; - x = -y; - y = tmp; - } - else if ((orientation == Configuration.ORIENTATION_PORTRAIT) && (mNaturalOrientation != Surface.ROTATION_0)) - { - float tmp = x; - x = y; - y = -tmp; - } - - onSensorChanged(x, y, z, event.timestamp); - // Log.d(TAG, "x = " + event.values[0] + " y = " + event.values[1] + " z = " + event.values[2]); - } - - @Override - public void onAccuracyChanged(Sensor sensor, int accuracy) { - } - - private static native void onSensorChanged(float x, float y, float z, long timeStamp); -} diff --git a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java b/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java deleted file mode 100644 index 952d5148fb..0000000000 --- a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java +++ /dev/null @@ -1,346 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -package org.cocos2dx.lib; - -import java.lang.ref.WeakReference; - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.Dialog; -import android.content.DialogInterface; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.content.res.AssetManager; -import android.os.Build; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.util.DisplayMetrics; -import android.util.Log; - -public class Cocos2dxActivity extends Activity{ - - protected Cocos2dxGLSurfaceView mGLView; - private static Cocos2dxMusic backgroundMusicPlayer; - private static Cocos2dxSound soundPlayer; - private static Cocos2dxAccelerometer accelerometer; - private static AssetManager assetManager; - private static boolean accelerometerEnabled = false; - private static Handler handler; - private final static int HANDLER_SHOW_DIALOG = 1; - private final static int HANDLER_SHOW_EDITBOX_DIALOG = 2; - - private static String packageName; - - private static native void nativeSetPaths(String apkPath); - private static native void nativeSetEditboxText(byte[] text); - - - static class ShowDialogHandler extends Handler { - WeakReference mActivity; - - ShowDialogHandler(Cocos2dxActivity activity) { - mActivity = new WeakReference(activity); - } - - @Override - public void handleMessage(Message msg) { - Cocos2dxActivity theActivity = mActivity.get(); - switch(msg.what) { - case HANDLER_SHOW_DIALOG: - theActivity.showDialog(((DialogMessage)msg.obj).title, ((DialogMessage)msg.obj).message); - break; - case HANDLER_SHOW_EDITBOX_DIALOG: - theActivity.onShowEditBoxDialog((EditBoxMessage)msg.obj); - break; - } - } - }; - - public Cocos2dxGLSurfaceView getGLView() { - return mGLView; - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // get frame size - DisplayMetrics dm = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(dm); - accelerometer = new Cocos2dxAccelerometer(this); - - // init media player and sound player - backgroundMusicPlayer = new Cocos2dxMusic(this); - soundPlayer = new Cocos2dxSound(this); - - // init asset manager for jni call - assetManager = getAssets(); - - // init bitmap context - Cocos2dxBitmap.setContext(this); - - handler = new ShowDialogHandler(this); - } - - public static String getDeviceModel(){ - return Build.MODEL; - } - - public static AssetManager getAssetManager() { - return assetManager; - } - - public static String getCurrentLanguage() { - String languageName = java.util.Locale.getDefault().getLanguage(); - return languageName; - } - - public static void showMessageBox(String title, String message){ - Message msg = new Message(); - msg.what = HANDLER_SHOW_DIALOG; - msg.obj = new DialogMessage(title, message); - - handler.sendMessage(msg); - } - - public static void enableAccelerometer() { - accelerometerEnabled = true; - accelerometer.enable(); - } - - public static void disableAccelerometer() { - accelerometerEnabled = false; - accelerometer.disable(); - } - - public static void preloadBackgroundMusic(String path){ - backgroundMusicPlayer.preloadBackgroundMusic(path); - } - - public static void playBackgroundMusic(String path, boolean isLoop){ - backgroundMusicPlayer.playBackgroundMusic(path, isLoop); - } - - public static void stopBackgroundMusic(){ - backgroundMusicPlayer.stopBackgroundMusic(); - } - - public static void pauseBackgroundMusic(){ - backgroundMusicPlayer.pauseBackgroundMusic(); - } - - public static void resumeBackgroundMusic(){ - backgroundMusicPlayer.resumeBackgroundMusic(); - } - - public static void rewindBackgroundMusic(){ - backgroundMusicPlayer.rewindBackgroundMusic(); - } - - public static boolean isBackgroundMusicPlaying(){ - return backgroundMusicPlayer.isBackgroundMusicPlaying(); - } - - public static float getBackgroundMusicVolume(){ - return backgroundMusicPlayer.getBackgroundVolume(); - } - - public static void setBackgroundMusicVolume(float volume){ - backgroundMusicPlayer.setBackgroundVolume(volume); - } - - public static int playEffect(String path, boolean isLoop){ - return soundPlayer.playEffect(path, isLoop); - } - - public static void stopEffect(int soundId){ - soundPlayer.stopEffect(soundId); - } - - public static void pauseEffect(int soundId){ - soundPlayer.pauseEffect(soundId); - } - - public static void resumeEffect(int soundId){ - soundPlayer.resumeEffect(soundId); - } - - public static float getEffectsVolume(){ - return soundPlayer.getEffectsVolume(); - } - - public static void setEffectsVolume(float volume){ - soundPlayer.setEffectsVolume(volume); - } - - public static void preloadEffect(String path){ - soundPlayer.preloadEffect(path); - } - - public static void unloadEffect(String path){ - soundPlayer.unloadEffect(path); - } - - public static void stopAllEffects(){ - soundPlayer.stopAllEffects(); - } - - public static void pauseAllEffects(){ - soundPlayer.pauseAllEffects(); - } - - public static void resumeAllEffects(){ - soundPlayer.resumeAllEffects(); - } - - public static void end(){ - backgroundMusicPlayer.end(); - soundPlayer.end(); - } - - public static String getCocos2dxPackageName(){ - return packageName; - } - - public static void terminateProcess(){ - android.os.Process.killProcess(android.os.Process.myPid()); - } - - @Override - protected void onResume() { - super.onResume(); - if (accelerometerEnabled) { - accelerometer.enable(); - } - } - - @Override - protected void onPause() { - super.onPause(); - if (accelerometerEnabled) { - accelerometer.disable(); - } - } - - protected void setPackageName(String packageName) { - Cocos2dxActivity.packageName = packageName; - - String apkFilePath = ""; - ApplicationInfo appInfo = null; - PackageManager packMgmr = getApplication().getPackageManager(); - try { - appInfo = packMgmr.getApplicationInfo(packageName, 0); - } catch (NameNotFoundException e) { - e.printStackTrace(); - throw new RuntimeException("Unable to locate assets, aborting..."); - } - apkFilePath = appInfo.sourceDir; - Log.w("apk path", apkFilePath); - - // add this link at the renderer class - nativeSetPaths(apkFilePath); - } - - private void showDialog(String title, String message){ - Dialog dialog = new AlertDialog.Builder(this) - .setTitle(title) - .setMessage(message) - .setPositiveButton("Ok", - new DialogInterface.OnClickListener() - { - public void onClick(DialogInterface dialog, int whichButton){ - - } - }).create(); - - dialog.show(); - } - - private static void showEditBoxDialog(String title, String content, int inputMode, int inputFlag, int returnType, int maxLength) - { - Message msg = new Message(); - msg.what = HANDLER_SHOW_EDITBOX_DIALOG; - msg.obj = new EditBoxMessage(title, content, inputMode, inputFlag, returnType, maxLength); - handler.sendMessage(msg); - } - - private void onShowEditBoxDialog(EditBoxMessage msg) - { - Dialog dialog = new Cocos2dxEditBoxDialog(this, msg); - dialog.show(); - } - - public void setEditBoxResult(String editResult) - { - Log.i("editbox_content", editResult); - - try - { - final byte[] bytesUTF8 = editResult.getBytes("UTF8"); - // pass utf8 string from editbox activity to native. - // Should invoke native method in GL thread. - mGLView.queueEvent(new Runnable() { - @Override - public void run() { - nativeSetEditboxText(bytesUTF8); - } - }); - } - catch (java.io.UnsupportedEncodingException e) - { - e.printStackTrace(); - } - } -} - -class DialogMessage { - public String title; - public String message; - - public DialogMessage(String title, String message){ - this.message = message; - this.title = title; - } -} - -class EditBoxMessage { - public String title; - public String content; - public int inputMode; - public int inputFlag; - public int returnType; - public int maxLength; - - public EditBoxMessage(String title, String content, int inputMode, int inputFlag, int returnType, int maxLength){ - this.content = content; - this.title = title; - this.inputMode = inputMode; - this.inputFlag = inputFlag; - this.returnType = returnType; - this.maxLength = maxLength; - } -} diff --git a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java b/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java deleted file mode 100644 index 395400b779..0000000000 --- a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java +++ /dev/null @@ -1,455 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.LinkedList; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Rect; -import android.graphics.Typeface; -import android.graphics.Paint.Align; -import android.graphics.Paint.FontMetricsInt; -import android.text.TextPaint; -import android.text.TextUtils; -import android.util.Log; - -public class Cocos2dxBitmap{ - /* - * The values are the same as cocos2dx/platform/CCImage.h. - */ - private static final int HALIGNCENTER = 3; - private static final int HALIGNLEFT = 1; - private static final int HALIGNRIGHT = 2; - // vertical alignment - private static final int VALIGNTOP = 1; - private static final int VALIGNBOTTOM = 2; - private static final int VALIGNCENTER = 3; - - private static Context context; - - public static void setContext(Context context){ - Cocos2dxBitmap.context = context; - } - - /* - * @width: the width to draw, it can be 0 - * @height: the height to draw, it can be 0 - */ - public static void createTextBitmap(String content, String fontName, - int fontSize, int alignment, int width, int height){ - - content = refactorString(content); - Paint paint = newPaint(fontName, fontSize, alignment); - - TextProperty textProperty = computeTextProperty(content, paint, width, height); - - int bitmapTotalHeight = (height == 0 ? textProperty.totalHeight:height); - - // Draw text to bitmap - Bitmap bitmap = Bitmap.createBitmap(textProperty.maxWidth, - bitmapTotalHeight, Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - - // Draw string - FontMetricsInt fm = paint.getFontMetricsInt(); - int x = 0; - int y = computeY(fm, height, textProperty.totalHeight, alignment); - String[] lines = textProperty.lines; - for (String line : lines){ - x = computeX(paint, line, textProperty.maxWidth, alignment); - canvas.drawText(line, x, y, paint); - y += textProperty.heightPerLine; - } - - initNativeObject(bitmap); - } - - private static int computeX(Paint paint, String content, int w, int alignment){ - int ret = 0; - int hAlignment = alignment & 0x0F; - - switch (hAlignment){ - case HALIGNCENTER: - ret = w / 2; - break; - - // ret = 0 - case HALIGNLEFT: - break; - - case HALIGNRIGHT: - ret = w; - break; - - /* - * Default is align left. - * Should be same as newPaint(). - */ - default: - break; - } - - return ret; - } - - private static int computeY(FontMetricsInt fm, int constrainHeight, int totalHeight, int alignment) { - int y = -fm.top; - - if (constrainHeight > totalHeight) { - int vAlignment = (alignment >> 4) & 0x0F; - - switch (vAlignment) { - case VALIGNTOP: - y = -fm.top; - break; - case VALIGNCENTER: - y = -fm.top + (constrainHeight - totalHeight)/2; - break; - case VALIGNBOTTOM: - y = -fm.top + (constrainHeight - totalHeight); - break; - default: - break; - } - } - - return y; - } - - private static class TextProperty{ - // The max width of lines - int maxWidth; - // The height of all lines - int totalHeight; - int heightPerLine; - String[] lines; - - TextProperty(int w, int h, String[] lines){ - this.maxWidth = w; - this.heightPerLine = h; - this.totalHeight = h * lines.length; - this.lines = lines; - } - } - - private static TextProperty computeTextProperty(String content, Paint paint, - int maxWidth, int maxHeight){ - FontMetricsInt fm = paint.getFontMetricsInt(); - int h = (int)Math.ceil(fm.bottom - fm.top); - int maxContentWidth = 0; - - String[] lines = splitString(content, maxHeight, maxWidth, paint); - - if (maxWidth != 0){ - maxContentWidth = maxWidth; - } - else { - /* - * Compute the max width - */ - int temp = 0; - for (String line : lines){ - temp = (int)Math.ceil(paint.measureText(line, 0, line.length())); - if (temp > maxContentWidth){ - maxContentWidth = temp; - } - } - } - - return new TextProperty(maxContentWidth, h, lines); - } - - /* - * If maxWidth or maxHeight is not 0, - * split the string to fix the maxWidth and maxHeight. - */ - private static String[] splitString(String content, int maxHeight, int maxWidth, - Paint paint){ - String[] lines = content.split("\\n"); - String[] ret = null; - FontMetricsInt fm = paint.getFontMetricsInt(); - int heightPerLine = (int)Math.ceil(fm.bottom - fm.top); - int maxLines = maxHeight / heightPerLine; - - if (maxWidth != 0){ - LinkedList strList = new LinkedList(); - for (String line : lines){ - /* - * The width of line is exceed maxWidth, should divide it into - * two or more lines. - */ - int lineWidth = (int)Math.ceil(paint.measureText(line)); - if (lineWidth > maxWidth){ - strList.addAll(divideStringWithMaxWidth(paint, line, maxWidth)); - } - else{ - strList.add(line); - } - - /* - * Should not exceed the max height; - */ - if (maxLines > 0 && strList.size() >= maxLines){ - break; - } - } - - /* - * Remove exceeding lines - */ - if (maxLines > 0 && strList.size() > maxLines){ - while (strList.size() > maxLines){ - strList.removeLast(); - } - } - - ret = new String[strList.size()]; - strList.toArray(ret); - } else - if (maxHeight != 0 && lines.length > maxLines) { - /* - * Remove exceeding lines - */ - LinkedList strList = new LinkedList(); - for (int i = 0; i < maxLines; i++){ - strList.add(lines[i]); - } - ret = new String[strList.size()]; - strList.toArray(ret); - } - else { - ret = lines; - } - - return ret; - } - - private static LinkedList divideStringWithMaxWidth(Paint paint, String content, - int width){ - int charLength = content.length(); - int start = 0; - int tempWidth = 0; - LinkedList strList = new LinkedList(); - - /* - * Break a String into String[] by the width & should wrap the word - */ - for (int i = 1; i <= charLength; ++i){ - tempWidth = (int)Math.ceil(paint.measureText(content, start, i)); - if (tempWidth >= width){ - int lastIndexOfSpace = content.substring(0, i).lastIndexOf(" "); - - if (lastIndexOfSpace != -1 && lastIndexOfSpace > start){ - /** - * Should wrap the word - */ - strList.add(content.substring(start, lastIndexOfSpace)); - i = lastIndexOfSpace; - } - else { - /* - * Should not exceed the width - */ - if (tempWidth > width){ - strList.add(content.substring(start, i - 1)); - /* - * compute from previous char - */ - --i; - } - else { - strList.add(content.substring(start, i)); - } - } - - // remove spaces at the beginning of a new line - while(content.indexOf(i++) == ' ') { - } - - start = i; - } - } - - /* - * Add the last chars - */ - if (start < charLength){ - strList.add(content.substring(start)); - } - - return strList; - } - - private static Paint newPaint(String fontName, int fontSize, int alignment){ - Paint paint = new Paint(); - paint.setColor(Color.WHITE); - paint.setTextSize(fontSize); - paint.setAntiAlias(true); - - /* - * Set type face for paint, now it support .ttf file. - */ - if (fontName.endsWith(".ttf")){ - try { - //Typeface typeFace = Typeface.createFromAsset(context.getAssets(), fontName); - Typeface typeFace = Cocos2dxTypefaces.get(context, fontName); - paint.setTypeface(typeFace); - } catch (Exception e){ - Log.e("Cocos2dxBitmap", - "error to create ttf type face: " + fontName); - - /* - * The file may not find, use system font - */ - paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL)); - } - } - else { - paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL)); - } - - int hAlignment = alignment & 0x0F; - switch (hAlignment){ - case HALIGNCENTER: - paint.setTextAlign(Align.CENTER); - break; - - case HALIGNLEFT: - paint.setTextAlign(Align.LEFT); - break; - - case HALIGNRIGHT: - paint.setTextAlign(Align.RIGHT); - break; - - default: - paint.setTextAlign(Align.LEFT); - break; - } - - return paint; - } - - private static String refactorString(String str){ - // Avoid error when content is "" - if (str.compareTo("") == 0){ - return " "; - } - - /* - * If the font of "\n" is "" or "\n", insert " " in front of it. - * - * For example: - * "\nabc" -> " \nabc" - * "\nabc\n\n" -> " \nabc\n \n" - */ - StringBuilder strBuilder = new StringBuilder(str); - int start = 0; - int index = strBuilder.indexOf("\n"); - while (index != -1){ - if (index == 0 || strBuilder.charAt(index -1) == '\n'){ - strBuilder.insert(start, " "); - start = index + 2; - } else { - start = index + 1; - } - - if (start > strBuilder.length() || index == strBuilder.length()){ - break; - } - - index = strBuilder.indexOf("\n", start); - } - - return strBuilder.toString(); - } - - private static void initNativeObject(Bitmap bitmap){ - byte[] pixels = getPixels(bitmap); - if (pixels == null){ - return; - } - - nativeInitBitmapDC(bitmap.getWidth(), bitmap.getHeight(), pixels); - } - - private static byte[] getPixels(Bitmap bitmap){ - if (bitmap != null){ - byte[] pixels = new byte[bitmap.getWidth() * bitmap.getHeight() * 4]; - ByteBuffer buf = ByteBuffer.wrap(pixels); - buf.order(ByteOrder.nativeOrder()); - bitmap.copyPixelsToBuffer(buf); - return pixels; - } - - return null; - } - - private static native void nativeInitBitmapDC(int width, int height, byte[] pixels); - - private static int getFontSizeAccordingHeight(int height) - { - Paint paint = new Paint(); - Rect bounds = new Rect(); - - paint.setTypeface(Typeface.DEFAULT); - int incr_text_size = 1; - boolean found_desired_size = false; - - while (!found_desired_size) { - - paint.setTextSize(incr_text_size); - String text = "SghMNy"; - paint.getTextBounds(text, 0, text.length(), bounds); - - incr_text_size++; - - if (height - bounds.height() <= 2) { - found_desired_size = true; - } - Log.d("font size", "incr size:" + incr_text_size); - } - return incr_text_size; - } - - private static String getStringWithEllipsis(String originalText, float width, float fontSize){ - if(TextUtils.isEmpty(originalText)){ - return ""; - } - - TextPaint paint = new TextPaint(); - paint.setTypeface(Typeface.DEFAULT); - paint.setTextSize(fontSize); - - return TextUtils.ellipsize(originalText, paint, width, - TextUtils.TruncateAt.valueOf("END")).toString(); - } - -} diff --git a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java b/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java deleted file mode 100755 index 66e94e242c..0000000000 --- a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java +++ /dev/null @@ -1,338 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -package org.cocos2dx.lib; - -import android.app.Dialog; -import android.content.Context; -import android.graphics.drawable.ColorDrawable; -import android.os.Bundle; -import android.os.Handler; -import android.text.InputFilter; -import android.text.InputType; -import android.util.Log; -import android.util.TypedValue; -import android.view.KeyEvent; -import android.view.ViewGroup; -import android.view.WindowManager; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; -import android.widget.LinearLayout; -import android.widget.TextView; -import android.widget.TextView.OnEditorActionListener; - -public class Cocos2dxEditBoxDialog extends Dialog { - - /** - * The user is allowed to enter any text, including line breaks. - */ - private final int kEditBoxInputModeAny = 0; - - /** - * The user is allowed to enter an e-mail address. - */ - private final int kEditBoxInputModeEmailAddr = 1; - - /** - * The user is allowed to enter an integer value. - */ - private final int kEditBoxInputModeNumeric = 2; - - /** - * The user is allowed to enter a phone number. - */ - private final int kEditBoxInputModePhoneNumber = 3; - - /** - * The user is allowed to enter a URL. - */ - private final int kEditBoxInputModeUrl = 4; - - /** - * The user is allowed to enter a real number value. - * This extends kEditBoxInputModeNumeric by allowing a decimal point. - */ - private final int kEditBoxInputModeDecimal = 5; - - /** - * The user is allowed to enter any text, except for line breaks. - */ - private final int kEditBoxInputModeSingleLine = 6; - - - /** - * Indicates that the text entered is confidential data that should be - * obscured whenever possible. This implies EDIT_BOX_INPUT_FLAG_SENSITIVE. - */ - private final int kEditBoxInputFlagPassword = 0; - - /** - * Indicates that the text entered is sensitive data that the - * implementation must never store into a dictionary or table for use - * in predictive, auto-completing, or other accelerated input schemes. - * A credit card number is an example of sensitive data. - */ - private final int kEditBoxInputFlagSensitive = 1; - - /** - * This flag is a hint to the implementation that during text editing, - * the initial letter of each word should be capitalized. - */ - private final int kEditBoxInputFlagInitialCapsWord = 2; - - /** - * This flag is a hint to the implementation that during text editing, - * the initial letter of each sentence should be capitalized. - */ - private final int kEditBoxInputFlagInitialCapsSentence = 3; - - /** - * Capitalize all characters automatically. - */ - private final int kEditBoxInputFlagInitialCapsAllCharacters = 4; - - private final int kKeyboardReturnTypeDefault = 0; - private final int kKeyboardReturnTypeDone = 1; - private final int kKeyboardReturnTypeSend = 2; - private final int kKeyboardReturnTypeSearch = 3; - private final int kKeyboardReturnTypeGo = 4; - - // - private EditText mInputEditText = null; - private TextView mTextViewTitle = null; - private int mInputMode = 0; - private int mInputFlag = 0; - private int mReturnType = 0; - private int mMaxLength = -1; - - private int mInputFlagConstraints = 0x00000; - private int mInputModeContraints = 0x00000; - private boolean mIsMultiline = false; - private Cocos2dxActivity mParentActivity = null; - private EditBoxMessage mMsg = null; - - public Cocos2dxEditBoxDialog(Context context, EditBoxMessage msg) { - //super(context, R.style.Theme_Translucent); - super(context, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen); - // TODO Auto-generated constructor stub - mParentActivity = (Cocos2dxActivity)context; - mMsg = msg; - } - - // Converting dips to pixels - private int convertDipsToPixels(float dips) - { - float scale = getContext().getResources().getDisplayMetrics().density; - return Math.round(dips * scale); - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - // TODO Auto-generated method stub - super.onCreate(savedInstanceState); - - getWindow().setBackgroundDrawable(new ColorDrawable(0x80000000)); - - LinearLayout layout = new LinearLayout(mParentActivity); - layout.setOrientation(LinearLayout.VERTICAL); - - LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup. - LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT); - - mTextViewTitle = new TextView(mParentActivity); - LinearLayout.LayoutParams textviewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.WRAP_CONTENT); - textviewParams.leftMargin = textviewParams.rightMargin = convertDipsToPixels(10); - mTextViewTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); - layout.addView(mTextViewTitle, textviewParams); - - mInputEditText = new EditText(mParentActivity); - LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT); - editTextParams.leftMargin = editTextParams.rightMargin = convertDipsToPixels(10); - - layout.addView(mInputEditText, editTextParams); - - setContentView(layout, layoutParams); - - getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - - mInputMode = mMsg.inputMode; - mInputFlag = mMsg.inputFlag; - mReturnType = mMsg.returnType; - mMaxLength = mMsg.maxLength; - - mTextViewTitle.setText(mMsg.title); - mInputEditText.setText(mMsg.content); - - int oldImeOptions = mInputEditText.getImeOptions(); - mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_FLAG_NO_EXTRACT_UI); - oldImeOptions = mInputEditText.getImeOptions(); - - switch (mInputMode) - { - case kEditBoxInputModeAny: - mInputModeContraints = - InputType.TYPE_CLASS_TEXT | - InputType.TYPE_TEXT_FLAG_MULTI_LINE; - break; - case kEditBoxInputModeEmailAddr: - mInputModeContraints = - InputType.TYPE_CLASS_TEXT | - InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; - break; - case kEditBoxInputModeNumeric: - mInputModeContraints = - InputType.TYPE_CLASS_NUMBER | - InputType.TYPE_NUMBER_FLAG_SIGNED; - break; - case kEditBoxInputModePhoneNumber: - mInputModeContraints = InputType.TYPE_CLASS_PHONE; - break; - case kEditBoxInputModeUrl: - mInputModeContraints = - InputType.TYPE_CLASS_TEXT | - InputType.TYPE_TEXT_VARIATION_URI; - break; - case kEditBoxInputModeDecimal: - mInputModeContraints = - InputType.TYPE_CLASS_NUMBER | - InputType.TYPE_NUMBER_FLAG_DECIMAL | - InputType.TYPE_NUMBER_FLAG_SIGNED; - break; - case kEditBoxInputModeSingleLine: - mInputModeContraints = InputType.TYPE_CLASS_TEXT; - break; - default: - - break; - } - - if ( mIsMultiline ) { - mInputModeContraints |= InputType.TYPE_TEXT_FLAG_MULTI_LINE; - } - - mInputEditText.setInputType(mInputModeContraints | mInputFlagConstraints); - - switch (mInputFlag) - { - case kEditBoxInputFlagPassword: - mInputFlagConstraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD; - break; - case kEditBoxInputFlagSensitive: - mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS; - break; - case kEditBoxInputFlagInitialCapsWord: - mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_WORDS; - break; - case kEditBoxInputFlagInitialCapsSentence: - mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; - break; - case kEditBoxInputFlagInitialCapsAllCharacters: - mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS; - break; - default: - break; - } - mInputEditText.setInputType(mInputFlagConstraints | mInputModeContraints); - - switch (mReturnType) { - case kKeyboardReturnTypeDefault: - mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE); - break; - case kKeyboardReturnTypeDone: - mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_DONE); - break; - case kKeyboardReturnTypeSend: - mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEND); - break; - case kKeyboardReturnTypeSearch: - mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEARCH); - break; - case kKeyboardReturnTypeGo: - mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_GO); - break; - default: - mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE); - break; - } - - if (mMaxLength > 0) { - mInputEditText.setFilters( - new InputFilter[] { - new InputFilter.LengthFilter(mMaxLength) - } - ); - } - - Handler initHandler = new Handler(); - initHandler.postDelayed(new Runnable() { - public void run() { - mInputEditText.requestFocus(); - mInputEditText.setSelection(mInputEditText.length()); - openKeyboard(); - } - }, 200); - - mInputEditText.setOnEditorActionListener(new OnEditorActionListener() { - @Override - public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - // if user didn't set keyboard type, - // this callback will be invoked twice with 'KeyEvent.ACTION_DOWN' and 'KeyEvent.ACTION_UP' - if (actionId != EditorInfo.IME_NULL - || (actionId == EditorInfo.IME_NULL - && event != null - && event.getAction() == KeyEvent.ACTION_DOWN)) - { - //Log.d("EditBox", "actionId: "+actionId +",event: "+event); - mParentActivity.setEditBoxResult(mInputEditText.getText().toString()); - closeKeyboard(); - dismiss(); - return true; - } - return false; - } - }); - } - - private void openKeyboard() { - InputMethodManager imm = (InputMethodManager) mParentActivity.getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(mInputEditText, 0); - Log.d("Cocos2dxEditBox", "openKeyboard"); - } - - private void closeKeyboard() { - InputMethodManager imm = (InputMethodManager) mParentActivity.getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(mInputEditText.getWindowToken(), 0); - Log.d("Cocos2dxEditBox", "closeKeyboard"); - } - - @Override - protected void onStop() { - // TODO Auto-generated method stub - super.onStop(); - Log.d("EditBox", "onStop..."); - } -} diff --git a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxEditText.java b/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxEditText.java deleted file mode 100644 index 1c9778293f..0000000000 --- a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxEditText.java +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -package org.cocos2dx.lib; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.KeyEvent; -import android.widget.EditText; - -public class Cocos2dxEditText extends EditText { - - private Cocos2dxGLSurfaceView mView; - - public Cocos2dxEditText(Context context) { - super(context); - // TODO Auto-generated constructor stub - } - - public Cocos2dxEditText(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public Cocos2dxEditText(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - public void setMainView(Cocos2dxGLSurfaceView glSurfaceView) { - mView = glSurfaceView; - } - - /* - * Let GlSurfaceView get focus if back key is input - */ - public boolean onKeyDown(int keyCode, KeyEvent event) { - super.onKeyDown(keyCode, event); - - if (keyCode == KeyEvent.KEYCODE_BACK) { - mView.requestFocus(); - } - - return true; - } -} diff --git a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java b/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java deleted file mode 100644 index e7c4721cf3..0000000000 --- a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java +++ /dev/null @@ -1,417 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import android.content.Context; -import android.opengl.GLSurfaceView; -import android.os.Handler; -import android.os.Message; -import android.text.Editable; -import android.text.TextWatcher; -import android.util.AttributeSet; -import android.util.Log; -import android.view.KeyEvent; -import android.view.MotionEvent; -import android.view.inputmethod.InputMethodManager; -import android.widget.TextView; -import android.widget.TextView.OnEditorActionListener; - -class TextInputWraper implements TextWatcher, OnEditorActionListener { - - private static final Boolean debug = false; - private void LogD(String msg) { - if (debug) Log.d("TextInputFilter", msg); - } - - private Cocos2dxGLSurfaceView mMainView; - private String mText; - private String mOriginText; - - private Boolean isFullScreenEdit() { - InputMethodManager imm = (InputMethodManager)mMainView.getTextField().getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - return imm.isFullscreenMode(); - } - - public TextInputWraper(Cocos2dxGLSurfaceView view) { - mMainView = view; - } - - public void setOriginText(String text) { - mOriginText = text; - } - - @Override - public void afterTextChanged(Editable s) { - if (isFullScreenEdit()) { - return; - } - - LogD("afterTextChanged: " + s); - int nModified = s.length() - mText.length(); - if (nModified > 0) { - final String insertText = s.subSequence(mText.length(), s.length()).toString(); - mMainView.insertText(insertText); - LogD("insertText(" + insertText + ")"); - } - else { - for (; nModified < 0; ++nModified) { - mMainView.deleteBackward(); - LogD("deleteBackward"); - } - } - mText = s.toString(); - } - - @Override - public void beforeTextChanged(CharSequence s, int start, int count, - int after) { - LogD("beforeTextChanged(" + s + ")start: " + start + ",count: " + count + ",after: " + after); - mText = s.toString(); - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - - @Override - public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - if (mMainView.getTextField() == v && isFullScreenEdit()) { - // user press the action button, delete all old text and insert new text - for (int i = mOriginText.length(); i > 0; --i) { - mMainView.deleteBackward(); - LogD("deleteBackward"); - } - String text = v.getText().toString(); - - /* - * If user input nothing, translate "\n" to engine. - */ - if (text.compareTo("") == 0){ - text = "\n"; - } - - if ('\n' != text.charAt(text.length() - 1)) { - text += '\n'; - } - - final String insertText = text; - mMainView.insertText(insertText); - LogD("insertText(" + insertText + ")"); - } - return false; - } -} - -public class Cocos2dxGLSurfaceView extends GLSurfaceView { - - static private Cocos2dxGLSurfaceView mainView; - - private static final String TAG = Cocos2dxGLSurfaceView.class.getCanonicalName(); - private Cocos2dxRenderer mRenderer; - - private static final boolean debug = false; - - /////////////////////////////////////////////////////////////////////////// - // for initialize - /////////////////////////////////////////////////////////////////////////// - public Cocos2dxGLSurfaceView(Context context) { - super(context); - initView(); - } - - public Cocos2dxGLSurfaceView(Context context, AttributeSet attrs) { - super(context, attrs); - initView(); - } - - public void setCocos2dxRenderer(Cocos2dxRenderer renderer){ - mRenderer = renderer; - setRenderer(mRenderer); - } - - protected void initView() { - setFocusableInTouchMode(true); - - textInputWraper = new TextInputWraper(this); - - handler = new Handler(){ - public void handleMessage(Message msg){ - switch(msg.what){ - case HANDLER_OPEN_IME_KEYBOARD: - if (null != mTextField && mTextField.requestFocus()) { - mTextField.removeTextChangedListener(textInputWraper); - mTextField.setText(""); - String text = (String)msg.obj; - mTextField.append(text); - textInputWraper.setOriginText(text); - mTextField.addTextChangedListener(textInputWraper); - InputMethodManager imm = (InputMethodManager)mainView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(mTextField, 0); - Log.d("GLSurfaceView", "showSoftInput"); - } - break; - - case HANDLER_CLOSE_IME_KEYBOARD: - if (null != mTextField) { - mTextField.removeTextChangedListener(textInputWraper); - InputMethodManager imm = (InputMethodManager)mainView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(mTextField.getWindowToken(), 0); - Log.d("GLSurfaceView", "HideSoftInput"); - } - break; - } - } - }; - - mainView = this; - } - - public void onPause(){ - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleOnPause(); - } - }); - - super.onPause(); - } - - public void onResume(){ - super.onResume(); - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleOnResume(); - } - }); - } - - /////////////////////////////////////////////////////////////////////////// - // for text input - /////////////////////////////////////////////////////////////////////////// - private final static int HANDLER_OPEN_IME_KEYBOARD = 2; - private final static int HANDLER_CLOSE_IME_KEYBOARD = 3; - private static Handler handler; - private static TextInputWraper textInputWraper; - private Cocos2dxEditText mTextField; - - public TextView getTextField() { - return mTextField; - } - - public void setTextField(Cocos2dxEditText view) { - mTextField = view; - if (null != mTextField && null != textInputWraper) { - mTextField.setOnEditorActionListener(textInputWraper); - mTextField.setMainView(this); - this.requestFocus(); - } - } - - public static void openIMEKeyboard() { - Message msg = new Message(); - msg.what = HANDLER_OPEN_IME_KEYBOARD; - msg.obj = mainView.getContentText(); - handler.sendMessage(msg); - - } - - private String getContentText() { - return mRenderer.getContentText(); - } - - public static void closeIMEKeyboard() { - Message msg = new Message(); - msg.what = HANDLER_CLOSE_IME_KEYBOARD; - handler.sendMessage(msg); - } - - public void insertText(final String text) { - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleInsertText(text); - } - }); - } - - public void deleteBackward() { - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleDeleteBackward(); - } - }); - } - - /////////////////////////////////////////////////////////////////////////// - // for touch event - /////////////////////////////////////////////////////////////////////////// - - public boolean onTouchEvent(final MotionEvent event) { - // these data are used in ACTION_MOVE and ACTION_CANCEL - final int pointerNumber = event.getPointerCount(); - final int[] ids = new int[pointerNumber]; - final float[] xs = new float[pointerNumber]; - final float[] ys = new float[pointerNumber]; - - for (int i = 0; i < pointerNumber; i++) { - ids[i] = event.getPointerId(i); - xs[i] = event.getX(i); - ys[i] = event.getY(i); - } - - switch (event.getAction() & MotionEvent.ACTION_MASK) { - case MotionEvent.ACTION_POINTER_DOWN: - final int indexPointerDown = event.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT; - final int idPointerDown = event.getPointerId(indexPointerDown); - final float xPointerDown = event.getX(indexPointerDown); - final float yPointerDown = event.getY(indexPointerDown); - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionDown(idPointerDown, xPointerDown, yPointerDown); - } - }); - break; - - case MotionEvent.ACTION_DOWN: - // there are only one finger on the screen - final int idDown = event.getPointerId(0); - final float xDown = xs[0]; - final float yDown = ys[0]; - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionDown(idDown, xDown, yDown); - } - }); - break; - - case MotionEvent.ACTION_MOVE: - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionMove(ids, xs, ys); - } - }); - break; - - case MotionEvent.ACTION_POINTER_UP: - final int indexPointUp = event.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT; - final int idPointerUp = event.getPointerId(indexPointUp); - final float xPointerUp = event.getX(indexPointUp); - final float yPointerUp = event.getY(indexPointUp); - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionUp(idPointerUp, xPointerUp, yPointerUp); - } - }); - break; - - case MotionEvent.ACTION_UP: - // there are only one finger on the screen - final int idUp = event.getPointerId(0); - final float xUp = xs[0]; - final float yUp = ys[0]; - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionUp(idUp, xUp, yUp); - } - }); - break; - - case MotionEvent.ACTION_CANCEL: - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionCancel(ids, xs, ys); - } - }); - break; - } - - if (debug){ - dumpEvent(event); - } - return true; - } - - /* - * This function is called before Cocos2dxRenderer.nativeInit(), so the width and height is correct. - */ - protected void onSizeChanged(int w, int h, int oldw, int oldh){ - this.mRenderer.setScreenWidthAndHeight(w, h); - } - - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) { - final int kc = keyCode; - if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) { - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleKeyDown(kc); - } - }); - return true; - } - return super.onKeyDown(keyCode, event); - } - - // Show an event in the LogCat view, for debugging - private void dumpEvent(MotionEvent event) { - String names[] = { "DOWN" , "UP" , "MOVE" , "CANCEL" , "OUTSIDE" , - "POINTER_DOWN" , "POINTER_UP" , "7?" , "8?" , "9?" }; - StringBuilder sb = new StringBuilder(); - int action = event.getAction(); - int actionCode = action & MotionEvent.ACTION_MASK; - sb.append("event ACTION_" ).append(names[actionCode]); - if (actionCode == MotionEvent.ACTION_POINTER_DOWN - || actionCode == MotionEvent.ACTION_POINTER_UP) { - sb.append("(pid " ).append( - action >> MotionEvent.ACTION_POINTER_ID_SHIFT); - sb.append(")" ); - } - sb.append("[" ); - for (int i = 0; i < event.getPointerCount(); i++) { - sb.append("#" ).append(i); - sb.append("(pid " ).append(event.getPointerId(i)); - sb.append(")=" ).append((int) event.getX(i)); - sb.append("," ).append((int) event.getY(i)); - if (i + 1 < event.getPointerCount()) - sb.append(";" ); - } - sb.append("]" ); - Log.d(TAG, sb.toString()); - } -} diff --git a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxMusic.java b/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxMusic.java deleted file mode 100644 index 10e3e5f3c6..0000000000 --- a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxMusic.java +++ /dev/null @@ -1,228 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import android.content.Context; -import android.content.res.AssetFileDescriptor; -import android.media.MediaPlayer; -import android.util.Log; - -/** - * - * This class is used for controlling background music - * - */ -public class Cocos2dxMusic { - - private static final String TAG = "Cocos2dxMusic"; - private float mLeftVolume; - private float mRightVolume; - private Context mContext; - private MediaPlayer mBackgroundMediaPlayer; - private boolean mIsPaused; - private String mCurrentPath; - - public Cocos2dxMusic(Context context){ - this.mContext = context; - initData(); - } - - public void preloadBackgroundMusic(String path){ - if ((mCurrentPath == null) || (! mCurrentPath.equals(path))){ - // preload new background music - - // release old resource and create a new one - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.release(); - } - - mBackgroundMediaPlayer = createMediaplayerFromAssets(path); - - // record the path - mCurrentPath = path; - } - } - - public void playBackgroundMusic(String path, boolean isLoop){ - if (mCurrentPath == null){ - // it is the first time to play background music - // or end() was called - mBackgroundMediaPlayer = createMediaplayerFromAssets(path); - mCurrentPath = path; - } - else { - if (! mCurrentPath.equals(path)){ - // play new background music - - // release old resource and create a new one - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.release(); - } - mBackgroundMediaPlayer = createMediaplayerFromAssets(path); - - // record the path - mCurrentPath = path; - } - } - - if (mBackgroundMediaPlayer == null){ - Log.e(TAG, "playBackgroundMusic: background media player is null"); - } else { - // if the music is playing or paused, stop it - mBackgroundMediaPlayer.stop(); - - mBackgroundMediaPlayer.setLooping(isLoop); - - try { - mBackgroundMediaPlayer.prepare(); - mBackgroundMediaPlayer.seekTo(0); - mBackgroundMediaPlayer.start(); - - this.mIsPaused = false; - } catch (Exception e){ - Log.e(TAG, "playBackgroundMusic: error state"); - } - } - } - - public void stopBackgroundMusic(){ - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.stop(); - - // should set the state, if not , the following sequence will be error - // play -> pause -> stop -> resume - this.mIsPaused = false; - } - } - - public void pauseBackgroundMusic(){ - if (mBackgroundMediaPlayer != null && mBackgroundMediaPlayer.isPlaying()){ - mBackgroundMediaPlayer.pause(); - this.mIsPaused = true; - } - } - - public void resumeBackgroundMusic(){ - if (mBackgroundMediaPlayer != null && this.mIsPaused){ - mBackgroundMediaPlayer.start(); - this.mIsPaused = false; - } - } - - public void rewindBackgroundMusic(){ - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.stop(); - - try { - mBackgroundMediaPlayer.prepare(); - mBackgroundMediaPlayer.seekTo(0); - mBackgroundMediaPlayer.start(); - - this.mIsPaused = false; - } catch (Exception e){ - Log.e(TAG, "rewindBackgroundMusic: error state"); - } - } - } - - public boolean isBackgroundMusicPlaying(){ - boolean ret = false; - - if (mBackgroundMediaPlayer == null){ - ret = false; - } else { - ret = mBackgroundMediaPlayer.isPlaying(); - } - - return ret; - } - - public void end(){ - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.release(); - } - - initData(); - } - - public float getBackgroundVolume(){ - if (this.mBackgroundMediaPlayer != null){ - return (this.mLeftVolume + this.mRightVolume) / 2; - } else { - return 0.0f; - } - } - - public void setBackgroundVolume(float volume){ - if (volume < 0.0f){ - volume = 0.0f; - } - - if (volume > 1.0f){ - volume = 1.0f; - } - - this.mLeftVolume = this.mRightVolume = volume; - if (this.mBackgroundMediaPlayer != null){ - this.mBackgroundMediaPlayer.setVolume(this.mLeftVolume, this.mRightVolume); - } - } - - private void initData(){ - mLeftVolume =0.5f; - mRightVolume = 0.5f; - mBackgroundMediaPlayer = null; - mIsPaused = false; - mCurrentPath = null; - } - - /** - * create mediaplayer for music - * @param path the path relative to assets - * @return - */ - private MediaPlayer createMediaplayerFromAssets(String path){ - MediaPlayer mediaPlayer = new MediaPlayer(); - - try{ - if (path.startsWith("/")) { - mediaPlayer.setDataSource(path); - } - else { - AssetFileDescriptor assetFileDescritor = mContext.getAssets().openFd(path); - mediaPlayer.setDataSource(assetFileDescritor.getFileDescriptor(), - assetFileDescritor.getStartOffset(), assetFileDescritor.getLength()); - } - - mediaPlayer.prepare(); - - mediaPlayer.setVolume(mLeftVolume, mRightVolume); - }catch (Exception e) { - mediaPlayer = null; - Log.e(TAG, "error: " + e.getMessage(), e); - } - - return mediaPlayer; - } -} diff --git a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxRenderer.java b/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxRenderer.java deleted file mode 100644 index fad0974f42..0000000000 --- a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxRenderer.java +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; - -import android.opengl.GLSurfaceView; - -public class Cocos2dxRenderer implements GLSurfaceView.Renderer { - private final static long NANOSECONDSPERSECOND = 1000000000L; - private final static long NANOSECONDSPERMINISECOND = 1000000; - private static long animationInterval = (long)(1.0 / 60 * NANOSECONDSPERSECOND); - private long last; - private int screenWidth; - private int screenHeight; - - public void onSurfaceCreated(GL10 gl, EGLConfig config) { - nativeInit(screenWidth, screenHeight); - last = System.nanoTime(); - } - - public void setScreenWidthAndHeight(int w, int h){ - this.screenWidth = w; - this.screenHeight = h; - } - - public void onSurfaceChanged(GL10 gl, int w, int h) { - } - - public void onDrawFrame(GL10 gl) { - - long now = System.nanoTime(); - long interval = now - last; - - // should render a frame when onDrawFrame() is called - // or there is a "ghost" - nativeRender(); - - // fps controlling - if (interval < animationInterval){ - try { - // because we render it before, so we should sleep twice time interval - Thread.sleep((animationInterval - interval) * 2 / NANOSECONDSPERMINISECOND); - } catch (Exception e){} - } - - last = now; - } - - public void handleActionDown(int id, float x, float y) - { - nativeTouchesBegin(id, x, y); - } - - public void handleActionUp(int id, float x, float y) - { - nativeTouchesEnd(id, x, y); - } - - public void handleActionCancel(int[] id, float[] x, float[] y) - { - nativeTouchesCancel(id, x, y); - } - - public void handleActionMove(int[] id, float[] x, float[] y) - { - nativeTouchesMove(id, x, y); - } - - public void handleKeyDown(int keyCode) - { - nativeKeyDown(keyCode); - } - - public void handleOnPause(){ - nativeOnPause(); - } - - public void handleOnResume(){ - nativeOnResume(); - } - - public static void setAnimationInterval(double interval){ - animationInterval = (long)(interval * NANOSECONDSPERSECOND); - } - private static native void nativeTouchesBegin(int id, float x, float y); - private static native void nativeTouchesEnd(int id, float x, float y); - private static native void nativeTouchesMove(int[] id, float[] x, float[] y); - private static native void nativeTouchesCancel(int[] id, float[] x, float[] y); - private static native boolean nativeKeyDown(int keyCode); - private static native void nativeRender(); - private static native void nativeInit(int w, int h); - private static native void nativeOnPause(); - private static native void nativeOnResume(); - - ///////////////////////////////////////////////////////////////////////////////// - // handle input method edit message - ///////////////////////////////////////////////////////////////////////////////// - - public void handleInsertText(final String text) { - nativeInsertText(text); - } - - public void handleDeleteBackward() { - nativeDeleteBackward(); - } - - public String getContentText() { - return nativeGetContentText(); - } - - private static native void nativeInsertText(String text); - private static native void nativeDeleteBackward(); - private static native String nativeGetContentText(); -} diff --git a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java b/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java deleted file mode 100644 index e7061f74de..0000000000 --- a/samples/SimpleGame/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import android.content.Context; -import android.media.AudioManager; -import android.media.SoundPool; -import android.util.Log; - -/** - * - * This class is used for controlling effect - * - */ - -public class Cocos2dxSound { - private Context mContext; - private SoundPool mSoundPool; - private float mLeftVolume; - private float mRightVolume; - - // sound path and stream ids map - // a file may be played many times at the same time - // so there is an array map to a file path - private HashMap> mPathStreamIDsMap; - - private HashMap mPathSoundIdMap; - - private static final String TAG = "Cocos2dxSound"; - private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5; - private static final float SOUND_RATE = 1.0f; - private static final int SOUND_PRIORITY = 1; - private static final int SOUND_QUALITY = 5; - - private final static int INVALID_SOUND_ID = -1; - private final static int INVALID_STREAM_ID = -1; - - public Cocos2dxSound(Context context){ - this.mContext = context; - initData(); - } - - public int preloadEffect(String path){ - Integer soundID = this.mPathSoundIdMap.get(path); - - if (soundID == null) { - soundID = createSoundIdFromAsset(path); - this.mPathSoundIdMap.put(path, soundID); - } - - return soundID; - } - - public void unloadEffect(String path){ - // stop effects - ArrayList streamIDs = this.mPathStreamIDsMap.get(path); - if (streamIDs != null) { - for (Integer streamID : streamIDs) { - this.mSoundPool.stop(streamID); - } - } - this.mPathStreamIDsMap.remove(path); - - // unload effect - Integer soundID = this.mPathSoundIdMap.get(path); - this.mSoundPool.unload(soundID); - this.mPathSoundIdMap.remove(path); - } - - public int playEffect(String path, boolean isLoop){ - Integer soundId = this.mPathSoundIdMap.get(path); - int streamId = INVALID_STREAM_ID; - - if (soundId != null){ - // play sound - streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, - this.mRightVolume, SOUND_PRIORITY, isLoop ? -1 : 0, SOUND_RATE); - - // record stream id - ArrayList streamIds = this.mPathStreamIDsMap.get(path); - if (streamIds == null) { - streamIds = new ArrayList(); - this.mPathStreamIDsMap.put(path, streamIds); - } - streamIds.add(streamId); - } else { - // the effect is not prepared - soundId = preloadEffect(path); - if (soundId == INVALID_SOUND_ID){ - // can not preload effect - return INVALID_SOUND_ID; - } - - /* - * Someone reports that, it can not play effect for the - * first time. If you are lucky to meet it. There are two - * ways to resolve it. - * 1. Add some delay here. I don't know how long it is, so - * I don't add it here. - * 2. If you use 2.2(API level 8), you can call - * SoundPool.setOnLoadCompleteListener() to play the effect. - * Because the method is supported from 2.2, so I can't use - * it here. - */ - playEffect(path, isLoop); - } - - return streamId; - } - - public void stopEffect(int streamID){ - this.mSoundPool.stop(streamID); - - // remove record - for (String path : this.mPathStreamIDsMap.keySet()) { - if (this.mPathStreamIDsMap.get(path).contains(streamID)) { - this.mPathStreamIDsMap.get(path).remove(this.mPathStreamIDsMap.get(path).indexOf(streamID)); - break; - } - } - } - - public void pauseEffect(int streamID){ - this.mSoundPool.pause(streamID); - } - - public void resumeEffect(int streamID){ - this.mSoundPool.resume(streamID); - } - - public void pauseAllEffects(){ - this.mSoundPool.autoPause(); - } - - public void resumeAllEffects(){ - // autoPause() is available since level 8 - this.mSoundPool.autoResume(); - } - - @SuppressWarnings("unchecked") - public void stopAllEffects(){ - // stop effects - if (! this.mPathStreamIDsMap.isEmpty()) { - Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry> entry = (Map.Entry>)iter.next(); - for (int streamID : entry.getValue()) { - this.mSoundPool.stop(streamID); - } - } - } - - // remove records - this.mPathStreamIDsMap.clear(); - } - - public float getEffectsVolume(){ - return (this.mLeftVolume + this.mRightVolume) / 2; - } - - @SuppressWarnings("unchecked") - public void setEffectsVolume(float volume){ - // volume should be in [0, 1.0] - if (volume < 0){ - volume = 0; - } - if (volume > 1){ - volume = 1; - } - - this.mLeftVolume = this.mRightVolume = volume; - - // change the volume of playing sounds - if (! this.mPathStreamIDsMap.isEmpty()) { - Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry> entry = (Map.Entry>)iter.next(); - for (int streamID : entry.getValue()) { - this.mSoundPool.setVolume(streamID, mLeftVolume, mRightVolume); - } - } - } - } - - public void end(){ - this.mSoundPool.release(); - this.mPathStreamIDsMap.clear(); - this.mPathSoundIdMap.clear(); - - initData(); - } - - public int createSoundIdFromAsset(String path){ - int soundId = INVALID_SOUND_ID; - - try { - if (path.startsWith("/")){ - soundId = mSoundPool.load(path, 0); - } - else { - soundId = mSoundPool.load(mContext.getAssets().openFd(path), 0); - } - } catch(Exception e){ - soundId = INVALID_SOUND_ID; - Log.e(TAG, "error: " + e.getMessage(), e); - } - - return soundId; - } - - private void initData(){ - this.mPathStreamIDsMap = new HashMap>(); - this.mPathSoundIdMap = new HashMap(); - mSoundPool = new SoundPool(MAX_SIMULTANEOUS_STREAMS_DEFAULT, AudioManager.STREAM_MUSIC, SOUND_QUALITY); - - this.mLeftVolume = 0.5f; - this.mRightVolume = 0.5f; - } -} diff --git a/samples/SimpleGame/proj.android/src/org/cocos2dx/simplegame/SimpleGame.java b/samples/SimpleGame/proj.android/src/org/cocos2dx/simplegame/SimpleGame.java index 99171bd284..997bb81493 100644 --- a/samples/SimpleGame/proj.android/src/org/cocos2dx/simplegame/SimpleGame.java +++ b/samples/SimpleGame/proj.android/src/org/cocos2dx/simplegame/SimpleGame.java @@ -24,85 +24,16 @@ THE SOFTWARE. package org.cocos2dx.simplegame; import org.cocos2dx.lib.Cocos2dxActivity; -import org.cocos2dx.lib.Cocos2dxEditText; -import org.cocos2dx.lib.Cocos2dxGLSurfaceView; -import org.cocos2dx.lib.Cocos2dxRenderer; -import android.app.ActivityManager; -import android.content.Context; -import android.content.pm.ConfigurationInfo; import android.os.Bundle; -import android.util.Log; -import android.widget.FrameLayout; -import android.view.ViewGroup; public class SimpleGame extends Cocos2dxActivity{ protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); - - if (detectOpenGLES20()) { - // get the packageName,it's used to set the resource path - String packageName = getApplication().getPackageName(); - super.setPackageName(packageName); - - // FrameLayout - ViewGroup.LayoutParams framelayout_params = - new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT); - FrameLayout framelayout = new FrameLayout(this); - framelayout.setLayoutParams(framelayout_params); - - // Cocos2dxEditText layout - ViewGroup.LayoutParams edittext_layout_params = - new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT); - Cocos2dxEditText edittext = new Cocos2dxEditText(this); - edittext.setLayoutParams(edittext_layout_params); - - // ...add to FrameLayout - framelayout.addView(edittext); - - // Cocos2dxGLSurfaceView - mGLView = new Cocos2dxGLSurfaceView(this); - - // ...add to FrameLayout - framelayout.addView(mGLView); - - mGLView.setEGLContextClientVersion(2); - mGLView.setCocos2dxRenderer(new Cocos2dxRenderer()); - mGLView.setTextField(edittext); - - // Set framelayout as the content view - setContentView(framelayout); - } - else { - Log.d("activity", "don't support gles2.0"); - finish(); - } } - @Override - protected void onPause() { - super.onPause(); - mGLView.onPause(); - } - - @Override - protected void onResume() { - super.onResume(); - mGLView.onResume(); - } - - private boolean detectOpenGLES20() - { - ActivityManager am = - (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); - ConfigurationInfo info = am.getDeviceConfigurationInfo(); - return (info.reqGlEsVersion >= 0x20000); - } - - static { - System.loadLibrary("game"); - } + static { + System.loadLibrary("game"); + } } diff --git a/samples/TestCpp/proj.android/.classpath b/samples/TestCpp/proj.android/.classpath index dc00167933..a4763d1eec 100644 --- a/samples/TestCpp/proj.android/.classpath +++ b/samples/TestCpp/proj.android/.classpath @@ -1,9 +1,8 @@ - - - - - - - - - + + + + + + + + diff --git a/samples/TestCpp/proj.android/.project b/samples/TestCpp/proj.android/.project index e5c64898b1..860a568760 100644 --- a/samples/TestCpp/proj.android/.project +++ b/samples/TestCpp/proj.android/.project @@ -1,40 +1,33 @@ - - - TestCpp - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - - - src_common - 2 - PARENT-3-PROJECT_LOC/cocos2dx/platform/android/java/src_common - - - + + + TestCpp + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/samples/TestCpp/proj.android/src/org/cocos2dx/testcpp/TestCpp.java b/samples/TestCpp/proj.android/src/org/cocos2dx/testcpp/TestCpp.java index d906569159..c590e12c1d 100644 --- a/samples/TestCpp/proj.android/src/org/cocos2dx/testcpp/TestCpp.java +++ b/samples/TestCpp/proj.android/src/org/cocos2dx/testcpp/TestCpp.java @@ -24,87 +24,16 @@ THE SOFTWARE. package org.cocos2dx.testcpp; import org.cocos2dx.lib.Cocos2dxActivity; -import org.cocos2dx.lib.Cocos2dxEditText; -import org.cocos2dx.lib.Cocos2dxGLSurfaceView; -import org.cocos2dx.lib.Cocos2dxRenderer; -import android.app.ActivityManager; -import android.content.Context; -import android.content.pm.ConfigurationInfo; import android.os.Bundle; -import android.util.Log; -import android.widget.FrameLayout; -import android.view.ViewGroup; public class TestCpp extends Cocos2dxActivity{ protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); - - if (detectOpenGLES20()) { - // get the packageName,it's used to set the resource path - String packageName = getApplication().getPackageName(); - super.setPackageName(packageName); - - // FrameLayout - ViewGroup.LayoutParams framelayout_params = - new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT); - FrameLayout framelayout = new FrameLayout(this); - framelayout.setLayoutParams(framelayout_params); - - // Cocos2dxEditText layout - ViewGroup.LayoutParams edittext_layout_params = - new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT); - Cocos2dxEditText edittext = new Cocos2dxEditText(this); - edittext.setLayoutParams(edittext_layout_params); - - // ...add to FrameLayout - framelayout.addView(edittext); - - // Cocos2dxGLSurfaceView - mGLView = new Cocos2dxGLSurfaceView(this); - - // ...add to FrameLayout - framelayout.addView(mGLView); - - mGLView.setEGLContextClientVersion(2); - mGLView.setCocos2dxRenderer(new Cocos2dxRenderer()); - mGLView.setTextField(edittext); - - // Set framelayout as the content view - setContentView(framelayout); - } - else { - Log.d("activity", "don't support gles2.0"); - finish(); - } } - @Override - protected void onPause() { - super.onPause(); - - mGLView.onPause(); - } - - @Override - protected void onResume() { - super.onResume(); - - mGLView.onResume(); - } - - private boolean detectOpenGLES20() - { - ActivityManager am = - (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); - ConfigurationInfo info = am.getDeviceConfigurationInfo(); - return (info.reqGlEsVersion >= 0x20000); - } - - static { - System.loadLibrary("testcpp"); - } + static { + System.loadLibrary("testcpp"); + } } diff --git a/samples/TestJavascript/proj.android/.classpath b/samples/TestJavascript/proj.android/.classpath index dc00167933..a4763d1eec 100644 --- a/samples/TestJavascript/proj.android/.classpath +++ b/samples/TestJavascript/proj.android/.classpath @@ -1,9 +1,8 @@ - - - - - - - - - + + + + + + + + diff --git a/samples/TestJavascript/proj.android/src/org/cocos2dx/testjavascript/TestJavascript.java b/samples/TestJavascript/proj.android/src/org/cocos2dx/testjavascript/TestJavascript.java index fb6c750fa0..69117f4a73 100644 --- a/samples/TestJavascript/proj.android/src/org/cocos2dx/testjavascript/TestJavascript.java +++ b/samples/TestJavascript/proj.android/src/org/cocos2dx/testjavascript/TestJavascript.java @@ -24,85 +24,16 @@ THE SOFTWARE. package org.cocos2dx.testjavascript; import org.cocos2dx.lib.Cocos2dxActivity; -import org.cocos2dx.lib.Cocos2dxEditText; -import org.cocos2dx.lib.Cocos2dxGLSurfaceView; -import org.cocos2dx.lib.Cocos2dxRenderer; -import android.app.ActivityManager; -import android.content.Context; -import android.content.pm.ConfigurationInfo; import android.os.Bundle; -import android.util.Log; -import android.view.ViewGroup; -import android.widget.FrameLayout; public class TestJavascript extends Cocos2dxActivity{ protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); - - if (detectOpenGLES20()) { - // get the packageName,it's used to set the resource path - String packageName = getApplication().getPackageName(); - super.setPackageName(packageName); - - // FrameLayout - ViewGroup.LayoutParams framelayout_params = - new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT); - FrameLayout framelayout = new FrameLayout(this); - framelayout.setLayoutParams(framelayout_params); - - // Cocos2dxEditText layout - ViewGroup.LayoutParams edittext_layout_params = - new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT); - Cocos2dxEditText edittext = new Cocos2dxEditText(this); - edittext.setLayoutParams(edittext_layout_params); - - // ...add to FrameLayout - framelayout.addView(edittext); - - // Cocos2dxGLSurfaceView - mGLView = new Cocos2dxGLSurfaceView(this); - - // ...add to FrameLayout - framelayout.addView(mGLView); - - mGLView.setEGLContextClientVersion(2); - mGLView.setCocos2dxRenderer(new Cocos2dxRenderer()); - mGLView.setTextField(edittext); - - // Set framelayout as the content view - setContentView(framelayout); - } - else { - Log.d("activity", "don't support gles2.0"); - finish(); - } } - @Override - protected void onPause() { - super.onPause(); - mGLView.onPause(); - } - - @Override - protected void onResume() { - super.onResume(); - mGLView.onResume(); - } - - private boolean detectOpenGLES20() - { - ActivityManager am = - (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); - ConfigurationInfo info = am.getDeviceConfigurationInfo(); - return (info.reqGlEsVersion >= 0x20000); - } - - static { - System.loadLibrary("testjavascript"); - } + static { + System.loadLibrary("testjavascript"); + } } diff --git a/samples/TestLua/proj.android/.classpath b/samples/TestLua/proj.android/.classpath index ef74a4e99a..a4763d1eec 100644 --- a/samples/TestLua/proj.android/.classpath +++ b/samples/TestLua/proj.android/.classpath @@ -1,7 +1,6 @@ - diff --git a/samples/TestLua/proj.android/src/org/cocos2dx/testlua/TestLua.java b/samples/TestLua/proj.android/src/org/cocos2dx/testlua/TestLua.java index bcd7f7f4ad..1c9aa67ea6 100644 --- a/samples/TestLua/proj.android/src/org/cocos2dx/testlua/TestLua.java +++ b/samples/TestLua/proj.android/src/org/cocos2dx/testlua/TestLua.java @@ -23,91 +23,24 @@ THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.testlua; import org.cocos2dx.lib.Cocos2dxActivity; -import org.cocos2dx.lib.Cocos2dxEditText; import org.cocos2dx.lib.Cocos2dxGLSurfaceView; -import org.cocos2dx.lib.Cocos2dxRenderer; -import android.app.ActivityManager; import android.content.Context; -import android.content.pm.ConfigurationInfo; -import android.opengl.GLSurfaceView; import android.os.Bundle; -import android.util.Log; import android.view.KeyEvent; -import android.widget.FrameLayout; -import android.view.ViewGroup; public class TestLua extends Cocos2dxActivity{ protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); - - if (detectOpenGLES20()) { - // get the packageName,it's used to set the resource path - String packageName = getApplication().getPackageName(); - super.setPackageName(packageName); - - // FrameLayout - ViewGroup.LayoutParams framelayout_params = - new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT); - FrameLayout framelayout = new FrameLayout(this); - framelayout.setLayoutParams(framelayout_params); - - // Cocos2dxEditText layout - ViewGroup.LayoutParams edittext_layout_params = - new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT); - Cocos2dxEditText edittext = new Cocos2dxEditText(this); - edittext.setLayoutParams(edittext_layout_params); - - // ...add to FrameLayout - framelayout.addView(edittext); - - // LuaGLSurfaceView - mGLView = new LuaGLSurfaceView(this); - - // ...add to FrameLayout - framelayout.addView(mGLView); - - mGLView.setEGLContextClientVersion(2); - mGLView.setCocos2dxRenderer(new Cocos2dxRenderer()); - mGLView.setTextField(edittext); - - // Set framelayout as the content view - setContentView(framelayout); - } - else { - Log.d("activity", "don't support gles2.0"); - finish(); - } } - @Override - protected void onPause() { - super.onPause(); - mGLView.onPause(); - } + public Cocos2dxGLSurfaceView onCreateGLSurfaceView() { + return new LuaGLSurfaceView(this); + } - @Override - protected void onResume() { - super.onResume(); - mGLView.onResume(); - } - - private boolean detectOpenGLES20() - { - ActivityManager am = - (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); - ConfigurationInfo info = am.getDeviceConfigurationInfo(); - return (info.reqGlEsVersion >= 0x20000); - } - - private LuaGLSurfaceView mGLView; - - - static { - System.loadLibrary("testlua"); - } + static { + System.loadLibrary("testlua"); + } } class LuaGLSurfaceView extends Cocos2dxGLSurfaceView{ From 2ed9119d4f883aec00a07dd0652f5fc3a2ad9599 Mon Sep 17 00:00:00 2001 From: Byung Choi Date: Sat, 22 Sep 2012 03:02:29 +0900 Subject: [PATCH 091/181] fixed pointer to int casting warnings and errors, based on stdint --- cocos2dx/cocoa/CCDictionary.h | 6 +++--- cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp | 4 ++-- extensions/CCBReader/CCBAnimationManager.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cocos2dx/cocoa/CCDictionary.h b/cocos2dx/cocoa/CCDictionary.h index d39d7c5783..18dc2b8f9c 100644 --- a/cocos2dx/cocoa/CCDictionary.h +++ b/cocos2dx/cocoa/CCDictionary.h @@ -60,7 +60,7 @@ public: strcpy(m_szKey, pStart); } - CCDictElement(int iKey, CCObject* pObject) + CCDictElement(intptr_t iKey, CCObject* pObject) { init(); m_iKey = iKey; @@ -73,7 +73,7 @@ public: return m_szKey; } - inline int getIntKey() const + inline intptr_t getIntKey() const { CCAssert(m_szKey[0] == '\0', "Should not call this function for string dictionary"); return m_iKey; @@ -95,7 +95,7 @@ private: private: char m_szKey[MAX_KEY_LEN+1]; /** hash key of string type*/ - int m_iKey; /** hash key of integer type */ + intptr_t m_iKey; /** hash key of integer type */ CCObject* m_pObject;/** hash value */ public: UT_hash_handle hh; /* makes this class hashable */ diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp index a45d7a900d..03860d6a66 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp @@ -385,7 +385,7 @@ CCSprite * CCTMXLayer::insertTileForGID(unsigned int gid, const CCPoint& pos) CCRect rect = m_pTileSet->rectForGID(gid); rect = CC_RECT_PIXELS_TO_POINTS(rect); - int z = (int)(pos.x + pos.y * m_tLayerSize.width); + intptr_t z = (intptr_t)(pos.x + pos.y * m_tLayerSize.width); CCSprite *tile = reusedTileWithRect(rect); @@ -447,7 +447,7 @@ CCSprite * CCTMXLayer::appendTileForGID(unsigned int gid, const CCPoint& pos) CCRect rect = m_pTileSet->rectForGID(gid); rect = CC_RECT_PIXELS_TO_POINTS(rect); - int z = (int)(pos.x + pos.y * m_tLayerSize.width); + intptr_t z = (intptr_t)(pos.x + pos.y * m_tLayerSize.width); CCSprite *tile = reusedTileWithRect(rect); diff --git a/extensions/CCBReader/CCBAnimationManager.cpp b/extensions/CCBReader/CCBAnimationManager.cpp index 9448250c6a..3af62ea22e 100644 --- a/extensions/CCBReader/CCBAnimationManager.cpp +++ b/extensions/CCBReader/CCBAnimationManager.cpp @@ -129,16 +129,16 @@ void CCBAnimationManager::addNode(CCNode *pNode, CCDictionary *pSeq) { pNode->retain(); - mNodeSequences->setObject(pSeq, (int)pNode); + mNodeSequences->setObject(pSeq, (intptr_t)pNode); } void CCBAnimationManager::setBaseValue(CCObject *pValue, CCNode *pNode, const char *pPropName) { - CCDictionary *props = (CCDictionary*)mBaseValues->objectForKey((int)pNode); + CCDictionary *props = (CCDictionary*)mBaseValues->objectForKey((intptr_t)pNode); if (! props) { props = CCDictionary::create(); - mBaseValues->setObject(props, (int)pNode); + mBaseValues->setObject(props, (intptr_t)pNode); pNode->retain(); } @@ -147,7 +147,7 @@ void CCBAnimationManager::setBaseValue(CCObject *pValue, CCNode *pNode, const ch CCObject* CCBAnimationManager::getBaseValue(CCNode *pNode, const char* pPropName) { - CCDictionary *props = (CCDictionary*)mBaseValues->objectForKey((int)pNode); + CCDictionary *props = (CCDictionary*)mBaseValues->objectForKey((intptr_t)pNode); return props->objectForKey(pPropName); } From dad0573b29a33ed1268d6dda28872f849474cac0 Mon Sep 17 00:00:00 2001 From: Byung Choi Date: Sat, 22 Sep 2012 03:18:26 +0900 Subject: [PATCH 092/181] fixed build breakage for linux from change of test src name. --- samples/TestCpp/proj.linux/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/TestCpp/proj.linux/Makefile b/samples/TestCpp/proj.linux/Makefile index 82f62709a0..e1d855df5f 100644 --- a/samples/TestCpp/proj.linux/Makefile +++ b/samples/TestCpp/proj.linux/Makefile @@ -69,7 +69,7 @@ OBJECTS = ../Classes/AccelerometerTest/AccelerometerTest.o \ ../Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.o \ ../Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.o \ ../Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.o \ - ../Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsLayer.o \ + ../Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.o \ ../Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.o \ ../Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.o \ ../Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.o \ From 6730294dbe3f6f4f8c323045ed3ffe832a191224 Mon Sep 17 00:00:00 2001 From: folecr Date: Thu, 20 Sep 2012 14:12:04 -0700 Subject: [PATCH 093/181] Generated bindings are a submodule pointing to a separate repository * This allows bindings to be generated by a build server * ... when the Cocos2D-X API changes --- .gitmodules | 3 +++ scripting/javascript/bindings/generated | 1 + 2 files changed, 4 insertions(+) create mode 160000 scripting/javascript/bindings/generated diff --git a/.gitmodules b/.gitmodules index 29442ab901..165d817134 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "tools/cxx-generator"] path = tools/cxx-generator url = git://github.com/funkaster/cxx-generator.git +[submodule "scripting/javascript/bindings/generated"] + path = scripting/javascript/bindings/generated + url = git://github.com/folecr/cocos2dx-autogen-bindings.git diff --git a/scripting/javascript/bindings/generated b/scripting/javascript/bindings/generated new file mode 160000 index 0000000000..cae7ca0ca3 --- /dev/null +++ b/scripting/javascript/bindings/generated @@ -0,0 +1 @@ +Subproject commit cae7ca0ca35ec49f3d8eebe7256f7ae2bb946181 From 2a78f8d1767795956ef7d8e55c6665a6b70a6947 Mon Sep 17 00:00:00 2001 From: folecr Date: Thu, 20 Sep 2012 17:09:40 -0700 Subject: [PATCH 094/181] Separate out cocos specific manual type conversions. --- scripting/javascript/bindings/Android.mk | 1 + .../javascript/bindings/CCPhysicsSprite.cpp | 2 +- .../bindings/cocosjs_manual_conversions.cpp | 160 ++++++++++++++++++ .../bindings/cocosjs_manual_conversions.h | 19 +++ ...ings_chipmunk_functions.cpp.REMOVED.git-id | 2 +- .../bindings/js_bindings_chipmunk_manual.cpp | 2 +- .../bindings/js_manual_conversions.cpp | 157 ----------------- .../bindings/js_manual_conversions.h | 18 +- 8 files changed, 185 insertions(+), 176 deletions(-) create mode 100644 scripting/javascript/bindings/cocosjs_manual_conversions.cpp create mode 100644 scripting/javascript/bindings/cocosjs_manual_conversions.h diff --git a/scripting/javascript/bindings/Android.mk b/scripting/javascript/bindings/Android.mk index c11d5781c7..aa362e0fca 100644 --- a/scripting/javascript/bindings/Android.mk +++ b/scripting/javascript/bindings/Android.mk @@ -11,6 +11,7 @@ LOCAL_SRC_FILES := ScriptingCore.cpp \ CCPhysicsSprite.cpp \ cocos2dx.cpp \ js_manual_conversions.cpp \ + cocosjs_manual_conversions.cpp \ js_bindings_chipmunk_manual.cpp \ js_bindings_chipmunk_functions.cpp \ generated/cocos2dx.cpp diff --git a/scripting/javascript/bindings/CCPhysicsSprite.cpp b/scripting/javascript/bindings/CCPhysicsSprite.cpp index a9ab54aac7..92c9080f58 100644 --- a/scripting/javascript/bindings/CCPhysicsSprite.cpp +++ b/scripting/javascript/bindings/CCPhysicsSprite.cpp @@ -21,7 +21,7 @@ #include "CCPhysicsSprite.h" #include "ScriptingCore.h" -#include "js_manual_conversions.h" +#include "cocosjs_manual_conversions.h" using namespace cocos2d; diff --git a/scripting/javascript/bindings/cocosjs_manual_conversions.cpp b/scripting/javascript/bindings/cocosjs_manual_conversions.cpp new file mode 100644 index 0000000000..23618acc86 --- /dev/null +++ b/scripting/javascript/bindings/cocosjs_manual_conversions.cpp @@ -0,0 +1,160 @@ +#include "jsapi.h" +#include "jsfriendapi.h" +#include "ScriptingCore.h" +#include "js_bindings_config.h" +#include "cocosjs_manual_conversions.h" + +#define JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + +using namespace cocos2d; + +JSBool jsval_to_CCPoint( JSContext *cx, jsval vp, CCPoint *ret ) +{ +#ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + + JSObject *jsobj; + if( ! JS_ValueToObject( cx, vp, &jsobj ) ) + return JS_FALSE; + + JSB_PRECONDITION( jsobj, "Not a valid JS object"); + + jsval valx, valy; + JSBool ok = JS_TRUE; + ok &= JS_GetProperty(cx, jsobj, "x", &valx); + ok &= JS_GetProperty(cx, jsobj, "y", &valy); + + if( ! ok ) + return JS_FALSE; + + double x, y; + ok &= JS_ValueToNumber(cx, valx, &x); + ok &= JS_ValueToNumber(cx, valy, &y); + + if( ! ok ) + return JS_FALSE; + + ret->x = x; + ret->y = y; + + return JS_TRUE; + +#else // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + + JSObject *tmp_arg; + if( ! JS_ValueToObject( cx, vp, &tmp_arg ) ) + return JS_FALSE; + + JSB_PRECONDITION( tmp_arg && JS_IsTypedArrayObject( tmp_arg, cx ), "Not a TypedArray object"); + + JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg, cx ) == sizeof(cpVect), "Invalid length"); + + *ret = *(CCPoint*)JS_GetArrayBufferViewData( tmp_arg, cx ); + + return JS_TRUE; +#endif // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES +} + + +JSBool jsval_to_CGPoint( JSContext *cx, jsval vp, cpVect *ret ) +{ +#ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + + JSObject *jsobj; + if( ! JS_ValueToObject( cx, vp, &jsobj ) ) + return JS_FALSE; + + JSB_PRECONDITION( jsobj, "Not a valid JS object"); + + jsval valx, valy; + JSBool ok = JS_TRUE; + ok &= JS_GetProperty(cx, jsobj, "x", &valx); + ok &= JS_GetProperty(cx, jsobj, "y", &valy); + + if( ! ok ) + return JS_FALSE; + + double x, y; + ok &= JS_ValueToNumber(cx, valx, &x); + ok &= JS_ValueToNumber(cx, valy, &y); + + if( ! ok ) + return JS_FALSE; + + ret->x = x; + ret->y = y; + + return JS_TRUE; + +#else // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + + JSObject *tmp_arg; + if( ! JS_ValueToObject( cx, vp, &tmp_arg ) ) + return JS_FALSE; + + JSB_PRECONDITION( tmp_arg && JS_IsTypedArrayObject( tmp_arg, cx ), "Not a TypedArray object"); + + JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg, cx ) == sizeof(cpVect), "Invalid length"); + + *ret = *(cpVect*)JS_GetArrayBufferViewData( tmp_arg, cx ); + + return JS_TRUE; +#endif // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES +} + + +jsval CGPoint_to_jsval( JSContext *cx, cpVect p) +{ + +#ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + + JSObject *object = JS_NewObject(cx, NULL, NULL, NULL ); + if (!object) + return JSVAL_VOID; + + if (!JS_DefineProperty(cx, object, "x", DOUBLE_TO_JSVAL(p.x), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || + !JS_DefineProperty(cx, object, "y", DOUBLE_TO_JSVAL(p.y), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) ) + return JSVAL_VOID; + + return OBJECT_TO_JSVAL(object); + +#else // JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + +#ifdef __LP64__ + JSObject *typedArray = JS_NewFloat64Array( cx, 2 ); +#else + JSObject *typedArray = JS_NewFloat32Array( cx, 2 ); +#endif + + cpVect *buffer = (cpVect*)JS_GetArrayBufferViewData(typedArray, cx ); + *buffer = p; + return OBJECT_TO_JSVAL(typedArray); +#endif // ! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES +} + +JSBool jsval_to_cpBB( JSContext *cx, jsval vp, cpBB *ret ) +{ + JSObject *tmp_arg; + if( ! JS_ValueToObject( cx, vp, &tmp_arg ) ) + return JS_FALSE; + + JSB_PRECONDITION( JS_IsTypedArrayObject( tmp_arg, cx ), "Not a TypedArray object"); + + JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg, cx ) == sizeof(cpFloat)*4, "Invalid length"); + + *ret = *(cpBB*)JS_GetArrayBufferViewData( tmp_arg, cx); + + return JS_TRUE; +} + +jsval cpBB_to_jsval(JSContext *cx, cpBB bb ) +{ +#ifdef __LP64__ + JSObject *typedArray = JS_NewFloat64Array( cx, 4 ); +#else + JSObject *typedArray = JS_NewFloat32Array( cx, 4 ); +#endif + cpBB *buffer = (cpBB*)JS_GetArrayBufferViewData(typedArray, cx); + + *buffer = bb; + return OBJECT_TO_JSVAL(typedArray); +} diff --git a/scripting/javascript/bindings/cocosjs_manual_conversions.h b/scripting/javascript/bindings/cocosjs_manual_conversions.h new file mode 100644 index 0000000000..7a32f4c7a9 --- /dev/null +++ b/scripting/javascript/bindings/cocosjs_manual_conversions.h @@ -0,0 +1,19 @@ +#include "chipmunk.h" +#include "cocos2d.h" +#include "js_manual_conversions.h" + +#ifdef __cplusplus +extern "C" { +#endif + +JSBool jsval_to_CGPoint( JSContext *cx, jsval vp, cpVect *out ); +jsval CGPoint_to_jsval( JSContext *cx, cpVect p ); +JSBool jsval_to_cpBB( JSContext *cx, jsval vp, cpBB *ret ); +jsval cpBB_to_jsval(JSContext *cx, cpBB bb ); + +#ifdef __cplusplus +} +#endif + +#define cpVect_to_jsval CGPoint_to_jsval +#define jsval_to_cpVect jsval_to_CGPoint diff --git a/scripting/javascript/bindings/js_bindings_chipmunk_functions.cpp.REMOVED.git-id b/scripting/javascript/bindings/js_bindings_chipmunk_functions.cpp.REMOVED.git-id index 3210fb4c76..ff96617499 100644 --- a/scripting/javascript/bindings/js_bindings_chipmunk_functions.cpp.REMOVED.git-id +++ b/scripting/javascript/bindings/js_bindings_chipmunk_functions.cpp.REMOVED.git-id @@ -1 +1 @@ -02ec34ee0597673f01d3cc72224a3f0f52d8c06b \ No newline at end of file +c40aaf99dc1fe3345c11bc4952c69810483ea5d7 \ No newline at end of file diff --git a/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp b/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp index bb6530d2ee..7a8e2b1576 100644 --- a/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp +++ b/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp @@ -6,7 +6,7 @@ #include "js_bindings_chipmunk_manual.hpp" #include "jsapi.h" -#include "js_manual_conversions.h" +#include "cocosjs_manual_conversions.h" #include "uthash.h" #include "ccConfig.h" #include "ScriptingCore.h" diff --git a/scripting/javascript/bindings/js_manual_conversions.cpp b/scripting/javascript/bindings/js_manual_conversions.cpp index 5c65b056c3..334e77321b 100644 --- a/scripting/javascript/bindings/js_manual_conversions.cpp +++ b/scripting/javascript/bindings/js_manual_conversions.cpp @@ -9,135 +9,6 @@ #include "js_bindings_config.h" #include "js_manual_conversions.h" -#define JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES - -//#include "js_bindings_NS_manual.h" - - -JSBool jsval_to_CCPoint( JSContext *cx, jsval vp, CCPoint *ret ) -{ -#ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES - - JSObject *jsobj; - if( ! JS_ValueToObject( cx, vp, &jsobj ) ) - return JS_FALSE; - - JSB_PRECONDITION( jsobj, "Not a valid JS object"); - - jsval valx, valy; - JSBool ok = JS_TRUE; - ok &= JS_GetProperty(cx, jsobj, "x", &valx); - ok &= JS_GetProperty(cx, jsobj, "y", &valy); - - if( ! ok ) - return JS_FALSE; - - double x, y; - ok &= JS_ValueToNumber(cx, valx, &x); - ok &= JS_ValueToNumber(cx, valy, &y); - - if( ! ok ) - return JS_FALSE; - - ret->x = x; - ret->y = y; - - return JS_TRUE; - -#else // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES - - JSObject *tmp_arg; - if( ! JS_ValueToObject( cx, vp, &tmp_arg ) ) - return JS_FALSE; - - JSB_PRECONDITION( tmp_arg && JS_IsTypedArrayObject( tmp_arg, cx ), "Not a TypedArray object"); - - JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg, cx ) == sizeof(cpVect), "Invalid length"); - - *ret = *(CCPoint*)JS_GetArrayBufferViewData( tmp_arg, cx ); - - return JS_TRUE; -#endif // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES -} - - -JSBool jsval_to_CGPoint( JSContext *cx, jsval vp, cpVect *ret ) -{ -#ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES - - JSObject *jsobj; - if( ! JS_ValueToObject( cx, vp, &jsobj ) ) - return JS_FALSE; - - JSB_PRECONDITION( jsobj, "Not a valid JS object"); - - jsval valx, valy; - JSBool ok = JS_TRUE; - ok &= JS_GetProperty(cx, jsobj, "x", &valx); - ok &= JS_GetProperty(cx, jsobj, "y", &valy); - - if( ! ok ) - return JS_FALSE; - - double x, y; - ok &= JS_ValueToNumber(cx, valx, &x); - ok &= JS_ValueToNumber(cx, valy, &y); - - if( ! ok ) - return JS_FALSE; - - ret->x = x; - ret->y = y; - - return JS_TRUE; - -#else // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES - - JSObject *tmp_arg; - if( ! JS_ValueToObject( cx, vp, &tmp_arg ) ) - return JS_FALSE; - - JSB_PRECONDITION( tmp_arg && JS_IsTypedArrayObject( tmp_arg, cx ), "Not a TypedArray object"); - - JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg, cx ) == sizeof(cpVect), "Invalid length"); - - *ret = *(cpVect*)JS_GetArrayBufferViewData( tmp_arg, cx ); - - return JS_TRUE; -#endif // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES -} - - -jsval CGPoint_to_jsval( JSContext *cx, cpVect p) -{ - -#ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES - - JSObject *object = JS_NewObject(cx, NULL, NULL, NULL ); - if (!object) - return JSVAL_VOID; - - if (!JS_DefineProperty(cx, object, "x", DOUBLE_TO_JSVAL(p.x), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || - !JS_DefineProperty(cx, object, "y", DOUBLE_TO_JSVAL(p.y), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) ) - return JSVAL_VOID; - - return OBJECT_TO_JSVAL(object); - -#else // JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES - -#ifdef __LP64__ - JSObject *typedArray = JS_NewFloat64Array( cx, 2 ); -#else - JSObject *typedArray = JS_NewFloat32Array( cx, 2 ); -#endif - - cpVect *buffer = (cpVect*)JS_GetArrayBufferViewData(typedArray, cx ); - *buffer = p; - return OBJECT_TO_JSVAL(typedArray); -#endif // ! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES -} - - JSBool jsval_to_opaque( JSContext *cx, jsval vp, void **r) { #ifdef __LP64__ @@ -261,34 +132,6 @@ jsval long_to_jsval( JSContext *cx, long number ) #endif } -JSBool jsval_to_cpBB( JSContext *cx, jsval vp, cpBB *ret ) -{ - JSObject *tmp_arg; - if( ! JS_ValueToObject( cx, vp, &tmp_arg ) ) - return JS_FALSE; - - JSB_PRECONDITION( JS_IsTypedArrayObject( tmp_arg, cx ), "Not a TypedArray object"); - - JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg, cx ) == sizeof(cpFloat)*4, "Invalid length"); - - *ret = *(cpBB*)JS_GetArrayBufferViewData( tmp_arg, cx); - - return JS_TRUE; -} - -jsval cpBB_to_jsval(JSContext *cx, cpBB bb ) -{ -#ifdef __LP64__ - JSObject *typedArray = JS_NewFloat64Array( cx, 4 ); -#else - JSObject *typedArray = JS_NewFloat32Array( cx, 4 ); -#endif - cpBB *buffer = (cpBB*)JS_GetArrayBufferViewData(typedArray, cx); - - *buffer = bb; - return OBJECT_TO_JSVAL(typedArray); -} - jsval longlong_to_jsval( JSContext *cx, long long number ) { //NSCAssert( sizeof(long long)==8, @"Error!"); diff --git a/scripting/javascript/bindings/js_manual_conversions.h b/scripting/javascript/bindings/js_manual_conversions.h index 27baafff98..e67da4de09 100644 --- a/scripting/javascript/bindings/js_manual_conversions.h +++ b/scripting/javascript/bindings/js_manual_conversions.h @@ -3,10 +3,8 @@ // Copyright (c) 2012 Zynga Inc. All rights reserved. // -#include "chipmunk.h" -#include "cocos2d.h" +#include "jsapi.h" -using namespace cocos2d; #ifdef __cplusplus extern "C" { #endif @@ -15,23 +13,11 @@ JSBool jsval_to_opaque( JSContext *cx, jsval vp, void **out ); JSBool jsval_to_int( JSContext *cx, jsval vp, int *out); JSBool jsval_to_long( JSContext *cx, jsval vp, long *out); JSBool jsval_to_longlong( JSContext *cx, jsval vp, long long *out); - -JSBool jsval_to_CGPoint( JSContext *cx, jsval vp, cpVect *out ); - -jsval CGPoint_to_jsval( JSContext *cx, cpVect p ); - jsval int_to_jsval( JSContext *cx, int l); jsval long_to_jsval( JSContext *cx, long l); jsval longlong_to_jsval( JSContext *cx, long long l); jsval opaque_to_jsval( JSContext *cx, void* opaque); - - - JSBool jsval_to_cpBB( JSContext *cx, jsval vp, cpBB *ret ); - jsval cpBB_to_jsval(JSContext *cx, cpBB bb ); - + #ifdef __cplusplus } #endif - -#define cpVect_to_jsval CGPoint_to_jsval -#define jsval_to_cpVect jsval_to_CGPoint From 901146e2eee6c90cdba6f5208e5b0f2b0fa693f2 Mon Sep 17 00:00:00 2001 From: folecr Date: Thu, 20 Sep 2012 22:14:09 -0700 Subject: [PATCH 095/181] Synchronize cocos2dx.ini --- tools/tojs/cocos2dx.ini | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index fe721313d6..c37a6585fb 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -27,8 +27,7 @@ headers = %(cocosdir)s/cocos2dx/include/cocos2d.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^CCMenu*$". - -classes = CCSprite.* CCScene CCNode CCDirector CCLayer.* CCMenu.* CCTouch CC.*Action.* CCMove.* CCRotate.* CCBlink.* CCTint.* CCSequence CCRepeat.* CCFade.* CCEase.* CCScale.* CCTransition.* CCSpawn CCSequence CCAnimat.* CCFlip.* CCDelay.* CCSkew.* CCJump.* CCPlace.* CCShow.* CCProgress.* CCToggleVisibility.* CCHide CCParticle.* CCLabel.* CCAtlas.* CCTextureCache.* CCTexture2D CCParallaxNode CCTileMap.* CCTMX.* CCCallFunc CCRenderTexture CCGridAction CCGrid3DAction CCShaky3D CCWaves3D CCFlipX3D CCFlipY3D CCSpeed CCSet CCObject +classes = CCSprite.* CCScene CCNode CCDirector CCLayer.* CCMenu.* CCTouch CC.*Action.* CCMove.* CCRotate.* CCBlink.* CCTint.* CCSequence CCRepeat.* CCFade.* CCEase.* CCScale.* CCTransition.* CCSpawn CCSequence CCAnimat.* CCFlip.* CCDelay.* CCSkew.* CCJump.* CCPlace.* CCShow.* CCProgress.* CCPointArray CCToggleVisibility.* CCHide CCParticle.* CCLabel.* CCAtlas.* CCTextureCache.* CCTexture2D CCCardinal.* CCCatmullRom.* CCParallaxNode CCTileMap.* CCTMX.* CCCallFunc CCRenderTexture CCGridAction CCGrid3DAction CCShaky3D CCWaves3D CCFlipX3D CCFlipY3D CCSpeed CCActionManager CCSet # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -47,6 +46,8 @@ skip = CCNode::[.*Transform convertToWindowSpace getChildren getGrid setGLServer CC.*Protocol::[*], CC.*Delegate::[*], CCPoolManager::[*], + CCTexture2D::[initWithPVRTCData releaseData setTexParameters initWithData keepData], + CCSet::[begin end], CCIMEDispatcher::[*], CCSAXParser::[*], CCThread::[*], @@ -86,11 +87,14 @@ skip = CCNode::[.*Transform convertToWindowSpace getChildren getGrid setGLServer *::[copyWith.* onEnter.* onExit.* description getObjectType .*RGB.* .*HSV.*] rename_functions = CCDirector::[sharedDirector=getInstance], - CCSpriteFrameCache::[sharedSpriteFrameCache=getInstance addSpriteFramesWithFile=addSpriteFrames], + CCSpriteFrameCache::[sharedSpriteFrameCache=getInstance addSpriteFramesWithFile=addSpriteFrames spriteFrameByName=getSpriteFrame], CCMenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize fontSizeObj=fontSize fontNameObj=fontName], CCProgressTimer::[setReverseProgress=setReverseDirection], CCTextureCache::[sharedTextureCache=getInstance], CCMenuItem::[setEnabled=setIsEnabled] + CCAnimation::[addSpriteFrameWithFileName=addSpriteFrameWithFilename], + CCAnimationCache::[sharedAnimationCache=getInstance addAnimationsWithFile=addAnimations animationByName=getAnimation], + CCLayerGradient::[initWithColor=init] rename_classes = CCParticleSystemQuad::CCParticleSystem @@ -101,4 +105,5 @@ remove_prefix = CC base_objects = CCNode CCDirector # classes that create no constructor +# CCSet is special and we will use a hand-written constructor abstract_classes = CCDirector CCSpriteFrameCache CCTransitionEaseScene CCSet From 5ff4d73688f1938bec460885db479256bc1bb312 Mon Sep 17 00:00:00 2001 From: folecr Date: Thu, 20 Sep 2012 22:16:01 -0700 Subject: [PATCH 096/181] Use new directives for renaming functions and classes --- tools/tojs/cocos2dx.ini | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index c37a6585fb..32cea11f19 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -91,7 +91,7 @@ rename_functions = CCDirector::[sharedDirector=getInstance], CCMenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize fontSizeObj=fontSize fontNameObj=fontName], CCProgressTimer::[setReverseProgress=setReverseDirection], CCTextureCache::[sharedTextureCache=getInstance], - CCMenuItem::[setEnabled=setIsEnabled] + CCMenuItem::[setEnabled=setIsEnabled], CCAnimation::[addSpriteFrameWithFileName=addSpriteFrameWithFilename], CCAnimationCache::[sharedAnimationCache=getInstance addAnimationsWithFile=addAnimations animationByName=getAnimation], CCLayerGradient::[initWithColor=init] @@ -107,3 +107,5 @@ base_objects = CCNode CCDirector # classes that create no constructor # CCSet is special and we will use a hand-written constructor abstract_classes = CCDirector CCSpriteFrameCache CCTransitionEaseScene CCSet + +rename_classes = From cbade952f6b3c83a38cc24c95b75022086ca0bca Mon Sep 17 00:00:00 2001 From: folecr Date: Thu, 20 Sep 2012 22:17:32 -0700 Subject: [PATCH 097/181] Update to latest cxx-generator --- tools/cxx-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cxx-generator b/tools/cxx-generator index db61f83996..40ad79373b 160000 --- a/tools/cxx-generator +++ b/tools/cxx-generator @@ -1 +1 @@ -Subproject commit db61f8399655dd90f09d550259b45ae8289364fe +Subproject commit 40ad79373b6c041a3312afb36da6985b91f0a3dc From 12e88ac514ca1801cf4b48bc89494f7a4276353e Mon Sep 17 00:00:00 2001 From: folecr Date: Thu, 20 Sep 2012 23:12:43 -0700 Subject: [PATCH 098/181] Update 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 cae7ca0ca3..2d18305596 160000 --- a/scripting/javascript/bindings/generated +++ b/scripting/javascript/bindings/generated @@ -1 +1 @@ -Subproject commit cae7ca0ca35ec49f3d8eebe7256f7ae2bb946181 +Subproject commit 2d18305596b4da4b260bb2fd6d5ed8e878d0b129 From 78bfc2df62abc69fddd7d031185b18b113b9969c Mon Sep 17 00:00:00 2001 From: folecr Date: Fri, 21 Sep 2012 12:09:26 -0700 Subject: [PATCH 099/181] Fix spurious file introduced into makefile --- scripting/javascript/bindings/Android.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/scripting/javascript/bindings/Android.mk b/scripting/javascript/bindings/Android.mk index aa362e0fca..790f0369d3 100644 --- a/scripting/javascript/bindings/Android.mk +++ b/scripting/javascript/bindings/Android.mk @@ -9,7 +9,6 @@ LOCAL_MODULE_FILENAME := libscriptingcore-spidermonkey LOCAL_SRC_FILES := ScriptingCore.cpp \ cocos2d_specifics.cpp \ CCPhysicsSprite.cpp \ - cocos2dx.cpp \ js_manual_conversions.cpp \ cocosjs_manual_conversions.cpp \ js_bindings_chipmunk_manual.cpp \ From ad5b68784875e8ab8fb0a4a749d38636d3e18c44 Mon Sep 17 00:00:00 2001 From: jzgenius Date: Sat, 22 Sep 2012 13:16:23 +0800 Subject: [PATCH 100/181] [lib] New libcurl.a, armv7 & armv7s & simulator Supported. --- .../platform/third_party/ios/libraries/libcurl.a.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/platform/third_party/ios/libraries/libcurl.a.REMOVED.git-id b/cocos2dx/platform/third_party/ios/libraries/libcurl.a.REMOVED.git-id index 3d6bfa8e42..046fd56b68 100644 --- a/cocos2dx/platform/third_party/ios/libraries/libcurl.a.REMOVED.git-id +++ b/cocos2dx/platform/third_party/ios/libraries/libcurl.a.REMOVED.git-id @@ -1 +1 @@ -fdac5aed5e10f452a833652c4ad04a9833494542 \ No newline at end of file +8bc29b211f581ad43a042b638ad25e38766b8e0e \ No newline at end of file From 68f38914b17fa604f360806fc12cb4a1de21ade6 Mon Sep 17 00:00:00 2001 From: Byung Choi Date: Sat, 22 Sep 2012 17:36:36 +0900 Subject: [PATCH 101/181] fixes #1359 , MSVC's stdint absence --- cocos2dx/platform/win32/CCStdC.h | 6 + cocos2dx/platform/win32/compat/stdint.h | 247 ++++++++++++++++++++++++ 2 files changed, 253 insertions(+) create mode 100644 cocos2dx/platform/win32/compat/stdint.h diff --git a/cocos2dx/platform/win32/CCStdC.h b/cocos2dx/platform/win32/CCStdC.h index 6c310f6643..8e05aceaf9 100644 --- a/cocos2dx/platform/win32/CCStdC.h +++ b/cocos2dx/platform/win32/CCStdC.h @@ -50,6 +50,12 @@ THE SOFTWARE. #define MIN min #define MAX max +#if _MSC_VER >= 1600 + #include +#else + #include "./compat/stdint.h" +#endif + // Structure timeval has define in winsock.h, include windows.h for it. #include diff --git a/cocos2dx/platform/win32/compat/stdint.h b/cocos2dx/platform/win32/compat/stdint.h new file mode 100644 index 0000000000..c66fbb817c --- /dev/null +++ b/cocos2dx/platform/win32/compat/stdint.h @@ -0,0 +1,247 @@ +// ISO C9x compliant stdint.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006-2008 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_STDINT_H_ // [ +#define _MSC_STDINT_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +// For Visual Studio 6 in C++ mode and for many Visual Studio versions when +// compiling for ARM we should wrap include with 'extern "C++" {}' +// or compiler give many errors like this: +// error C2733: second C linkage of overloaded function 'wmemchr' not allowed +#ifdef __cplusplus +extern "C" { +#endif +# include +#ifdef __cplusplus +} +#endif + +// Define _W64 macros to mark types changing their size, like intptr_t. +#ifndef _W64 +# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 +# define _W64 __w64 +# else +# define _W64 +# endif +#endif + + +// 7.18.1 Integer types + +// 7.18.1.1 Exact-width integer types + +// Visual Studio 6 and Embedded Visual C++ 4 doesn't +// realize that, e.g. char has the same size as __int8 +// so we give up on __intX for them. +#if (_MSC_VER < 1300) + typedef signed char int8_t; + typedef signed short int16_t; + typedef signed int int32_t; + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; +#else + typedef signed __int8 int8_t; + typedef signed __int16 int16_t; + typedef signed __int32 int32_t; + typedef unsigned __int8 uint8_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int32 uint32_t; +#endif +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; + + +// 7.18.1.2 Minimum-width integer types +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; + +// 7.18.1.3 Fastest minimum-width integer types +typedef int8_t int_fast8_t; +typedef int16_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef int64_t int_fast64_t; +typedef uint8_t uint_fast8_t; +typedef uint16_t uint_fast16_t; +typedef uint32_t uint_fast32_t; +typedef uint64_t uint_fast64_t; + +// 7.18.1.4 Integer types capable of holding object pointers +#ifdef _WIN64 // [ + typedef signed __int64 intptr_t; + typedef unsigned __int64 uintptr_t; +#else // _WIN64 ][ + typedef _W64 signed int intptr_t; + typedef _W64 unsigned int uintptr_t; +#endif // _WIN64 ] + +// 7.18.1.5 Greatest-width integer types +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; + + +// 7.18.2 Limits of specified-width integer types + +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 + +// 7.18.2.1 Limits of exact-width integer types +#define INT8_MIN ((int8_t)_I8_MIN) +#define INT8_MAX _I8_MAX +#define INT16_MIN ((int16_t)_I16_MIN) +#define INT16_MAX _I16_MAX +#define INT32_MIN ((int32_t)_I32_MIN) +#define INT32_MAX _I32_MAX +#define INT64_MIN ((int64_t)_I64_MIN) +#define INT64_MAX _I64_MAX +#define UINT8_MAX _UI8_MAX +#define UINT16_MAX _UI16_MAX +#define UINT32_MAX _UI32_MAX +#define UINT64_MAX _UI64_MAX + +// 7.18.2.2 Limits of minimum-width integer types +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MIN INT64_MIN +#define INT_LEAST64_MAX INT64_MAX +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +// 7.18.2.3 Limits of fastest minimum-width integer types +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MIN INT64_MIN +#define INT_FAST64_MAX INT64_MAX +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX + +// 7.18.2.4 Limits of integer types capable of holding object pointers +#ifdef _WIN64 // [ +# define INTPTR_MIN INT64_MIN +# define INTPTR_MAX INT64_MAX +# define UINTPTR_MAX UINT64_MAX +#else // _WIN64 ][ +# define INTPTR_MIN INT32_MIN +# define INTPTR_MAX INT32_MAX +# define UINTPTR_MAX UINT32_MAX +#endif // _WIN64 ] + +// 7.18.2.5 Limits of greatest-width integer types +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +// 7.18.3 Limits of other integer types + +#ifdef _WIN64 // [ +# define PTRDIFF_MIN _I64_MIN +# define PTRDIFF_MAX _I64_MAX +#else // _WIN64 ][ +# define PTRDIFF_MIN _I32_MIN +# define PTRDIFF_MAX _I32_MAX +#endif // _WIN64 ] + +#define SIG_ATOMIC_MIN INT_MIN +#define SIG_ATOMIC_MAX INT_MAX + +#ifndef SIZE_MAX // [ +# ifdef _WIN64 // [ +# define SIZE_MAX _UI64_MAX +# else // _WIN64 ][ +# define SIZE_MAX _UI32_MAX +# endif // _WIN64 ] +#endif // SIZE_MAX ] + +// WCHAR_MIN and WCHAR_MAX are also defined in +#ifndef WCHAR_MIN // [ +# define WCHAR_MIN 0 +#endif // WCHAR_MIN ] +#ifndef WCHAR_MAX // [ +# define WCHAR_MAX _UI16_MAX +#endif // WCHAR_MAX ] + +#define WINT_MIN 0 +#define WINT_MAX _UI16_MAX + +#endif // __STDC_LIMIT_MACROS ] + + +// 7.18.4 Limits of other integer types + +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 + +// 7.18.4.1 Macros for minimum-width integer constants + +#define INT8_C(val) val##i8 +#define INT16_C(val) val##i16 +#define INT32_C(val) val##i32 +#define INT64_C(val) val##i64 + +#define UINT8_C(val) val##ui8 +#define UINT16_C(val) val##ui16 +#define UINT32_C(val) val##ui32 +#define UINT64_C(val) val##ui64 + +// 7.18.4.2 Macros for greatest-width integer constants +#define INTMAX_C INT64_C +#define UINTMAX_C UINT64_C + +#endif // __STDC_CONSTANT_MACROS ] + + +#endif // _MSC_STDINT_H_ ] From 7b9c15176e79c9f4186a936808a60997280361f6 Mon Sep 17 00:00:00 2001 From: ncrothe Date: Sat, 22 Sep 2012 17:45:02 +0300 Subject: [PATCH 102/181] Update extensions/network/HttpRequest.h --- extensions/network/HttpRequest.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/extensions/network/HttpRequest.h b/extensions/network/HttpRequest.h index 89c1a3f812..ef4ca4a3a0 100644 --- a/extensions/network/HttpRequest.h +++ b/extensions/network/HttpRequest.h @@ -175,7 +175,20 @@ public: { return _pSelector; } - + + /** Set any custom headers **/ + inline void setHeaders(std::vector pHeaders) + { + _headers=pHeaders; + } + + /** Get custom headers **/ + inline std::vector getHeaders() + { + return _headers; + } + + protected: // properties HttpRequestType _requestType; /// kHttpRequestGet, kHttpRequestPost or other enums @@ -185,6 +198,7 @@ protected: cocos2d::CCObject* _pTarget; /// callback target of pSelector function cocos2d::SEL_CallFuncND _pSelector; /// callback function, e.g. MyLayer::onHttpResponse(CCObject *sender, void *data) void* _pUserData; /// You can add your customed data here + std::vector _headers; /// custom http headers }; NS_CC_EXT_END From b3f5a04ad426acdf90ec353e73302a1c75bacf14 Mon Sep 17 00:00:00 2001 From: ncrothe Date: Sat, 22 Sep 2012 17:52:04 +0300 Subject: [PATCH 103/181] Update extensions/network/HttpClient.cpp Added custom header capability to http wrapper (using curl features). This allows setting non-default content-type for POSTs. --- extensions/network/HttpClient.cpp | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/extensions/network/HttpClient.cpp b/extensions/network/HttpClient.cpp index 1fa241540c..d40c6d0d41 100644 --- a/extensions/network/HttpClient.cpp +++ b/extensions/network/HttpClient.cpp @@ -246,6 +246,25 @@ int processGetTask(CCHttpRequest *request, write_callback callback, void *stream break; } + /* handle custom header data */ + /* create curl linked list */ + struct curl_slist *cHeaders=NULL; + /* get custom header data (if set) */ + std::vector headers=request->getHeaders(); + if(!headers.empty()) + { + for(std::vector::iterator it=headers.begin();it!=headers.end();it++) + { + /* append custom headers one by one */ + cHeaders=curl_slist_append(cHeaders,it->c_str()); + } + /* set custom headers for curl */ + code = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, cHeaders); + if (code != CURLE_OK) { + break; + } + } + code = curl_easy_setopt(curl, CURLOPT_URL, request->getUrl()); if (code != CURLE_OK) { @@ -276,6 +295,9 @@ int processGetTask(CCHttpRequest *request, write_callback callback, void *stream break; } + /* free the linked list for header data */ + curl_slist_free_all(cHeaders); + code = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, responseCode); if (code != CURLE_OK || *responseCode != 200) { @@ -301,6 +323,25 @@ int processPostTask(CCHttpRequest *request, write_callback callback, void *strea break; } + /* handle custom header data */ + /* create curl linked list */ + struct curl_slist *cHeaders=NULL; + /* get custom header data (if set) */ + std::vector headers=request->getHeaders(); + if(!headers.empty()) + { + for(std::vector::iterator it=headers.begin();it!=headers.end();it++) + { + /* append custom headers one by one */ + cHeaders=curl_slist_append(cHeaders,it->c_str()); + } + /* set custom headers for curl */ + code = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, cHeaders); + if (code != CURLE_OK) { + break; + } + } + code = curl_easy_setopt(curl, CURLOPT_URL, request->getUrl()); if (code != CURLE_OK) { break; @@ -330,6 +371,9 @@ int processPostTask(CCHttpRequest *request, write_callback callback, void *strea break; } + /* free the linked list for header data */ + curl_slist_free_all(cHeaders); + code = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, responseCode); if (code != CURLE_OK || *responseCode != 200) { code = CURLE_HTTP_RETURNED_ERROR; From dec9fff7a7115f322f308b0c5a2634927a8d6fc2 Mon Sep 17 00:00:00 2001 From: Donald Alan Morrison Date: Sat, 22 Sep 2012 20:56:10 -0700 Subject: [PATCH 104/181] UITextAlignment deprecated for NSTextAlignment. UITextAlignment on NSTextAlignment is injective, not surjective. There is an equivalence relationship for a subset of NSTextAlignment. http://en.wikipedia.org/wiki/One-to-one_function --- cocos2dx/platform/ios/FontLabel/FontLabel.m | 11 +++++++---- .../platform/ios/FontLabel/FontLabelStringDrawing.m | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/cocos2dx/platform/ios/FontLabel/FontLabel.m b/cocos2dx/platform/ios/FontLabel/FontLabel.m index 3e7ac0e323..1e97d650d9 100644 --- a/cocos2dx/platform/ios/FontLabel/FontLabel.m +++ b/cocos2dx/platform/ios/FontLabel/FontLabel.m @@ -118,15 +118,18 @@ } size.width = MIN(size.width, origSize.width); // adjust the point for alignment - switch (self.textAlignment) { - case UITextAlignmentLeft: + switch ((NSTextAlignment)self.textAlignment) { + case NSTextAlignmentLeft: break; - case UITextAlignmentCenter: + case NSTextAlignmentCenter: point.x += (origSize.width - size.width) / 2.0f; break; - case UITextAlignmentRight: + case NSTextAlignmentRight: point.x += origSize.width - size.width; break; + case NSTextAlignmentJustified: + case NSTextAlignmentNatural: + default: break; } [self.text drawAtPoint:point forWidth:size.width withZFont:actualFont lineBreakMode:self.lineBreakMode]; } else { diff --git a/cocos2dx/platform/ios/FontLabel/FontLabelStringDrawing.m b/cocos2dx/platform/ios/FontLabel/FontLabelStringDrawing.m index 8884fa468d..bad5abd028 100644 --- a/cocos2dx/platform/ios/FontLabel/FontLabelStringDrawing.m +++ b/cocos2dx/platform/ios/FontLabel/FontLabelStringDrawing.m @@ -637,16 +637,19 @@ static CGSize drawOrSizeTextConstrainedToSize(BOOL performDraw, NSString *string // draw if (performDraw) { - switch (alignment) { - case UITextAlignmentLeft: + switch ((NSTextAlignment)alignment) { + case NSTextAlignmentLeft: drawPoint.x = 0; break; - case UITextAlignmentCenter: + case NSTextAlignmentCenter: drawPoint.x = (constrainedSize.width - lineSize.width) / 2.0f; break; - case UITextAlignmentRight: + case NSTextAlignmentRight: drawPoint.x = constrainedSize.width - lineSize.width; break; + case NSTextAlignmentJustified: + case NSTextAlignmentNatural: + default: break; } NSUInteger stopGlyphIdx = glyphIdx; NSUInteger lastRunIdx = currentRunIdx; From b69913356777d0309ee44a5790dbc8f8dfe0b1b2 Mon Sep 17 00:00:00 2001 From: Donald Alan Morrison Date: Sat, 22 Sep 2012 21:02:46 -0700 Subject: [PATCH 105/181] Merge with upstream re: tools/cxx-generator subproject commit. --- tools/cxx-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cxx-generator b/tools/cxx-generator index db61f83996..5154f8898b 160000 --- a/tools/cxx-generator +++ b/tools/cxx-generator @@ -1 +1 @@ -Subproject commit db61f8399655dd90f09d550259b45ae8289364fe +Subproject commit 5154f8898bb8755bda496a84fa39abe97d6a9b44 From 88b98faa883db9b78a26b7fc2d1315825dacdbdc Mon Sep 17 00:00:00 2001 From: Walzer Date: Sun, 23 Sep 2012 20:24:51 +0800 Subject: [PATCH 106/181] fixed #1482, fix orientation problem caused by ios6 api change. AppDelegate.mm & RootViewController.mm are updated. --- cocos2dx/platform/ios/FontLabel/FontLabel.m | 3 +++ .../ios/FontLabel/FontLabelStringDrawing.m | 3 +++ samples/HelloCpp/proj.ios/AppController.mm | 12 +++++++++++- .../proj.ios/HelloCpp.xcodeproj/project.pbxproj | 13 +++++++++---- samples/HelloCpp/proj.ios/RootViewController.mm | 10 ++++++++++ samples/HelloLua/proj.ios/AppController.mm | 12 +++++++++++- .../proj.ios/HelloLua.xcodeproj/project.pbxproj | 4 ++++ samples/HelloLua/proj.ios/RootViewController.mm | 10 ++++++++++ samples/SimpleGame/proj.ios/AppController.mm | 12 +++++++++++- samples/SimpleGame/proj.ios/RootViewController.mm | 10 ++++++++++ .../proj.ios/SimpleGame.xcodeproj/project.pbxproj | 4 ++++ .../proj.ios/Classes/RootViewController.mm | 10 ++++++++++ .../TestCpp/proj.ios/Classes/testsAppDelegate.mm | 12 +++++++++++- .../project.pbxproj.REMOVED.git-id | 2 +- samples/TestJavascript/proj.ios/AppController.mm | 12 +++++++++++- .../TestJavascript/proj.ios/RootViewController.mm | 15 +++++++++++---- .../TestJavascript.xcodeproj/project.pbxproj | 2 +- samples/TestLua/proj.ios/AppController.mm | 12 +++++++++++- samples/TestLua/proj.ios/RootViewController.mm | 10 ++++++++++ .../proj.ios/TestLua.xcodeproj/project.pbxproj | 4 ++++ .../cocos2dx.xctemplate/ios/AppController.mm | 12 +++++++++++- .../cocos2dx.xctemplate/ios/RootViewController.mm | 15 +++++++++++---- .../ios/AppController.mm | 12 +++++++++++- .../ios/RootViewController.mm | 15 +++++++++++---- .../ios/AppController.mm | 12 +++++++++++- .../ios/RootViewController.mm | 15 +++++++++++---- .../cocos2dx_js.xctemplate/ios/AppController.mm | 12 +++++++++++- .../ios/RootViewController.mm | 10 ++++++++++ .../cocos2dx_lua.xctemplate/ios/AppController.mm | 12 +++++++++++- .../ios/RootViewController.mm | 10 ++++++++++ 30 files changed, 264 insertions(+), 33 deletions(-) diff --git a/cocos2dx/platform/ios/FontLabel/FontLabel.m b/cocos2dx/platform/ios/FontLabel/FontLabel.m index 3e7ac0e323..820113779e 100644 --- a/cocos2dx/platform/ios/FontLabel/FontLabel.m +++ b/cocos2dx/platform/ios/FontLabel/FontLabel.m @@ -127,6 +127,9 @@ case UITextAlignmentRight: point.x += origSize.width - size.width; break; + default: + // NSTextAlignmentJustified and NSTextAlignmentNatural are not handled here + break; } [self.text drawAtPoint:point forWidth:size.width withZFont:actualFont lineBreakMode:self.lineBreakMode]; } else { diff --git a/cocos2dx/platform/ios/FontLabel/FontLabelStringDrawing.m b/cocos2dx/platform/ios/FontLabel/FontLabelStringDrawing.m index 8884fa468d..2a975aeb6a 100644 --- a/cocos2dx/platform/ios/FontLabel/FontLabelStringDrawing.m +++ b/cocos2dx/platform/ios/FontLabel/FontLabelStringDrawing.m @@ -647,6 +647,9 @@ static CGSize drawOrSizeTextConstrainedToSize(BOOL performDraw, NSString *string case UITextAlignmentRight: drawPoint.x = constrainedSize.width - lineSize.width; break; + default: + // NSTextAlignmentJuestified and NSTextAlignmentNatural are not handled here + break; } NSUInteger stopGlyphIdx = glyphIdx; NSUInteger lastRunIdx = currentRunIdx; diff --git a/samples/HelloCpp/proj.ios/AppController.mm b/samples/HelloCpp/proj.ios/AppController.mm index db16a9024e..4f375d9efd 100644 --- a/samples/HelloCpp/proj.ios/AppController.mm +++ b/samples/HelloCpp/proj.ios/AppController.mm @@ -57,7 +57,17 @@ static AppDelegate s_sharedApplication; viewController.view = __glView; // Set RootViewController to window - [window addSubview: viewController.view]; + if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) + { + // warning: addSubView doesn't work on iOS6 + [window addSubview: viewController.view]; + } + else + { + // use this mehod on ios6 + [window setRootViewController:viewController]; + } + [window makeKeyAndVisible]; [[UIApplication sharedApplication] setStatusBarHidden: YES]; diff --git a/samples/HelloCpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj b/samples/HelloCpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj index afc3f37ae1..b3a98f857d 100644 --- a/samples/HelloCpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj +++ b/samples/HelloCpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 45; + objectVersion = 46; objects = { /* Begin PBXBuildFile section */ @@ -22,6 +22,7 @@ BF23D4E8143315EB00657E08 /* HelloWorldScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BF23D4E5143315EB00657E08 /* HelloWorldScene.cpp */; }; BF365AA812A103F70050DCF4 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF365AA712A103F70050DCF4 /* AppController.mm */; }; BF4DE6AD138BB89600CF907D /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF4DE6AC138BB89600CF907D /* RootViewController.mm */; }; + D41A0A92160F1229004552AE /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D41A0A91160F1229004552AE /* Default-568h@2x.png */; }; D4ABB4B313B4395300552E6E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D4ABB4B213B4395300552E6E /* main.m */; }; D4EF94E815BD319200D803EB /* Icon-57.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF94E715BD319200D803EB /* Icon-57.png */; }; D4EF94EA15BD319500D803EB /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF94E915BD319500D803EB /* Icon-114.png */; }; @@ -70,6 +71,7 @@ BF492D4B1289302400A09262 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; BF4DE6AB138BB89600CF907D /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; BF4DE6AC138BB89600CF907D /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; + D41A0A91160F1229004552AE /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; D4ABB4B213B4395300552E6E /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; D4EF94E715BD319200D803EB /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-57.png"; path = "../proj.ios/Icon-57.png"; sourceTree = ""; }; D4EF94E915BD319500D803EB /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-114.png"; path = "../proj.ios/Icon-114.png"; sourceTree = ""; }; @@ -115,6 +117,7 @@ 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { isa = PBXGroup; children = ( + D41A0A91160F1229004552AE /* Default-568h@2x.png */, 154269C815B5644500712A7F /* cocos2dx.xcodeproj */, BF23D4E2143315EB00657E08 /* Classes */, 29B97323FDCFA39411CA2CEA /* Frameworks */, @@ -207,8 +210,11 @@ /* Begin PBXProject section */ 29B97313FDCFA39411CA2CEA /* Project object */ = { isa = PBXProject; + attributes = { + LastUpgradeCheck = 0450; + }; buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloCpp" */; - compatibilityVersion = "Xcode 3.1"; + compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( @@ -254,6 +260,7 @@ D4EF94EE15BD319D00D803EB /* Icon-144.png in Resources */, 15003FA315D2601D00B6775A /* iphone in Resources */, 15003FA515D2602400B6775A /* iphonehd in Resources */, + D41A0A92160F1229004552AE /* Default-568h@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -364,7 +371,6 @@ GCC_VERSION = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - PREBINDING = NO; SDKROOT = iphoneos; VALID_ARCHS = "armv6 armv7 i386"; }; @@ -380,7 +386,6 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; - PREBINDING = NO; SDKROOT = iphoneos; VALID_ARCHS = "armv6 armv7 i386"; }; diff --git a/samples/HelloCpp/proj.ios/RootViewController.mm b/samples/HelloCpp/proj.ios/RootViewController.mm index c1c841078d..fee0d0c071 100644 --- a/samples/HelloCpp/proj.ios/RootViewController.mm +++ b/samples/HelloCpp/proj.ios/RootViewController.mm @@ -52,10 +52,20 @@ */ // Override to allow orientations other than the default portrait orientation. +// This method is deprecated on ios6 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape( interfaceOrientation ); } +// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead +- (NSUInteger) supportedInterfaceOrientations{ + return UIInterfaceOrientationMaskLandscape; +} + +- (BOOL) shouldAutorotate { + return YES; +} + - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; diff --git a/samples/HelloLua/proj.ios/AppController.mm b/samples/HelloLua/proj.ios/AppController.mm index ef4552b40d..051b8b1735 100644 --- a/samples/HelloLua/proj.ios/AppController.mm +++ b/samples/HelloLua/proj.ios/AppController.mm @@ -57,7 +57,17 @@ static AppDelegate s_sharedApplication; viewController.view = __glView; // Set RootViewController to window - [window addSubview: viewController.view]; + if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) + { + // warning: addSubView doesn't work on iOS6 + [window addSubview: viewController.view]; + } + else + { + // use this mehod on ios6 + [window setRootViewController:viewController]; + } + [window makeKeyAndVisible]; [[UIApplication sharedApplication] setStatusBarHidden: YES]; diff --git a/samples/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj b/samples/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj index 645ac8e7ea..c3e2d3a7b4 100644 --- a/samples/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj +++ b/samples/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj @@ -30,6 +30,7 @@ BF82F42113A8652A00616D55 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF82F41F13A8652A00616D55 /* AppController.mm */; }; BF82F42213A8652A00616D55 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BF82F42013A8652A00616D55 /* main.m */; }; D403B5D9135D1AF1004B518D /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D403B5D8135D1AF1004B518D /* libxml2.dylib */; }; + D41A0AA2160F13F8004552AE /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D41A0AA1160F13F8004552AE /* Default-568h@2x.png */; }; D4CEAD7913B4634300780515 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = D4CEAD7713B4634300780515 /* RootViewController.mm */; }; D4EF94D715BD311700D803EB /* Icon-57.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF94D615BD311700D803EB /* Icon-57.png */; }; D4EF94D915BD311A00D803EB /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF94D815BD311A00D803EB /* Icon-114.png */; }; @@ -138,6 +139,7 @@ BF82F42013A8652A00616D55 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; BF82F42313A8654600616D55 /* HelloLua_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelloLua_Prefix.pch; sourceTree = ""; }; D403B5D8135D1AF1004B518D /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; }; + D41A0AA1160F13F8004552AE /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; D4CEAD7713B4634300780515 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; D4CEAD7813B4634300780515 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; D4EF94D615BD311700D803EB /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-57.png"; path = "../proj.ios/Icon-57.png"; sourceTree = ""; }; @@ -301,6 +303,7 @@ 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { isa = PBXGroup; children = ( + D41A0AA1160F13F8004552AE /* Default-568h@2x.png */, 15426A2B15B571B300712A7F /* cocos2dx.xcodeproj */, BF82F41413A864B000616D55 /* Classes */, 15426A3715B5722100712A7F /* CocosDenshion */, @@ -588,6 +591,7 @@ D4EF94D915BD311A00D803EB /* Icon-114.png in Resources */, D4EF94DB15BD311E00D803EB /* Icon-72.png in Resources */, D4EF94DD15BD312100D803EB /* Icon-144.png in Resources */, + D41A0AA2160F13F8004552AE /* Default-568h@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/samples/HelloLua/proj.ios/RootViewController.mm b/samples/HelloLua/proj.ios/RootViewController.mm index c1c841078d..fee0d0c071 100644 --- a/samples/HelloLua/proj.ios/RootViewController.mm +++ b/samples/HelloLua/proj.ios/RootViewController.mm @@ -52,10 +52,20 @@ */ // Override to allow orientations other than the default portrait orientation. +// This method is deprecated on ios6 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape( interfaceOrientation ); } +// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead +- (NSUInteger) supportedInterfaceOrientations{ + return UIInterfaceOrientationMaskLandscape; +} + +- (BOOL) shouldAutorotate { + return YES; +} + - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; diff --git a/samples/SimpleGame/proj.ios/AppController.mm b/samples/SimpleGame/proj.ios/AppController.mm index db16a9024e..4f375d9efd 100644 --- a/samples/SimpleGame/proj.ios/AppController.mm +++ b/samples/SimpleGame/proj.ios/AppController.mm @@ -57,7 +57,17 @@ static AppDelegate s_sharedApplication; viewController.view = __glView; // Set RootViewController to window - [window addSubview: viewController.view]; + if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) + { + // warning: addSubView doesn't work on iOS6 + [window addSubview: viewController.view]; + } + else + { + // use this mehod on ios6 + [window setRootViewController:viewController]; + } + [window makeKeyAndVisible]; [[UIApplication sharedApplication] setStatusBarHidden: YES]; diff --git a/samples/SimpleGame/proj.ios/RootViewController.mm b/samples/SimpleGame/proj.ios/RootViewController.mm index c1c841078d..fee0d0c071 100644 --- a/samples/SimpleGame/proj.ios/RootViewController.mm +++ b/samples/SimpleGame/proj.ios/RootViewController.mm @@ -52,10 +52,20 @@ */ // Override to allow orientations other than the default portrait orientation. +// This method is deprecated on ios6 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape( interfaceOrientation ); } +// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead +- (NSUInteger) supportedInterfaceOrientations{ + return UIInterfaceOrientationMaskLandscape; +} + +- (BOOL) shouldAutorotate { + return YES; +} + - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; diff --git a/samples/SimpleGame/proj.ios/SimpleGame.xcodeproj/project.pbxproj b/samples/SimpleGame/proj.ios/SimpleGame.xcodeproj/project.pbxproj index d894afef52..2d38dbc116 100644 --- a/samples/SimpleGame/proj.ios/SimpleGame.xcodeproj/project.pbxproj +++ b/samples/SimpleGame/proj.ios/SimpleGame.xcodeproj/project.pbxproj @@ -19,6 +19,7 @@ BF23D4E8143315EB00657E08 /* HelloWorldScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BF23D4E5143315EB00657E08 /* HelloWorldScene.cpp */; }; BF365AA812A103F70050DCF4 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF365AA712A103F70050DCF4 /* AppController.mm */; }; BF4DE6AD138BB89600CF907D /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF4DE6AC138BB89600CF907D /* RootViewController.mm */; }; + D41A0AC6160F14F5004552AE /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D41A0AC5160F14F5004552AE /* Default-568h@2x.png */; }; D4ABB4B313B4395300552E6E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D4ABB4B213B4395300552E6E /* main.m */; }; D4E6BC8515FCB4A4008BF525 /* libcocos2dx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D4E6BC8315FCB477008BF525 /* libcocos2dx.a */; }; D4E6BC9215FCB5BA008BF525 /* GameOverScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D4E6BC9015FCB5BA008BF525 /* GameOverScene.cpp */; }; @@ -71,6 +72,7 @@ BF492D4B1289302400A09262 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; BF4DE6AB138BB89600CF907D /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; BF4DE6AC138BB89600CF907D /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; + D41A0AC5160F14F5004552AE /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; D4ABB4B213B4395300552E6E /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; D4E6BC7B15FCB477008BF525 /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = ""; }; D4E6BC9015FCB5BA008BF525 /* GameOverScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GameOverScene.cpp; sourceTree = ""; }; @@ -130,6 +132,7 @@ 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { isa = PBXGroup; children = ( + D41A0AC5160F14F5004552AE /* Default-568h@2x.png */, D4E6BC7B15FCB477008BF525 /* cocos2dx.xcodeproj */, BF23D4E2143315EB00657E08 /* Classes */, 29B97323FDCFA39411CA2CEA /* Frameworks */, @@ -320,6 +323,7 @@ D4E6BCC915FCB6AA008BF525 /* hd in Resources */, D4E6BCCA15FCB6AA008BF525 /* pew-pew-lei.wav in Resources */, D4E6BCCB15FCB6AA008BF525 /* sd in Resources */, + D41A0AC6160F14F5004552AE /* Default-568h@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/samples/TestCpp/proj.ios/Classes/RootViewController.mm b/samples/TestCpp/proj.ios/Classes/RootViewController.mm index bd9b273710..7e47e134a8 100644 --- a/samples/TestCpp/proj.ios/Classes/RootViewController.mm +++ b/samples/TestCpp/proj.ios/Classes/RootViewController.mm @@ -35,10 +35,20 @@ */ // Override to allow orientations other than the default portrait orientation. +// This method is deprecated on ios6 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape( interfaceOrientation ); } +// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead +- (NSUInteger) supportedInterfaceOrientations{ + return UIInterfaceOrientationMaskLandscape; +} + +- (BOOL) shouldAutorotate { + return YES; +} + - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; diff --git a/samples/TestCpp/proj.ios/Classes/testsAppDelegate.mm b/samples/TestCpp/proj.ios/Classes/testsAppDelegate.mm index 2cfe786c29..08986589d9 100644 --- a/samples/TestCpp/proj.ios/Classes/testsAppDelegate.mm +++ b/samples/TestCpp/proj.ios/Classes/testsAppDelegate.mm @@ -44,7 +44,17 @@ static AppDelegate s_sharedApplication; viewController.view = __glView; // Set RootViewController to window - [window addSubview: viewController.view]; + if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) + { + // warning: addSubView doesn't work on iOS6 + [window addSubview: viewController.view]; + } + else + { + // use this mehod on ios6 + [window setRootViewController:viewController]; + } + [window makeKeyAndVisible]; [[UIApplication sharedApplication] setStatusBarHidden:true]; diff --git a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id index 796dd744b5..d7957fba4e 100644 --- a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -4e9a0c8b08e12b2d6d915f77e26eae289a302051 \ No newline at end of file +e652ef54a5d039edc73428b5f296f4b3ed83af7c \ No newline at end of file diff --git a/samples/TestJavascript/proj.ios/AppController.mm b/samples/TestJavascript/proj.ios/AppController.mm index 22b2e3d043..02ea9c66d1 100644 --- a/samples/TestJavascript/proj.ios/AppController.mm +++ b/samples/TestJavascript/proj.ios/AppController.mm @@ -41,7 +41,17 @@ static AppDelegate s_sharedApplication; viewController.view = __glView; // Set RootViewController to window - [window addSubview: viewController.view]; + if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) + { + // warning: addSubView doesn't work on iOS6 + [window addSubview: viewController.view]; + } + else + { + // use this mehod on ios6 + [window setRootViewController:viewController]; + } + [window makeKeyAndVisible]; [[UIApplication sharedApplication] setStatusBarHidden: YES]; diff --git a/samples/TestJavascript/proj.ios/RootViewController.mm b/samples/TestJavascript/proj.ios/RootViewController.mm index 9dda5a1846..39200bd7c3 100644 --- a/samples/TestJavascript/proj.ios/RootViewController.mm +++ b/samples/TestJavascript/proj.ios/RootViewController.mm @@ -34,12 +34,19 @@ } */ -// Override to allow orientations other than the default landscape orientation. +// Override to allow orientations other than the default portrait orientation. +// This method is deprecated on ios6 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape( interfaceOrientation ); - - // switch to this line if you want to set portrait view -// return UIInterfaceOrientationIsPortrait( interfaceOrientation ); +} + +// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead +- (NSUInteger) supportedInterfaceOrientations{ + return UIInterfaceOrientationMaskLandscape; +} + +- (BOOL) shouldAutorotate { + return YES; } - (void)didReceiveMemoryWarning { diff --git a/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj b/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj index d3b05e614b..7a2d38c9ed 100644 --- a/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj +++ b/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj @@ -486,9 +486,9 @@ A92275321517C094001B78AA = { isa = PBXGroup; children = ( + 15426AE915B5733200712A7F /* cocos2dx.xcodeproj */, 15628F5B15F0F5C2000CF24B /* Resources */, 2628297C15EC7196002C4240 /* chipmunk */, - 15426AE915B5733200712A7F /* cocos2dx.xcodeproj */, F2837A9C15B9639100A5707B /* bindings */, D4545214156E28EF00887EB5 /* Classes */, 15426FC415B5743C00712A7F /* CocosDenshion */, diff --git a/samples/TestLua/proj.ios/AppController.mm b/samples/TestLua/proj.ios/AppController.mm index 6b27e1dcc9..457a9fa0a3 100644 --- a/samples/TestLua/proj.ios/AppController.mm +++ b/samples/TestLua/proj.ios/AppController.mm @@ -57,7 +57,17 @@ static AppDelegate s_sharedApplication; viewController.view = __glView; // Set RootViewController to window - [window addSubview:__glView]; + if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) + { + // warning: addSubView doesn't work on iOS6 + [window addSubview: viewController.view]; + } + else + { + // use this mehod on ios6 + [window setRootViewController:viewController]; + } + [window makeKeyAndVisible]; [[UIApplication sharedApplication] setStatusBarHidden: YES]; diff --git a/samples/TestLua/proj.ios/RootViewController.mm b/samples/TestLua/proj.ios/RootViewController.mm index c1c841078d..fee0d0c071 100644 --- a/samples/TestLua/proj.ios/RootViewController.mm +++ b/samples/TestLua/proj.ios/RootViewController.mm @@ -52,10 +52,20 @@ */ // Override to allow orientations other than the default portrait orientation. +// This method is deprecated on ios6 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape( interfaceOrientation ); } +// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead +- (NSUInteger) supportedInterfaceOrientations{ + return UIInterfaceOrientationMaskLandscape; +} + +- (BOOL) shouldAutorotate { + return YES; +} + - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; diff --git a/samples/TestLua/proj.ios/TestLua.xcodeproj/project.pbxproj b/samples/TestLua/proj.ios/TestLua.xcodeproj/project.pbxproj index 4a9110976c..35550d4cf0 100644 --- a/samples/TestLua/proj.ios/TestLua.xcodeproj/project.pbxproj +++ b/samples/TestLua/proj.ios/TestLua.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 158B579C15EC9D86009FCBB4 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 158B579815EC9D86009FCBB4 /* Icon-72.png */; }; 158B579D15EC9D86009FCBB4 /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = 158B579915EC9D86009FCBB4 /* Icon-114.png */; }; 158B579E15EC9D86009FCBB4 /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = 158B579A15EC9D86009FCBB4 /* Icon-144.png */; }; + D41A0AE5160F1640004552AE /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D41A0AE4160F1640004552AE /* Default-568h@2x.png */; }; F293B3CD15EB7BE500256477 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F293B3CC15EB7BE500256477 /* QuartzCore.framework */; }; F293B3CF15EB7BE500256477 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F293B3CE15EB7BE500256477 /* OpenGLES.framework */; }; F293B3D115EB7BE500256477 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F293B3D015EB7BE500256477 /* OpenAL.framework */; }; @@ -130,6 +131,7 @@ 158B579815EC9D86009FCBB4 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = SOURCE_ROOT; }; 158B579915EC9D86009FCBB4 /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-114.png"; sourceTree = SOURCE_ROOT; }; 158B579A15EC9D86009FCBB4 /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-144.png"; sourceTree = SOURCE_ROOT; }; + D41A0AE4160F1640004552AE /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; F293B3C815EB7BE500256477 /* TestLua.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestLua.app; sourceTree = BUILT_PRODUCTS_DIR; }; F293B3CC15EB7BE500256477 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; F293B3CE15EB7BE500256477 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; @@ -294,6 +296,7 @@ F293B3BD15EB7BE500256477 = { isa = PBXGroup; children = ( + D41A0AE4160F1640004552AE /* Default-568h@2x.png */, F2A154E615EB8BCD00C9B0B6 /* cocos2dx.xcodeproj */, F2A1554A15EB921600C9B0B6 /* extensions */, F2A1553815EB91A000C9B0B6 /* chipmunk */, @@ -710,6 +713,7 @@ 158B579C15EC9D86009FCBB4 /* Icon-72.png in Resources */, 158B579D15EC9D86009FCBB4 /* Icon-114.png in Resources */, 158B579E15EC9D86009FCBB4 /* Icon-144.png in Resources */, + D41A0AE5160F1640004552AE /* Default-568h@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm index bf7505012c..d90eb8783c 100644 --- a/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm @@ -44,7 +44,17 @@ static AppDelegate s_sharedApplication; viewController.view = __glView; // Set RootViewController to window - [window addSubview: viewController.view]; + if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) + { + // warning: addSubView doesn't work on iOS6 + [window addSubview: viewController.view]; + } + else + { + // use this mehod on ios6 + [window setRootViewController:viewController]; + } + [window makeKeyAndVisible]; [[UIApplication sharedApplication] setStatusBarHidden: YES]; diff --git a/template/xcode4/cocos2dx.xctemplate/ios/RootViewController.mm b/template/xcode4/cocos2dx.xctemplate/ios/RootViewController.mm index c907f6adc3..7ca84275ca 100644 --- a/template/xcode4/cocos2dx.xctemplate/ios/RootViewController.mm +++ b/template/xcode4/cocos2dx.xctemplate/ios/RootViewController.mm @@ -34,12 +34,19 @@ } */ -// Override to allow orientations other than the default landscape orientation. +// Override to allow orientations other than the default portrait orientation. +// This method is deprecated on ios6 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape( interfaceOrientation ); - - // switch to this line if you want to set portrait view - // return UIInterfaceOrientationIsPortrait( interfaceOrientation ); +} + +// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead +- (NSUInteger) supportedInterfaceOrientations{ + return UIInterfaceOrientationMaskLandscape; +} + +- (BOOL) shouldAutorotate { + return YES; } - (void)didReceiveMemoryWarning { diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm index a9bf46f84a..3d41726fb2 100644 --- a/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm @@ -44,7 +44,17 @@ static AppDelegate s_sharedApplication; viewController.view = __glView; // Set RootViewController to window - [window addSubview:__glView]; + if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) + { + // warning: addSubView doesn't work on iOS6 + [window addSubview: viewController.view]; + } + else + { + // use this mehod on ios6 + [window setRootViewController:viewController]; + } + [window makeKeyAndVisible]; [[UIApplication sharedApplication] setStatusBarHidden: YES]; diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/ios/RootViewController.mm b/template/xcode4/cocos2dx_box2d.xctemplate/ios/RootViewController.mm index c907f6adc3..7ca84275ca 100644 --- a/template/xcode4/cocos2dx_box2d.xctemplate/ios/RootViewController.mm +++ b/template/xcode4/cocos2dx_box2d.xctemplate/ios/RootViewController.mm @@ -34,12 +34,19 @@ } */ -// Override to allow orientations other than the default landscape orientation. +// Override to allow orientations other than the default portrait orientation. +// This method is deprecated on ios6 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape( interfaceOrientation ); - - // switch to this line if you want to set portrait view - // return UIInterfaceOrientationIsPortrait( interfaceOrientation ); +} + +// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead +- (NSUInteger) supportedInterfaceOrientations{ + return UIInterfaceOrientationMaskLandscape; +} + +- (BOOL) shouldAutorotate { + return YES; } - (void)didReceiveMemoryWarning { diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm index da90ebfae0..f9311ead79 100644 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm @@ -44,7 +44,17 @@ static AppDelegate s_sharedApplication; viewController.view = __glView; // Set RootViewController to window - [window addSubview:__glView]; + if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) + { + // warning: addSubView doesn't work on iOS6 + [window addSubview: viewController.view]; + } + else + { + // use this mehod on ios6 + [window setRootViewController:viewController]; + } + [window makeKeyAndVisible]; [[UIApplication sharedApplication] setStatusBarHidden: YES]; diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/RootViewController.mm b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/RootViewController.mm index c907f6adc3..7ca84275ca 100644 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/RootViewController.mm +++ b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/RootViewController.mm @@ -34,12 +34,19 @@ } */ -// Override to allow orientations other than the default landscape orientation. +// Override to allow orientations other than the default portrait orientation. +// This method is deprecated on ios6 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape( interfaceOrientation ); - - // switch to this line if you want to set portrait view - // return UIInterfaceOrientationIsPortrait( interfaceOrientation ); +} + +// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead +- (NSUInteger) supportedInterfaceOrientations{ + return UIInterfaceOrientationMaskLandscape; +} + +- (BOOL) shouldAutorotate { + return YES; } - (void)didReceiveMemoryWarning { diff --git a/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm index 82acce0269..f9311ead79 100644 --- a/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm @@ -44,7 +44,17 @@ static AppDelegate s_sharedApplication; viewController.view = __glView; // Set RootViewController to window - [window addSubview: viewController.view]; + if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) + { + // warning: addSubView doesn't work on iOS6 + [window addSubview: viewController.view]; + } + else + { + // use this mehod on ios6 + [window setRootViewController:viewController]; + } + [window makeKeyAndVisible]; [[UIApplication sharedApplication] setStatusBarHidden: YES]; diff --git a/template/xcode4/cocos2dx_js.xctemplate/ios/RootViewController.mm b/template/xcode4/cocos2dx_js.xctemplate/ios/RootViewController.mm index c1c841078d..fee0d0c071 100644 --- a/template/xcode4/cocos2dx_js.xctemplate/ios/RootViewController.mm +++ b/template/xcode4/cocos2dx_js.xctemplate/ios/RootViewController.mm @@ -52,10 +52,20 @@ */ // Override to allow orientations other than the default portrait orientation. +// This method is deprecated on ios6 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape( interfaceOrientation ); } +// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead +- (NSUInteger) supportedInterfaceOrientations{ + return UIInterfaceOrientationMaskLandscape; +} + +- (BOOL) shouldAutorotate { + return YES; +} + - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; diff --git a/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm index a9cd27a2fe..e218764675 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm +++ b/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm @@ -60,7 +60,17 @@ static AppDelegate s_sharedApplication; viewController.view = __glView; // Set RootViewController to window - [window addSubview:__glView]; + if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) + { + // warning: addSubView doesn't work on iOS6 + [window addSubview: viewController.view]; + } + else + { + // use this mehod on ios6 + [window setRootViewController:viewController]; + } + [window makeKeyAndVisible]; [[UIApplication sharedApplication] setStatusBarHidden: YES]; diff --git a/template/xcode4/cocos2dx_lua.xctemplate/ios/RootViewController.mm b/template/xcode4/cocos2dx_lua.xctemplate/ios/RootViewController.mm index c1c841078d..fee0d0c071 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/ios/RootViewController.mm +++ b/template/xcode4/cocos2dx_lua.xctemplate/ios/RootViewController.mm @@ -52,10 +52,20 @@ */ // Override to allow orientations other than the default portrait orientation. +// This method is deprecated on ios6 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape( interfaceOrientation ); } +// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead +- (NSUInteger) supportedInterfaceOrientations{ + return UIInterfaceOrientationMaskLandscape; +} + +- (BOOL) shouldAutorotate { + return YES; +} + - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; From 8d51c0ed1901eb26f860f63fc7f6b6a65de792fe Mon Sep 17 00:00:00 2001 From: Walzer Date: Sun, 23 Sep 2012 22:11:29 +0800 Subject: [PATCH 107/181] fixed #1482, deal with ios6 orientation in templates/xcode4, with a little refactoring. 1. I think you guys haven't tested Xcode templates before 2.0.2 release. The templates are ALL BROKEN because CCHttpClient requires libcurl, which is excluded by xcode4_template_generator/run_generator.sh. It means developers on 2.0.2 would create a new project with compilation error, damn! 2. ios/AppController.*, ios/RootViewController.*, ios/main.m are moved from cocos2dx_*.xctemplate folder to base_ios.xctemplate folder. I don't want to modify tons of RootViewController clones any more. --- .../ios/AppController.h | 0 .../ios/AppController.mm | 0 .../ios/RootViewController.h | 0 .../ios/RootViewController.mm | 0 .../ios/main.m | 0 .../cocos2dx.xctemplate/ios/AppController.mm | 122 ------- .../ios/RootViewController.h | 33 -- .../ios/AppController.h | 20 -- .../ios/RootViewController.mm | 71 ---- .../cocos2dx_box2d.xctemplate/ios/main.m | 17 - .../ios/AppController.h | 20 -- .../ios/AppController.mm | 122 ------- .../ios/RootViewController.h | 16 - .../ios/RootViewController.mm | 71 ---- .../cocos2dx_chipmunk.xctemplate/ios/main.m | 17 - .../ios/AppController.h | 36 -- .../ios/AppController.mm | 122 ------- .../ios/RootViewController.h | 33 -- .../ios/RootViewController.mm | 88 ----- .../xcode4/cocos2dx_js.xctemplate/ios/main.m | 15 - .../Classes/AppDelegate.cpp | 19 +- .../Resources/hello.lua | 332 +++++++++--------- .../ios/AppController.h | 36 -- .../ios/AppController.mm | 138 -------- .../ios/RootViewController.h | 33 -- .../ios/RootViewController.mm | 88 ----- .../xcode4/cocos2dx_lua.xctemplate/ios/main.m | 15 - .../TemplateInfo.plist.REMOVED.git-id | 2 +- .../run_generator.sh | 2 +- 29 files changed, 182 insertions(+), 1286 deletions(-) rename template/xcode4/{cocos2dx.xctemplate => base_ios.xctemplate}/ios/AppController.h (100%) rename template/xcode4/{cocos2dx_box2d.xctemplate => base_ios.xctemplate}/ios/AppController.mm (100%) rename template/xcode4/{cocos2dx_box2d.xctemplate => base_ios.xctemplate}/ios/RootViewController.h (100%) rename template/xcode4/{cocos2dx.xctemplate => base_ios.xctemplate}/ios/RootViewController.mm (100%) rename template/xcode4/{cocos2dx.xctemplate => base_ios.xctemplate}/ios/main.m (100%) delete mode 100644 template/xcode4/cocos2dx.xctemplate/ios/AppController.mm delete mode 100644 template/xcode4/cocos2dx.xctemplate/ios/RootViewController.h delete mode 100644 template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h delete mode 100644 template/xcode4/cocos2dx_box2d.xctemplate/ios/RootViewController.mm delete mode 100644 template/xcode4/cocos2dx_box2d.xctemplate/ios/main.m delete mode 100644 template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h delete mode 100644 template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm delete mode 100644 template/xcode4/cocos2dx_chipmunk.xctemplate/ios/RootViewController.h delete mode 100644 template/xcode4/cocos2dx_chipmunk.xctemplate/ios/RootViewController.mm delete mode 100644 template/xcode4/cocos2dx_chipmunk.xctemplate/ios/main.m delete mode 100644 template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h delete mode 100644 template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm delete mode 100644 template/xcode4/cocos2dx_js.xctemplate/ios/RootViewController.h delete mode 100644 template/xcode4/cocos2dx_js.xctemplate/ios/RootViewController.mm delete mode 100644 template/xcode4/cocos2dx_js.xctemplate/ios/main.m delete mode 100644 template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h delete mode 100644 template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm delete mode 100644 template/xcode4/cocos2dx_lua.xctemplate/ios/RootViewController.h delete mode 100644 template/xcode4/cocos2dx_lua.xctemplate/ios/RootViewController.mm delete mode 100644 template/xcode4/cocos2dx_lua.xctemplate/ios/main.m diff --git a/template/xcode4/cocos2dx.xctemplate/ios/AppController.h b/template/xcode4/base_ios.xctemplate/ios/AppController.h similarity index 100% rename from template/xcode4/cocos2dx.xctemplate/ios/AppController.h rename to template/xcode4/base_ios.xctemplate/ios/AppController.h diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm b/template/xcode4/base_ios.xctemplate/ios/AppController.mm similarity index 100% rename from template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm rename to template/xcode4/base_ios.xctemplate/ios/AppController.mm diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/ios/RootViewController.h b/template/xcode4/base_ios.xctemplate/ios/RootViewController.h similarity index 100% rename from template/xcode4/cocos2dx_box2d.xctemplate/ios/RootViewController.h rename to template/xcode4/base_ios.xctemplate/ios/RootViewController.h diff --git a/template/xcode4/cocos2dx.xctemplate/ios/RootViewController.mm b/template/xcode4/base_ios.xctemplate/ios/RootViewController.mm similarity index 100% rename from template/xcode4/cocos2dx.xctemplate/ios/RootViewController.mm rename to template/xcode4/base_ios.xctemplate/ios/RootViewController.mm diff --git a/template/xcode4/cocos2dx.xctemplate/ios/main.m b/template/xcode4/base_ios.xctemplate/ios/main.m similarity index 100% rename from template/xcode4/cocos2dx.xctemplate/ios/main.m rename to template/xcode4/base_ios.xctemplate/ios/main.m diff --git a/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm deleted file mode 100644 index d90eb8783c..0000000000 --- a/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm +++ /dev/null @@ -1,122 +0,0 @@ -// -// ___PROJECTNAMEASIDENTIFIER___AppController.mm -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// -#import -#import "AppController.h" -#import "cocos2d.h" -#import "EAGLView.h" -#import "AppDelegate.h" - -#import "RootViewController.h" - -@implementation AppController - -@synthesize window; -@synthesize viewController; - -#pragma mark - -#pragma mark Application lifecycle - -// cocos2d application instance -static AppDelegate s_sharedApplication; - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - // Override point for customization after application launch. - - // Add the view controller's view to the window and display. - window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; - EAGLView *__glView = [EAGLView viewWithFrame: [window bounds] - pixelFormat: kEAGLColorFormatRGBA8 - depthFormat: GL_DEPTH_COMPONENT16 - preserveBackbuffer: NO - sharegroup: nil - multiSampling: NO - numberOfSamples: 0 ]; - - // Use RootViewController manage EAGLView - viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; - viewController.wantsFullScreenLayout = YES; - viewController.view = __glView; - - // Set RootViewController to window - if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) - { - // warning: addSubView doesn't work on iOS6 - [window addSubview: viewController.view]; - } - else - { - // use this mehod on ios6 - [window setRootViewController:viewController]; - } - - [window makeKeyAndVisible]; - - [[UIApplication sharedApplication] setStatusBarHidden: YES]; - - cocos2d::CCApplication::sharedApplication()->run(); - return YES; -} - - -- (void)applicationWillResignActive:(UIApplication *)application { - /* - Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. - */ - cocos2d::CCDirector::sharedDirector()->pause(); -} - -- (void)applicationDidBecomeActive:(UIApplication *)application { - /* - Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - */ - cocos2d::CCDirector::sharedDirector()->resume(); -} - -- (void)applicationDidEnterBackground:(UIApplication *)application { - /* - Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - If your application supports background execution, called instead of applicationWillTerminate: when the user quits. - */ - cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground(); -} - -- (void)applicationWillEnterForeground:(UIApplication *)application { - /* - Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. - */ - cocos2d::CCApplication::sharedApplication()->applicationWillEnterForeground(); -} - -- (void)applicationWillTerminate:(UIApplication *)application { - /* - Called when the application is about to terminate. - See also applicationDidEnterBackground:. - */ -} - - -#pragma mark - -#pragma mark Memory management - -- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { - /* - Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. - */ - cocos2d::CCDirector::sharedDirector()->purgeCachedData(); -} - - -- (void)dealloc { - [super dealloc]; -} - - -@end - diff --git a/template/xcode4/cocos2dx.xctemplate/ios/RootViewController.h b/template/xcode4/cocos2dx.xctemplate/ios/RootViewController.h deleted file mode 100644 index a40c2edd28..0000000000 --- a/template/xcode4/cocos2dx.xctemplate/ios/RootViewController.h +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010-2011 cocos2d-x.org - Copyright (c) 2010 Ricardo Quesada - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#import - - -@interface RootViewController : UIViewController { - -} - -@end diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h deleted file mode 100644 index 4f51fc6229..0000000000 --- a/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// ___PROJECTNAMEASIDENTIFIER___AppController.h -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - -@class RootViewController; - -@interface AppController : NSObject { - UIWindow *window; - RootViewController *viewController; -} - -@property (nonatomic, retain) UIWindow *window; -@property (nonatomic, retain) RootViewController *viewController; - -@end - diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/ios/RootViewController.mm b/template/xcode4/cocos2dx_box2d.xctemplate/ios/RootViewController.mm deleted file mode 100644 index 7ca84275ca..0000000000 --- a/template/xcode4/cocos2dx_box2d.xctemplate/ios/RootViewController.mm +++ /dev/null @@ -1,71 +0,0 @@ -// -// ___PROJECTNAMEASIDENTIFIER___AppController.h -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - -#import "RootViewController.h" - - -@implementation RootViewController - -/* - // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { - if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { - // Custom initialization - } - return self; -} -*/ - -/* -// Implement loadView to create a view hierarchy programmatically, without using a nib. -- (void)loadView { -} -*/ - -/* -// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. -- (void)viewDidLoad { - [super viewDidLoad]; -} - -*/ -// Override to allow orientations other than the default portrait orientation. -// This method is deprecated on ios6 -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { - return UIInterfaceOrientationIsLandscape( interfaceOrientation ); -} - -// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead -- (NSUInteger) supportedInterfaceOrientations{ - return UIInterfaceOrientationMaskLandscape; -} - -- (BOOL) shouldAutorotate { - return YES; -} - -- (void)didReceiveMemoryWarning { - // Releases the view if it doesn't have a superview. - [super didReceiveMemoryWarning]; - - // Release any cached data, images, etc that aren't in use. -} - -- (void)viewDidUnload { - [super viewDidUnload]; - // Release any retained subviews of the main view. - // e.g. self.myOutlet = nil; -} - - -- (void)dealloc { - [super dealloc]; -} - - -@end diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/ios/main.m b/template/xcode4/cocos2dx_box2d.xctemplate/ios/main.m deleted file mode 100644 index 8edf7f409e..0000000000 --- a/template/xcode4/cocos2dx_box2d.xctemplate/ios/main.m +++ /dev/null @@ -1,17 +0,0 @@ -// -// main.m -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - -#import - -int main(int argc, char *argv[]) { - - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - int retVal = UIApplicationMain(argc, argv, nil, @"AppController"); - [pool release]; - return retVal; -} diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h deleted file mode 100644 index 4f51fc6229..0000000000 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// ___PROJECTNAMEASIDENTIFIER___AppController.h -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - -@class RootViewController; - -@interface AppController : NSObject { - UIWindow *window; - RootViewController *viewController; -} - -@property (nonatomic, retain) UIWindow *window; -@property (nonatomic, retain) RootViewController *viewController; - -@end - diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm deleted file mode 100644 index f9311ead79..0000000000 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm +++ /dev/null @@ -1,122 +0,0 @@ -// -// ___PROJECTNAMEASIDENTIFIER___AppController.mm -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// -#import -#import "AppController.h" -#import "cocos2d.h" -#import "EAGLView.h" -#import "AppDelegate.h" - -#import "RootViewController.h" - -@implementation AppController - -@synthesize window; -@synthesize viewController; - -#pragma mark - -#pragma mark Application lifecycle - -// cocos2d application instance -static AppDelegate s_sharedApplication; - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - // Override point for customization after application launch. - - // Add the view controller's view to the window and display. - window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; - EAGLView *__glView = [EAGLView viewWithFrame: [window bounds] - pixelFormat: kEAGLColorFormatRGBA8 - depthFormat: GL_DEPTH_COMPONENT16 - preserveBackbuffer: NO - sharegroup: nil - multiSampling: NO - numberOfSamples: 0 ]; - - // Use RootViewController manage EAGLView - viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; - viewController.wantsFullScreenLayout = YES; - viewController.view = __glView; - - // Set RootViewController to window - if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) - { - // warning: addSubView doesn't work on iOS6 - [window addSubview: viewController.view]; - } - else - { - // use this mehod on ios6 - [window setRootViewController:viewController]; - } - - [window makeKeyAndVisible]; - - [[UIApplication sharedApplication] setStatusBarHidden: YES]; - - cocos2d::CCApplication::sharedApplication()->run(); - return YES; -} - - -- (void)applicationWillResignActive:(UIApplication *)application { - /* - Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. - */ - cocos2d::CCDirector::sharedDirector()->pause(); -} - -- (void)applicationDidBecomeActive:(UIApplication *)application { - /* - Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - */ - cocos2d::CCDirector::sharedDirector()->resume(); -} - -- (void)applicationDidEnterBackground:(UIApplication *)application { - /* - Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - If your application supports background execution, called instead of applicationWillTerminate: when the user quits. - */ - cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground(); -} - -- (void)applicationWillEnterForeground:(UIApplication *)application { - /* - Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. - */ - cocos2d::CCApplication::sharedApplication()->applicationWillEnterForeground(); -} - -- (void)applicationWillTerminate:(UIApplication *)application { - /* - Called when the application is about to terminate. - See also applicationDidEnterBackground:. - */ -} - - -#pragma mark - -#pragma mark Memory management - -- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { - /* - Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. - */ - cocos2d::CCDirector::sharedDirector()->purgeCachedData(); -} - - -- (void)dealloc { - [super dealloc]; -} - - -@end - diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/RootViewController.h b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/RootViewController.h deleted file mode 100644 index 5009e46b9d..0000000000 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/RootViewController.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// ___PROJECTNAMEASIDENTIFIER___AppController.h -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - -#import - - -@interface RootViewController : UIViewController { - -} - -@end diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/RootViewController.mm b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/RootViewController.mm deleted file mode 100644 index 7ca84275ca..0000000000 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/RootViewController.mm +++ /dev/null @@ -1,71 +0,0 @@ -// -// ___PROJECTNAMEASIDENTIFIER___AppController.h -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - -#import "RootViewController.h" - - -@implementation RootViewController - -/* - // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { - if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { - // Custom initialization - } - return self; -} -*/ - -/* -// Implement loadView to create a view hierarchy programmatically, without using a nib. -- (void)loadView { -} -*/ - -/* -// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. -- (void)viewDidLoad { - [super viewDidLoad]; -} - -*/ -// Override to allow orientations other than the default portrait orientation. -// This method is deprecated on ios6 -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { - return UIInterfaceOrientationIsLandscape( interfaceOrientation ); -} - -// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead -- (NSUInteger) supportedInterfaceOrientations{ - return UIInterfaceOrientationMaskLandscape; -} - -- (BOOL) shouldAutorotate { - return YES; -} - -- (void)didReceiveMemoryWarning { - // Releases the view if it doesn't have a superview. - [super didReceiveMemoryWarning]; - - // Release any cached data, images, etc that aren't in use. -} - -- (void)viewDidUnload { - [super viewDidUnload]; - // Release any retained subviews of the main view. - // e.g. self.myOutlet = nil; -} - - -- (void)dealloc { - [super dealloc]; -} - - -@end diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/main.m b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/main.m deleted file mode 100644 index 8edf7f409e..0000000000 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/main.m +++ /dev/null @@ -1,17 +0,0 @@ -// -// main.m -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - -#import - -int main(int argc, char *argv[]) { - - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - int retVal = UIApplicationMain(argc, argv, nil, @"AppController"); - [pool release]; - return retVal; -} diff --git a/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h deleted file mode 100644 index b05d7bf9f7..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.h +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -@class RootViewController; - -@interface AppController : NSObject { - UIWindow *window; - RootViewController *viewController; -} - -@property (nonatomic, retain) UIWindow *window; -@property (nonatomic, retain) RootViewController *viewController; - -@end - diff --git a/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm deleted file mode 100644 index f9311ead79..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/ios/AppController.mm +++ /dev/null @@ -1,122 +0,0 @@ -// -// ___PROJECTNAMEASIDENTIFIER___AppController.mm -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// -#import -#import "AppController.h" -#import "cocos2d.h" -#import "EAGLView.h" -#import "AppDelegate.h" - -#import "RootViewController.h" - -@implementation AppController - -@synthesize window; -@synthesize viewController; - -#pragma mark - -#pragma mark Application lifecycle - -// cocos2d application instance -static AppDelegate s_sharedApplication; - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - // Override point for customization after application launch. - - // Add the view controller's view to the window and display. - window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; - EAGLView *__glView = [EAGLView viewWithFrame: [window bounds] - pixelFormat: kEAGLColorFormatRGBA8 - depthFormat: GL_DEPTH_COMPONENT16 - preserveBackbuffer: NO - sharegroup: nil - multiSampling: NO - numberOfSamples: 0 ]; - - // Use RootViewController manage EAGLView - viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; - viewController.wantsFullScreenLayout = YES; - viewController.view = __glView; - - // Set RootViewController to window - if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) - { - // warning: addSubView doesn't work on iOS6 - [window addSubview: viewController.view]; - } - else - { - // use this mehod on ios6 - [window setRootViewController:viewController]; - } - - [window makeKeyAndVisible]; - - [[UIApplication sharedApplication] setStatusBarHidden: YES]; - - cocos2d::CCApplication::sharedApplication()->run(); - return YES; -} - - -- (void)applicationWillResignActive:(UIApplication *)application { - /* - Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. - */ - cocos2d::CCDirector::sharedDirector()->pause(); -} - -- (void)applicationDidBecomeActive:(UIApplication *)application { - /* - Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - */ - cocos2d::CCDirector::sharedDirector()->resume(); -} - -- (void)applicationDidEnterBackground:(UIApplication *)application { - /* - Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - If your application supports background execution, called instead of applicationWillTerminate: when the user quits. - */ - cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground(); -} - -- (void)applicationWillEnterForeground:(UIApplication *)application { - /* - Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. - */ - cocos2d::CCApplication::sharedApplication()->applicationWillEnterForeground(); -} - -- (void)applicationWillTerminate:(UIApplication *)application { - /* - Called when the application is about to terminate. - See also applicationDidEnterBackground:. - */ -} - - -#pragma mark - -#pragma mark Memory management - -- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { - /* - Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. - */ - cocos2d::CCDirector::sharedDirector()->purgeCachedData(); -} - - -- (void)dealloc { - [super dealloc]; -} - - -@end - diff --git a/template/xcode4/cocos2dx_js.xctemplate/ios/RootViewController.h b/template/xcode4/cocos2dx_js.xctemplate/ios/RootViewController.h deleted file mode 100644 index a40c2edd28..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/ios/RootViewController.h +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010-2011 cocos2d-x.org - Copyright (c) 2010 Ricardo Quesada - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#import - - -@interface RootViewController : UIViewController { - -} - -@end diff --git a/template/xcode4/cocos2dx_js.xctemplate/ios/RootViewController.mm b/template/xcode4/cocos2dx_js.xctemplate/ios/RootViewController.mm deleted file mode 100644 index fee0d0c071..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/ios/RootViewController.mm +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010-2011 cocos2d-x.org - Copyright (c) 2010 Ricardo Quesada - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#import "RootViewController.h" - - -@implementation RootViewController - -/* - // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { - if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { - // Custom initialization - } - return self; -} -*/ - -/* -// Implement loadView to create a view hierarchy programmatically, without using a nib. -- (void)loadView { -} -*/ - -/* -// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. -- (void)viewDidLoad { - [super viewDidLoad]; -} - -*/ -// Override to allow orientations other than the default portrait orientation. -// This method is deprecated on ios6 -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { - return UIInterfaceOrientationIsLandscape( interfaceOrientation ); -} - -// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead -- (NSUInteger) supportedInterfaceOrientations{ - return UIInterfaceOrientationMaskLandscape; -} - -- (BOOL) shouldAutorotate { - return YES; -} - -- (void)didReceiveMemoryWarning { - // Releases the view if it doesn't have a superview. - [super didReceiveMemoryWarning]; - - // Release any cached data, images, etc that aren't in use. -} - -- (void)viewDidUnload { - [super viewDidUnload]; - // Release any retained subviews of the main view. - // e.g. self.myOutlet = nil; -} - - -- (void)dealloc { - [super dealloc]; -} - - -@end diff --git a/template/xcode4/cocos2dx_js.xctemplate/ios/main.m b/template/xcode4/cocos2dx_js.xctemplate/ios/main.m deleted file mode 100644 index 4135c21f5d..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/ios/main.m +++ /dev/null @@ -1,15 +0,0 @@ -// -// main.m -// HelloLua -// -// Copyright __MyCompanyName__ 2011. All rights reserved. -// - -#import - -int main(int argc, char *argv[]) { - NSAutoreleasePool *pool = [NSAutoreleasePool new]; - int retVal = UIApplicationMain(argc, argv, nil, @"AppController"); - [pool release]; - return retVal; -} diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp index bdb910919e..21ca3dcefc 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp @@ -1,11 +1,10 @@ #include "cocos2d.h" #include "AppDelegate.h" #include "SimpleAudioEngine.h" -#include "CCScriptSupport.h" +#include "script_support/CCScriptSupport.h" #include "CCLuaEngine.h" USING_NS_CC; -using namespace std; using namespace CocosDenshion; AppDelegate::AppDelegate() @@ -18,7 +17,7 @@ AppDelegate::~AppDelegate() { // end simple audio engine here, or it may crashed on win32 SimpleAudioEngine::sharedEngine()->end(); - CCScriptEngineManager::purgeSharedManager(); + //CCScriptEngineManager::purgeSharedManager(); } bool AppDelegate::applicationDidFinishLaunching() @@ -26,6 +25,8 @@ bool AppDelegate::applicationDidFinishLaunching() // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); + + CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionShowAll); // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. // pDirector->enableRetinaDisplay(true); @@ -37,7 +38,7 @@ bool AppDelegate::applicationDidFinishLaunching() pDirector->setAnimationInterval(1.0 / 60); // register lua engine - CCScriptEngineProtocol* pEngine = CCLuaEngine::engine(); + CCLuaEngine* pEngine = CCLuaEngine::defaultEngine(); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) @@ -47,7 +48,7 @@ bool AppDelegate::applicationDidFinishLaunching() pEngine->executeString(pstrFileContent->getCString()); } #else - string path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("hello.lua"); + std::string path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("hello.lua"); pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); pEngine->executeScriptFile(path.c_str()); #endif @@ -59,16 +60,12 @@ bool AppDelegate::applicationDidFinishLaunching() void AppDelegate::applicationDidEnterBackground() { CCDirector::sharedDirector()->stopAnimation(); - - // if you use SimpleAudioEngine, it must be pause - // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); + SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); } // this function will be called when the app is active again void AppDelegate::applicationWillEnterForeground() { CCDirector::sharedDirector()->startAnimation(); - - // if you use SimpleAudioEngine, it must resume here - // SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); + SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); } diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua b/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua index ce3c4df576..4bbd577856 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua +++ b/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua @@ -1,188 +1,200 @@ --- avoid memory leak -collectgarbage("setpause", 100) -collectgarbage("setstepmul", 5000) - -local cclog = function(...) - print(string.format(...)) +-- for CCLuaEngine traceback +function __G__TRACKBACK__(msg) + print("----------------------------------------") + print("LUA ERROR: " .. tostring(msg) .. "\n") + print(debug.traceback()) + print("----------------------------------------") end -require "hello2" -cclog("result is " .. myadd(3, 5)) +local function main() + -- avoid memory leak + collectgarbage("setpause", 100) + collectgarbage("setstepmul", 5000) ---------------- - -local winSize = CCDirector:sharedDirector():getWinSize() - --- add the moving dog -local function creatDog() - local frameWidth = 105 - local frameHeight = 95 - - -- create dog animate - local textureDog = CCTextureCache:sharedTextureCache():addImage("dog.png") - local rect = CCRectMake(0, 0, frameWidth, frameHeight) - local frame0 = CCSpriteFrame:createWithTexture(textureDog, rect) - rect = CCRectMake(frameWidth, 0, frameWidth, frameHeight) - local frame1 = CCSpriteFrame:createWithTexture(textureDog, rect) - - local spriteDog = CCSprite:createWithSpriteFrame(frame0) - spriteDog.isPaused = false - spriteDog:setPosition(0, winSize.height / 4 * 3) - - local animFrames = CCArray:create(2) - - animFrames:addObject(frame0) - animFrames:addObject(frame1) - - local animation = CCAnimation:create(animFrames, 0.5) - local animate = CCAnimate:create(animation); - spriteDog:runAction(CCRepeatForever:create(animate)) - - -- moving dog at every frame - local function tick() - if spriteDog.isPaused then return end - local x, y = spriteDog:getPosition() - if x > winSize.width then - x = 0 - else - x = x + 1 - end - - spriteDog:setPositionX(x) + local cclog = function(...) + print(string.format(...)) end - CCDirector:sharedDirector():getScheduler():scheduleScriptFunc(tick, 0, false) + require "hello2" + cclog("result is " .. myadd(3, 5)) - return spriteDog -end + --------------- --- create farm -local function createLayerFarm() - local layerFarm = CCLayer:create() + local winSize = CCDirector:sharedDirector():getWinSize() - -- add in farm background - local bg = CCSprite:create("farm.jpg") - bg:setPosition(winSize.width / 2 + 80, winSize.height / 2) - layerFarm:addChild(bg) + -- add the moving dog + local function creatDog() + local frameWidth = 105 + local frameHeight = 95 - -- add land sprite - for i = 0, 3 do - for j = 0, 1 do - local spriteLand = CCSprite:create("land.png") - spriteLand:setPosition(200 + j * 180 - i % 2 * 90, 10 + i * 95 / 2) - layerFarm:addChild(spriteLand) - end - end + -- create dog animate + local textureDog = CCTextureCache:sharedTextureCache():addImage("dog.png") + local rect = CCRectMake(0, 0, frameWidth, frameHeight) + local frame0 = CCSpriteFrame:createWithTexture(textureDog, rect) + rect = CCRectMake(frameWidth, 0, frameWidth, frameHeight) + local frame1 = CCSpriteFrame:createWithTexture(textureDog, rect) - -- add crop - local frameCrop = CCSpriteFrame:create("crop.png", CCRectMake(0, 0, 105, 95)) - for i = 0, 3 do - for j = 0, 1 do - local spriteCrop = CCSprite:createWithSpriteFrame(frameCrop); - spriteCrop:setPosition(10 + 200 + j * 180 - i % 2 * 90, 30 + 10 + i * 95 / 2) - layerFarm:addChild(spriteCrop) - end - end - - -- add moving dog - local spriteDog = creatDog() - layerFarm:addChild(spriteDog) - - -- handing touch events - local touchBeginPoint = nil - - local function onTouchBegan(x, y) - cclog("onTouchBegan: %0.2f, %0.2f", x, y) - touchBeginPoint = {x = x, y = y} - spriteDog.isPaused = true - -- CCTOUCHBEGAN event must return true - return true - end - - local function onTouchMoved(x, y) - cclog("onTouchMoved: %0.2f, %0.2f", x, y) - if touchBeginPoint then - local cx, cy = layerFarm:getPosition() - layerFarm:setPosition(cx + x - touchBeginPoint.x, - cy + y - touchBeginPoint.y) - touchBeginPoint = {x = x, y = y} - end - end - - local function onTouchEnded(x, y) - cclog("onTouchEnded: %0.2f, %0.2f", x, y) - touchBeginPoint = nil + local spriteDog = CCSprite:createWithSpriteFrame(frame0) spriteDog.isPaused = false - end + spriteDog:setPosition(0, winSize.height / 4 * 3) - local function onTouch(eventType, x, y) - if eventType == CCTOUCHBEGAN then - return onTouchBegan(x, y) - elseif eventType == CCTOUCHMOVED then - return onTouchMoved(x, y) - else - return onTouchEnded(x, y) + local animFrames = CCArray:create() + + animFrames:addObject(frame0) + animFrames:addObject(frame1) + + local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.5) + local animate = CCAnimate:create(animation); + spriteDog:runAction(CCRepeatForever:create(animate)) + + -- moving dog at every frame + local function tick() + if spriteDog.isPaused then return end + local x, y = spriteDog:getPosition() + if x > winSize.width then + x = 0 + else + x = x + 1 + end + + spriteDog:setPositionX(x) end + + CCDirector:sharedDirector():getScheduler():scheduleScriptFunc(tick, 0, false) + + return spriteDog end - layerFarm:registerScriptTouchHandler(onTouch) - layerFarm:setTouchEnabled(true) + -- create farm + local function createLayerFarm() + local layerFarm = CCLayer:create() - return layerFarm -end + -- add in farm background + local bg = CCSprite:create("farm.jpg") + bg:setPosition(winSize.width / 2 + 80, winSize.height / 2) + layerFarm:addChild(bg) + + -- add land sprite + for i = 0, 3 do + for j = 0, 1 do + local spriteLand = CCSprite:create("land.png") + spriteLand:setPosition(200 + j * 180 - i % 2 * 90, 10 + i * 95 / 2) + layerFarm:addChild(spriteLand) + end + end + + -- add crop + local frameCrop = CCSpriteFrame:create("crop.png", CCRectMake(0, 0, 105, 95)) + for i = 0, 3 do + for j = 0, 1 do + local spriteCrop = CCSprite:createWithSpriteFrame(frameCrop); + spriteCrop:setPosition(10 + 200 + j * 180 - i % 2 * 90, 30 + 10 + i * 95 / 2) + layerFarm:addChild(spriteCrop) + end + end + + -- add moving dog + local spriteDog = creatDog() + layerFarm:addChild(spriteDog) + + -- handing touch events + local touchBeginPoint = nil + + local function onTouchBegan(x, y) + cclog("onTouchBegan: %0.2f, %0.2f", x, y) + touchBeginPoint = {x = x, y = y} + spriteDog.isPaused = true + -- CCTOUCHBEGAN event must return true + return true + end + + local function onTouchMoved(x, y) + -- cclog("onTouchMoved: %0.2f, %0.2f", x, y) + if touchBeginPoint then + local cx, cy = layerFarm:getPosition() + layerFarm:setPosition(cx + x - touchBeginPoint.x, + cy + y - touchBeginPoint.y) + touchBeginPoint = {x = x, y = y} + end + end + + local function onTouchEnded(x, y) + cclog("onTouchEnded: %0.2f, %0.2f", x, y) + touchBeginPoint = nil + spriteDog.isPaused = false + end + + local function onTouch(eventType, x, y) + if eventType == CCTOUCHBEGAN then + return onTouchBegan(x, y) + elseif eventType == CCTOUCHMOVED then + return onTouchMoved(x, y) + else + return onTouchEnded(x, y) + end + end + + layerFarm:registerScriptTouchHandler(onTouch) + layerFarm:setTouchEnabled(true) + + return layerFarm + end --- create menu -local function createLayerMenu() - local layerMenu = CCLayer:create() + -- create menu + local function createLayerMenu() + local layerMenu = CCLayer:create() - local menuPopup, menuTools, effectID + local menuPopup, menuTools, effectID - local function menuCallbackClosePopup() - -- stop test sound effect - SimpleAudioEngine:sharedEngine():stopEffect(effectID) + local function menuCallbackClosePopup() + -- stop test sound effect + SimpleAudioEngine:sharedEngine():stopEffect(effectID) + menuPopup:setVisible(false) + end + + local function menuCallbackOpenPopup() + -- loop test sound effect + local effectPath = CCFileUtils:sharedFileUtils():fullPathFromRelativePath("effect1.wav") + effectID = SimpleAudioEngine:sharedEngine():playEffect(effectPath) + menuPopup:setVisible(true) + end + + -- add a popup menu + local menuPopupItem = CCMenuItemImage:create("menu2.png", "menu2.png") + menuPopupItem:setPosition(0, 0) + menuPopupItem:registerScriptTapHandler(menuCallbackClosePopup) + menuPopup = CCMenu:createWithItem(menuPopupItem) + menuPopup:setPosition(winSize.width / 2, winSize.height / 2) menuPopup:setVisible(false) + layerMenu:addChild(menuPopup) + + -- add the left-bottom "tools" menu to invoke menuPopup + local menuToolsItem = CCMenuItemImage:create("menu1.png", "menu1.png") + menuToolsItem:setPosition(0, 0) + menuToolsItem:registerScriptTapHandler(menuCallbackOpenPopup) + menuTools = CCMenu:createWithItem(menuToolsItem) + menuTools:setPosition(30, 40) + layerMenu:addChild(menuTools) + + return layerMenu end - local function menuCallbackOpenPopup() - -- loop test sound effect - local effectPath = CCFileUtils:sharedFileUtils():fullPathFromRelativePath("effect1.wav") - effectID = SimpleAudioEngine:sharedEngine():playEffect(effectPath) - menuPopup:setVisible(true) - end + -- play background music, preload effect - -- add a popup menu - local menuPopupItem = CCMenuItemImage:create("menu2.png", "menu2.png") - menuPopupItem:setPosition(0, 0) - menuPopupItem:registerScriptHandler(menuCallbackClosePopup) - menuPopup = CCMenu:createWithItem(menuPopupItem) - menuPopup:setPosition(winSize.width / 2, winSize.height / 2) - menuPopup:setVisible(false) - layerMenu:addChild(menuPopup) + -- uncomment below for the BlackBerry version + -- local bgMusicPath = CCFileUtils:sharedFileUtils():fullPathFromRelativePath("background.ogg") + local bgMusicPath = CCFileUtils:sharedFileUtils():fullPathFromRelativePath("background.mp3") + SimpleAudioEngine:sharedEngine():playBackgroundMusic(bgMusicPath, true) + local effectPath = CCFileUtils:sharedFileUtils():fullPathFromRelativePath("effect1.wav") + SimpleAudioEngine:sharedEngine():preloadEffect(effectPath) - -- add the left-bottom "tools" menu to invoke menuPopup - local menuToolsItem = CCMenuItemImage:create("menu1.png", "menu1.png") - menuToolsItem:setPosition(0, 0) - menuToolsItem:registerScriptHandler(menuCallbackOpenPopup) - menuTools = CCMenu:createWithItem(menuToolsItem) - menuTools:setPosition(30, 40) - layerMenu:addChild(menuTools) - - return layerMenu + -- run + local sceneGame = CCScene:create() + sceneGame:addChild(createLayerFarm()) + sceneGame:addChild(createLayerMenu()) + CCDirector:sharedDirector():runWithScene(sceneGame) end --- play background music, preload effect - --- uncomment below for the BlackBerry version --- local bgMusicPath = CCFileUtils:sharedFileUtils():fullPathFromRelativePath("background.ogg") -local bgMusicPath = CCFileUtils:sharedFileUtils():fullPathFromRelativePath("background.mp3") -SimpleAudioEngine:sharedEngine():playBackgroundMusic(bgMusicPath, true) -local effectPath = CCFileUtils:sharedFileUtils():fullPathFromRelativePath("effect1.wav") -SimpleAudioEngine:sharedEngine():preloadEffect(effectPath) - --- run -local sceneGame = CCScene:create() -sceneGame:addChild(createLayerFarm()) -sceneGame:addChild(createLayerMenu()) -CCDirector:sharedDirector():runWithScene(sceneGame) +xpcall(main, __G__TRACKBACK__) diff --git a/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h deleted file mode 100644 index b05d7bf9f7..0000000000 --- a/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.h +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -@class RootViewController; - -@interface AppController : NSObject { - UIWindow *window; - RootViewController *viewController; -} - -@property (nonatomic, retain) UIWindow *window; -@property (nonatomic, retain) RootViewController *viewController; - -@end - diff --git a/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm deleted file mode 100644 index e218764675..0000000000 --- a/template/xcode4/cocos2dx_lua.xctemplate/ios/AppController.mm +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ -#import -#import "AppController.h" -#import "cocos2d.h" -#import "EAGLView.h" -#import "AppDelegate.h" - -#import "RootViewController.h" - -@implementation AppController - -@synthesize window; -@synthesize viewController; - -#pragma mark - -#pragma mark Application lifecycle - -// cocos2d application instance -static AppDelegate s_sharedApplication; - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - // Override point for customization after application launch. - - // Add the view controller's view to the window and display. - window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; - EAGLView *__glView = [EAGLView viewWithFrame: [window bounds] - pixelFormat: kEAGLColorFormatRGBA8 - depthFormat: GL_DEPTH_COMPONENT16 - preserveBackbuffer: NO - sharegroup: nil - multiSampling: NO - numberOfSamples: 0 ]; - - // Use RootViewController manage EAGLView - viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; - viewController.wantsFullScreenLayout = YES; - viewController.view = __glView; - - // Set RootViewController to window - if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) - { - // warning: addSubView doesn't work on iOS6 - [window addSubview: viewController.view]; - } - else - { - // use this mehod on ios6 - [window setRootViewController:viewController]; - } - - [window makeKeyAndVisible]; - - [[UIApplication sharedApplication] setStatusBarHidden: YES]; - - cocos2d::CCApplication::sharedApplication()->run(); - return YES; -} - - -- (void)applicationWillResignActive:(UIApplication *)application { - /* - Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. - */ - cocos2d::CCDirector::sharedDirector()->pause(); -} - -- (void)applicationDidBecomeActive:(UIApplication *)application { - /* - Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - */ - cocos2d::CCDirector::sharedDirector()->resume(); -} - -- (void)applicationDidEnterBackground:(UIApplication *)application { - /* - Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - If your application supports background execution, called instead of applicationWillTerminate: when the user quits. - */ - cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground(); -} - -- (void)applicationWillEnterForeground:(UIApplication *)application { - /* - Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. - */ - cocos2d::CCApplication::sharedApplication()->applicationWillEnterForeground(); -} - -- (void)applicationWillTerminate:(UIApplication *)application { - /* - Called when the application is about to terminate. - See also applicationDidEnterBackground:. - */ -} - - -#pragma mark - -#pragma mark Memory management - -- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { - /* - Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. - */ - cocos2d::CCDirector::sharedDirector()->purgeCachedData(); -} - - -- (void)dealloc { - [super dealloc]; -} - - -@end - diff --git a/template/xcode4/cocos2dx_lua.xctemplate/ios/RootViewController.h b/template/xcode4/cocos2dx_lua.xctemplate/ios/RootViewController.h deleted file mode 100644 index a40c2edd28..0000000000 --- a/template/xcode4/cocos2dx_lua.xctemplate/ios/RootViewController.h +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010-2011 cocos2d-x.org - Copyright (c) 2010 Ricardo Quesada - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#import - - -@interface RootViewController : UIViewController { - -} - -@end diff --git a/template/xcode4/cocos2dx_lua.xctemplate/ios/RootViewController.mm b/template/xcode4/cocos2dx_lua.xctemplate/ios/RootViewController.mm deleted file mode 100644 index fee0d0c071..0000000000 --- a/template/xcode4/cocos2dx_lua.xctemplate/ios/RootViewController.mm +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010-2011 cocos2d-x.org - Copyright (c) 2010 Ricardo Quesada - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#import "RootViewController.h" - - -@implementation RootViewController - -/* - // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { - if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { - // Custom initialization - } - return self; -} -*/ - -/* -// Implement loadView to create a view hierarchy programmatically, without using a nib. -- (void)loadView { -} -*/ - -/* -// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. -- (void)viewDidLoad { - [super viewDidLoad]; -} - -*/ -// Override to allow orientations other than the default portrait orientation. -// This method is deprecated on ios6 -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { - return UIInterfaceOrientationIsLandscape( interfaceOrientation ); -} - -// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead -- (NSUInteger) supportedInterfaceOrientations{ - return UIInterfaceOrientationMaskLandscape; -} - -- (BOOL) shouldAutorotate { - return YES; -} - -- (void)didReceiveMemoryWarning { - // Releases the view if it doesn't have a superview. - [super didReceiveMemoryWarning]; - - // Release any cached data, images, etc that aren't in use. -} - -- (void)viewDidUnload { - [super viewDidUnload]; - // Release any retained subviews of the main view. - // e.g. self.myOutlet = nil; -} - - -- (void)dealloc { - [super dealloc]; -} - - -@end diff --git a/template/xcode4/cocos2dx_lua.xctemplate/ios/main.m b/template/xcode4/cocos2dx_lua.xctemplate/ios/main.m deleted file mode 100644 index 4135c21f5d..0000000000 --- a/template/xcode4/cocos2dx_lua.xctemplate/ios/main.m +++ /dev/null @@ -1,15 +0,0 @@ -// -// main.m -// HelloLua -// -// Copyright __MyCompanyName__ 2011. All rights reserved. -// - -#import - -int main(int argc, char *argv[]) { - NSAutoreleasePool *pool = [NSAutoreleasePool new]; - int retVal = UIApplicationMain(argc, argv, nil, @"AppController"); - [pool release]; - return retVal; -} diff --git a/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id b/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id index 2acf240745..5fac254010 100644 --- a/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id +++ b/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id @@ -1 +1 @@ -8bf975e465dbd53b0042a7d6a96c2d98240dd881 \ No newline at end of file +e21d47625e1d0fac0c02ae37e976a4935d307012 \ No newline at end of file diff --git a/tools/xcode4_template_generator/run_generator.sh b/tools/xcode4_template_generator/run_generator.sh index d9ae47f74b..a772e5bb7a 100755 --- a/tools/xcode4_template_generator/run_generator.sh +++ b/tools/xcode4_template_generator/run_generator.sh @@ -2,7 +2,7 @@ pushd ../../ echo "generating libcocos2dx" mkdir -p template/xcode4/lib_cocos2dx.xctemplate -python ./tools/xcode4_template_generator/template_generator.py --directory cocos2dx --identifier libcocos2dx --prefix libs --exclude "android win32 blackberry linux third_party CCImage.cpp CCThread.cpp proj.ios CCFileUtilsCommon_cpp.h CCImageCommon_cpp.h CCFileUtils.cpp Android.mk mac" > ./template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist +python ./tools/xcode4_template_generator/template_generator.py --directory cocos2dx --identifier libcocos2dx --prefix libs --exclude "android win32 blackberry linux CCImage.cpp CCThread.cpp proj.ios CCFileUtilsCommon_cpp.h CCImageCommon_cpp.h CCFileUtils.cpp Android.mk mac" > ./template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist echo "generating libcocosdenshion" mkdir -p template/xcode4/lib_cocosdenshion.xctemplate From 59a4b0460b3a8507ca44d99d2e60482d9a03fdda Mon Sep 17 00:00:00 2001 From: walzer Date: Mon, 24 Sep 2012 10:46:15 +0800 Subject: [PATCH 108/181] HelloCpp and SimpleGame teaches how to adapt on all iPhone/iPad multi-resolutions, especially for 4-inch retina screen. --- samples/HelloCpp/Classes/AppDelegate.cpp | 5 ++- samples/HelloCpp/Classes/HelloWorldScene.cpp | 15 +++----- samples/SimpleGame/Classes/AppDelegate.cpp | 9 +++-- .../SimpleGame/Classes/HelloWorldScene.cpp | 36 +++++++++++++------ samples/SimpleGame/Classes/HelloWorldScene.h | 1 + .../SimpleGame.xcodeproj/project.pbxproj | 4 +-- 6 files changed, 44 insertions(+), 26 deletions(-) diff --git a/samples/HelloCpp/Classes/AppDelegate.cpp b/samples/HelloCpp/Classes/AppDelegate.cpp index b2c80149f5..d04664af37 100644 --- a/samples/HelloCpp/Classes/AppDelegate.cpp +++ b/samples/HelloCpp/Classes/AppDelegate.cpp @@ -32,10 +32,13 @@ bool AppDelegate::applicationDidFinishLaunching() { { // iphone - if (pDirector->enableRetinaDisplay(true)) + // try to enable retina on device + // notice: passby CCDirecor::enableRetinaDisplay() + if (true == CCEGLView::sharedOpenGLView()->enableRetina()) { // iphone hd CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd"); + CCEGLView::sharedOpenGLView()->setDesignResolutionSize(960, 640, kResolutionNoBorder); } else { diff --git a/samples/HelloCpp/Classes/HelloWorldScene.cpp b/samples/HelloCpp/Classes/HelloWorldScene.cpp index 43117c740f..83f84f3e00 100644 --- a/samples/HelloCpp/Classes/HelloWorldScene.cpp +++ b/samples/HelloCpp/Classes/HelloWorldScene.cpp @@ -40,15 +40,9 @@ bool HelloWorld::init() "CloseSelected.png", this, menu_selector(HelloWorld::menuCloseCallback)); - - if (CCApplication::sharedApplication()->getTargetPlatform() == kTargetIphone) - { - pCloseItem->setPosition(ccp(visibleSize.width - 20 + origin.x, 20 + origin.y)); - } - else - { - pCloseItem->setPosition(ccp(visibleSize.width - 40 + origin.x, 40 + origin.y)); - } + + pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 , + origin.y + pCloseItem->getContentSize().height/2)); // create menu, it's an autorelease object CCMenu* pMenu = CCMenu::create(pCloseItem, NULL); @@ -63,7 +57,8 @@ bool HelloWorld::init() CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24); // position the label on the center of the screen - pLabel->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height - 50 + origin.y)); + pLabel->setPosition(ccp(origin.x + visibleSize.width/2, + origin.y + visibleSize.height - pLabel->getContentSize().height)); // add the label as a child to this layer this->addChild(pLabel, 1); diff --git a/samples/SimpleGame/Classes/AppDelegate.cpp b/samples/SimpleGame/Classes/AppDelegate.cpp index 74fcb1a83c..a614d78518 100644 --- a/samples/SimpleGame/Classes/AppDelegate.cpp +++ b/samples/SimpleGame/Classes/AppDelegate.cpp @@ -3,6 +3,7 @@ USING_NS_CC; + AppDelegate::AppDelegate() { } @@ -14,7 +15,7 @@ AppDelegate::~AppDelegate() bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); - + pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); TargetPlatform target = getTargetPlatform(); @@ -30,15 +31,17 @@ bool AppDelegate::applicationDidFinishLaunching() { } else if (target == kTargetIphone) { - if (pDirector->enableRetinaDisplay(true)) + if (CCEGLView::sharedOpenGLView()->enableRetina()) { // well, it's a iPhone 4 and above, with 960x480 Retina resolution CCFileUtils::sharedFileUtils()->setResourceDirectory("hd"); + CCEGLView::sharedOpenGLView()->setDesignResolutionSize(960, 640, kResolutionNoBorder); } - else + else { // iPhone 3GS and before, with 480x320 resolution CCFileUtils::sharedFileUtils()->setResourceDirectory("sd"); + CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionNoBorder); } } else diff --git a/samples/SimpleGame/Classes/HelloWorldScene.cpp b/samples/SimpleGame/Classes/HelloWorldScene.cpp index 41587e8342..04e523e338 100755 --- a/samples/SimpleGame/Classes/HelloWorldScene.cpp +++ b/samples/SimpleGame/Classes/HelloWorldScene.cpp @@ -4,6 +4,8 @@ using namespace cocos2d; +extern float g_scaleRatio; + HelloWorld::~HelloWorld() { if (_targets) @@ -26,7 +28,18 @@ HelloWorld::HelloWorld() :_targets(NULL) ,_projectiles(NULL) ,_projectilesDestroyed(0) +,_scaleRatio(1.0) { + if ( 0 == strcmp(CCFileUtils::sharedFileUtils()->getResourceDirectory(), "hd/") ) + { + // AppDelegate.cpp used hd resource & 960x640 design resolution + _scaleRatio = 2.0; + } + else + { + // sd + _scaleRatio = 1.0; + } } CCScene* HelloWorld::scene() @@ -75,10 +88,13 @@ bool HelloWorld::init() this, menu_selector(HelloWorld::menuCloseCallback)); CC_BREAK_IF(! pCloseItem); - + // Place the menu item bottom-right conner. - pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width - 20, - CCDirector::sharedDirector()->getVisibleOrigin().y + 20)); + CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); + CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); + + pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2, + origin.y + pCloseItem->getContentSize().height/2)); // Create a menu with the "close" menu item, it's an auto release object. CCMenu* pMenu = CCMenu::create(pCloseItem, NULL); @@ -90,10 +106,10 @@ bool HelloWorld::init() ///////////////////////////// // 2. add your codes below... - - CCSize winSize = CCDirector::sharedDirector()->getVisibleSize(); - CCSprite *player = CCSprite::create("Player.png", CCRectMake(0, 0, 27, 40) ); - player->setPosition( ccp(player->getContentSize().width/2, winSize.height/2) ); + CCSprite *player = CCSprite::create("Player.png", CCRectMake(0, 0, 27*_scaleRatio, 40*_scaleRatio) ); + + player->setPosition( ccp(origin.x + player->getContentSize().width/2, + origin.y + visibleSize.height/2) ); this->addChild(player); this->schedule( schedule_selector(HelloWorld::gameLogic), 1.0 ); @@ -124,8 +140,8 @@ void HelloWorld::menuCloseCallback(CCObject* pSender) // cpp with cocos2d-x void HelloWorld::addTarget() { - CCSprite *target = CCSprite::create("Target.png", CCRectMake(0,0,27,40) ); - + CCSprite *target = CCSprite::create("Target.png", CCRectMake(0,0,27*_scaleRatio,40*_scaleRatio) ); + // Determine where to spawn the target along the Y axis CCSize winSize = CCDirector::sharedDirector()->getVisibleSize(); float minY = target->getContentSize().height/2; @@ -196,7 +212,7 @@ void HelloWorld::ccTouchesEnded(CCSet* touches, CCEvent* event) // Set up initial location of projectile CCSize winSize = CCDirector::sharedDirector()->getVisibleSize(); - CCSprite *projectile = CCSprite::create("Projectile.png", CCRectMake(0, 0, 20, 20)); + CCSprite *projectile = CCSprite::create("Projectile.png", CCRectMake(0, 0, 20*_scaleRatio, 20*_scaleRatio)); projectile->setPosition( ccp(20, winSize.height/2) ); // Determinie offset of location to projectile diff --git a/samples/SimpleGame/Classes/HelloWorldScene.h b/samples/SimpleGame/Classes/HelloWorldScene.h index c1fcbd2f1c..d88c7aa81b 100755 --- a/samples/SimpleGame/Classes/HelloWorldScene.h +++ b/samples/SimpleGame/Classes/HelloWorldScene.h @@ -38,6 +38,7 @@ protected: cocos2d::CCArray *_targets; cocos2d::CCArray *_projectiles; int _projectilesDestroyed; + float _scaleRatio; void addTarget(); diff --git a/samples/SimpleGame/proj.ios/SimpleGame.xcodeproj/project.pbxproj b/samples/SimpleGame/proj.ios/SimpleGame.xcodeproj/project.pbxproj index 2d38dbc116..c968300d11 100644 --- a/samples/SimpleGame/proj.ios/SimpleGame.xcodeproj/project.pbxproj +++ b/samples/SimpleGame/proj.ios/SimpleGame.xcodeproj/project.pbxproj @@ -72,7 +72,7 @@ BF492D4B1289302400A09262 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; BF4DE6AB138BB89600CF907D /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; BF4DE6AC138BB89600CF907D /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; - D41A0AC5160F14F5004552AE /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + D41A0AC5160F14F5004552AE /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../proj.ios/Default-568h@2x.png"; sourceTree = ""; }; D4ABB4B213B4395300552E6E /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; D4E6BC7B15FCB477008BF525 /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = ""; }; D4E6BC9015FCB5BA008BF525 /* GameOverScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GameOverScene.cpp; sourceTree = ""; }; @@ -132,7 +132,6 @@ 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { isa = PBXGroup; children = ( - D41A0AC5160F14F5004552AE /* Default-568h@2x.png */, D4E6BC7B15FCB477008BF525 /* cocos2dx.xcodeproj */, BF23D4E2143315EB00657E08 /* Classes */, 29B97323FDCFA39411CA2CEA /* Frameworks */, @@ -164,6 +163,7 @@ 784521C214EBA449009D533B /* Resources */ = { isa = PBXGroup; children = ( + D41A0AC5160F14F5004552AE /* Default-568h@2x.png */, D4E6BCC415FCB6AA008BF525 /* background-music-aac.wav */, D4E6BCC515FCB6AA008BF525 /* hd */, D4E6BCC615FCB6AA008BF525 /* pew-pew-lei.wav */, From c50a62be7a2e2ab53f0b2ea0936acd13e6455462 Mon Sep 17 00:00:00 2001 From: walzer Date: Mon, 24 Sep 2012 10:54:03 +0800 Subject: [PATCH 109/181] issue #1482, fix typos, mehod -> method. --- samples/HelloCpp/proj.ios/AppController.mm | 2 +- samples/HelloLua/proj.ios/AppController.mm | 2 +- samples/SimpleGame/proj.ios/AppController.mm | 2 +- samples/TestCpp/proj.ios/Classes/testsAppDelegate.mm | 2 +- samples/TestJavascript/proj.ios/AppController.mm | 2 +- samples/TestLua/proj.ios/AppController.mm | 2 +- template/xcode4/base_ios.xctemplate/ios/AppController.mm | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/samples/HelloCpp/proj.ios/AppController.mm b/samples/HelloCpp/proj.ios/AppController.mm index 4f375d9efd..42ba3259fd 100644 --- a/samples/HelloCpp/proj.ios/AppController.mm +++ b/samples/HelloCpp/proj.ios/AppController.mm @@ -64,7 +64,7 @@ static AppDelegate s_sharedApplication; } else { - // use this mehod on ios6 + // use this method on ios6 [window setRootViewController:viewController]; } diff --git a/samples/HelloLua/proj.ios/AppController.mm b/samples/HelloLua/proj.ios/AppController.mm index 051b8b1735..ad66ebe66c 100644 --- a/samples/HelloLua/proj.ios/AppController.mm +++ b/samples/HelloLua/proj.ios/AppController.mm @@ -64,7 +64,7 @@ static AppDelegate s_sharedApplication; } else { - // use this mehod on ios6 + // use this method on ios6 [window setRootViewController:viewController]; } diff --git a/samples/SimpleGame/proj.ios/AppController.mm b/samples/SimpleGame/proj.ios/AppController.mm index 4f375d9efd..42ba3259fd 100644 --- a/samples/SimpleGame/proj.ios/AppController.mm +++ b/samples/SimpleGame/proj.ios/AppController.mm @@ -64,7 +64,7 @@ static AppDelegate s_sharedApplication; } else { - // use this mehod on ios6 + // use this method on ios6 [window setRootViewController:viewController]; } diff --git a/samples/TestCpp/proj.ios/Classes/testsAppDelegate.mm b/samples/TestCpp/proj.ios/Classes/testsAppDelegate.mm index 08986589d9..d49daad652 100644 --- a/samples/TestCpp/proj.ios/Classes/testsAppDelegate.mm +++ b/samples/TestCpp/proj.ios/Classes/testsAppDelegate.mm @@ -51,7 +51,7 @@ static AppDelegate s_sharedApplication; } else { - // use this mehod on ios6 + // use this method on ios6 [window setRootViewController:viewController]; } diff --git a/samples/TestJavascript/proj.ios/AppController.mm b/samples/TestJavascript/proj.ios/AppController.mm index 02ea9c66d1..3e3e5c9474 100644 --- a/samples/TestJavascript/proj.ios/AppController.mm +++ b/samples/TestJavascript/proj.ios/AppController.mm @@ -48,7 +48,7 @@ static AppDelegate s_sharedApplication; } else { - // use this mehod on ios6 + // use this method on ios6 [window setRootViewController:viewController]; } diff --git a/samples/TestLua/proj.ios/AppController.mm b/samples/TestLua/proj.ios/AppController.mm index 457a9fa0a3..cbccc23254 100644 --- a/samples/TestLua/proj.ios/AppController.mm +++ b/samples/TestLua/proj.ios/AppController.mm @@ -64,7 +64,7 @@ static AppDelegate s_sharedApplication; } else { - // use this mehod on ios6 + // use this method on ios6 [window setRootViewController:viewController]; } diff --git a/template/xcode4/base_ios.xctemplate/ios/AppController.mm b/template/xcode4/base_ios.xctemplate/ios/AppController.mm index 3d41726fb2..7e58c4fc5c 100644 --- a/template/xcode4/base_ios.xctemplate/ios/AppController.mm +++ b/template/xcode4/base_ios.xctemplate/ios/AppController.mm @@ -51,7 +51,7 @@ static AppDelegate s_sharedApplication; } else { - // use this mehod on ios6 + // use this method on ios6 [window setRootViewController:viewController]; } From 863b0b89a303a273945e2ba95ebef7584efdaccf Mon Sep 17 00:00:00 2001 From: dualface Date: Mon, 24 Sep 2012 10:58:43 +0800 Subject: [PATCH 110/181] Revert "[iOS] fix: enableRetina() and setDesignResolutionSize() can not be used simultaneously. FROM kunlun.com, THANKS" This reverts commit 6eabead4e3700bd71c8fef5e2b7f508080154118. --- cocos2dx/platform/ios/EAGLView.h | 4 --- cocos2dx/platform/ios/EAGLView.mm | 44 +++++++------------------------ 2 files changed, 10 insertions(+), 38 deletions(-) diff --git a/cocos2dx/platform/ios/EAGLView.h b/cocos2dx/platform/ios/EAGLView.h index 2605819266..64c83233ab 100755 --- a/cocos2dx/platform/ios/EAGLView.h +++ b/cocos2dx/platform/ios/EAGLView.h @@ -87,7 +87,6 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. BOOL preserveBackbuffer_; CGSize size_; - CGFloat designContentScaleFactor_; BOOL discardFramebufferSupported_; //fsaa addition @@ -143,9 +142,6 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. @property(nonatomic,readwrite) BOOL multiSampling; -/** call from AppController.mm */ --(void) setDesignContentScaleFactor:(CGFloat)scale; --(CGFloat) getDesignContentScaleFactor; /** EAGLView uses double-buffer. This method swaps the buffers */ -(void) swapBuffers; diff --git a/cocos2dx/platform/ios/EAGLView.mm b/cocos2dx/platform/ios/EAGLView.mm index e1807f3dd4..2f9ba0a360 100755 --- a/cocos2dx/platform/ios/EAGLView.mm +++ b/cocos2dx/platform/ios/EAGLView.mm @@ -134,7 +134,6 @@ static EAGLView *view = 0; { if((self = [super initWithFrame:frame])) { - designContentScaleFactor_ = 1.0; isUseUITextField = YES; pixelformat_ = format; depthFormat_ = depth; @@ -163,7 +162,6 @@ static EAGLView *view = 0; CAEAGLLayer* eaglLayer = (CAEAGLLayer*)[self layer]; - designContentScaleFactor_ = 1.0; pixelformat_ = kEAGLColorFormatRGB565; depthFormat_ = 0; // GL_DEPTH_COMPONENT24_OES; multiSampling_= NO; @@ -202,27 +200,15 @@ static EAGLView *view = 0; -(int) getWidth { CGSize bound = [self bounds].size; - return bound.width * designContentScaleFactor_; + return bound.width; } -(int) getHeight { CGSize bound = [self bounds].size; - return bound.height * designContentScaleFactor_; + return bound.height; } --(void) setDesignContentScaleFactor:(CGFloat)scale -{ - if ([self respondsToSelector:@selector(setContentScaleFactor:)]) { - [self setContentScaleFactor:scale]; // if val == 2.0, enable retina display - designContentScaleFactor_ = scale; - } -} - --(CGFloat) getDesignContentScaleFactor -{ - return designContentScaleFactor_; -} -(BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup { @@ -415,8 +401,8 @@ static EAGLView *view = 0; int i = 0; for (UITouch *touch in touches) { ids[i] = (int)touch; - xs[i] = [touch locationInView: [touch view]].x * designContentScaleFactor_; - ys[i] = [touch locationInView: [touch view]].y * designContentScaleFactor_; + xs[i] = [touch locationInView: [touch view]].x; + ys[i] = [touch locationInView: [touch view]].y; ++i; } cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesBegin(i, ids, xs, ys); @@ -435,8 +421,8 @@ static EAGLView *view = 0; int i = 0; for (UITouch *touch in touches) { ids[i] = (int)touch; - xs[i] = [touch locationInView: [touch view]].x * designContentScaleFactor_; - ys[i] = [touch locationInView: [touch view]].y * designContentScaleFactor_; + xs[i] = [touch locationInView: [touch view]].x; + ys[i] = [touch locationInView: [touch view]].y; ++i; } cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesMove(i, ids, xs, ys); @@ -456,8 +442,8 @@ static EAGLView *view = 0; int i = 0; for (UITouch *touch in touches) { ids[i] = (int)touch; - xs[i] = [touch locationInView: [touch view]].x * designContentScaleFactor_; - ys[i] = [touch locationInView: [touch view]].y * designContentScaleFactor_; + xs[i] = [touch locationInView: [touch view]].x; + ys[i] = [touch locationInView: [touch view]].y; ++i; } cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesEnd(i, ids, xs, ys); @@ -477,8 +463,8 @@ static EAGLView *view = 0; int i = 0; for (UITouch *touch in touches) { ids[i] = (int)touch; - xs[i] = [touch locationInView: [touch view]].x * designContentScaleFactor_; - ys[i] = [touch locationInView: [touch view]].y * designContentScaleFactor_; + xs[i] = [touch locationInView: [touch view]].x; + ys[i] = [touch locationInView: [touch view]].y; ++i; } cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesCancel(i, ids, xs, ys); @@ -800,15 +786,6 @@ static EAGLView *view = 0; break; } - begin.origin.x *= designContentScaleFactor_; - begin.origin.y *= designContentScaleFactor_; - begin.size.width *= designContentScaleFactor_; - begin.size.height *= designContentScaleFactor_; - end.origin.x *= designContentScaleFactor_; - end.origin.y *= designContentScaleFactor_; - end.size.width *= designContentScaleFactor_; - end.size.height *= designContentScaleFactor_; - cocos2d::CCIMEKeyboardNotificationInfo notiInfo; notiInfo.begin = cocos2d::CCRect(begin.origin.x, begin.origin.y, @@ -882,7 +859,6 @@ static EAGLView *view = 0; // NSLog(@"[animation] dis = %f\n", dis); if (dis < 0.0f) dis = 0.0f; - dis /= designContentScaleFactor_; if (!cocos2d::CCEGLView::sharedOpenGLView()->isRetinaEnabled()) { From 426915dd4a64b2c3bebdbce77a8f5f7ac32ff501 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 24 Sep 2012 11:05:15 +0800 Subject: [PATCH 111/181] fixed some compilation error for win32 platform. --- cocos2d-win32.vc2008.sln | 7 +-- cocos2d-win32.vc2010.sln | 1 + extensions/CCBReader/CCNodeLoader.cpp | 2 - .../TestJavascript/Classes/AppDelegate.cpp | 2 +- .../PerformanceTest/PerformanceSpriteTest.js | 2 +- .../Resources/js/test-easeactions.js | 2 + .../proj.win32/TestJavascript.vcproj | 32 ++++++++++--- .../proj.win32/TestJavascript.vcxproj | 12 +++-- .../proj.win32/TestJavascript.vcxproj.filters | 47 ++++++++++++------- .../javascript/bindings/ScriptingCore.cpp | 2 +- .../bindings/js_bindings_ccbreader.cpp | 1 - .../bindings/js_bindings_ccbreader.h | 8 +--- 12 files changed, 76 insertions(+), 42 deletions(-) diff --git a/cocos2d-win32.vc2008.sln b/cocos2d-win32.vc2008.sln index ca500ac82e..a21437128a 100644 --- a/cocos2d-win32.vc2008.sln +++ b/cocos2d-win32.vc2008.sln @@ -35,6 +35,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCpp", "samples\TestCpp\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestJavascript", "samples\TestJavascript\proj.win32\TestJavascript.vcproj", "{D0F06A44-A245-4D13-A498-0120C203B539}" ProjectSection(ProjectDependencies) = postProject + {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28} {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} @@ -53,6 +54,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestLua", "samples\TestLua\ EndProjectSection EndProject Global + GlobalSection(DPCodeReviewSolutionGUID) = preSolution + DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 @@ -106,7 +110,4 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(DPCodeReviewSolutionGUID) = preSolution - DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} - EndGlobalSection EndGlobal diff --git a/cocos2d-win32.vc2010.sln b/cocos2d-win32.vc2010.sln index 79ba236ca0..ddc9efe7a0 100644 --- a/cocos2d-win32.vc2010.sln +++ b/cocos2d-win32.vc2010.sln @@ -19,6 +19,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCpp", "samples\TestCpp\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestJavascript", "samples\TestJavascript\proj.win32\TestJavascript.vcxproj", "{D0F06A44-A245-4D13-A498-0120C203B539}" ProjectSection(ProjectDependencies) = postProject + {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28} {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} EndProjectSection EndProject diff --git a/extensions/CCBReader/CCNodeLoader.cpp b/extensions/CCBReader/CCNodeLoader.cpp index a482a867ad..c5729b7aa2 100644 --- a/extensions/CCBReader/CCNodeLoader.cpp +++ b/extensions/CCBReader/CCNodeLoader.cpp @@ -7,8 +7,6 @@ using namespace std; -USING_NS_CC; - NS_CC_EXT_BEGIN CCNode * CCNodeLoader::loadCCNode(CCNode * pParent, CCBReader * pCCBReader) { diff --git a/samples/TestJavascript/Classes/AppDelegate.cpp b/samples/TestJavascript/Classes/AppDelegate.cpp index d49d23112b..15a4ba180e 100644 --- a/samples/TestJavascript/Classes/AppDelegate.cpp +++ b/samples/TestJavascript/Classes/AppDelegate.cpp @@ -3,7 +3,7 @@ #include "cocos2d.h" #include "SimpleAudioEngine.h" #include "ScriptingCore.h" -#include "cocos2dx.hpp" +#include "generated/cocos2dx.hpp" #include "cocos2d_specifics.hpp" #include "js_bindings_chipmunk_manual.hpp" diff --git a/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceSpriteTest.js b/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceSpriteTest.js index 7bef5f9652..c69ce71cb7 100644 --- a/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceSpriteTest.js +++ b/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceSpriteTest.js @@ -429,7 +429,7 @@ function performanceActions20(sprite) { var growDuration = 0.5 + (Math.random() * 1000) / 500.0; var grow = cc.ScaleBy.create(growDuration, 0.5, 0.5); - var permanentScaleLoop = cc.RepeatForever.create(cc.Sequence._actionOneTwo(grow, grow.reverse())); + var permanentScaleLoop = cc.RepeatForever.create(cc.Sequence.create(grow, grow.reverse())); sprite.runAction(permanentScaleLoop); } diff --git a/samples/TestJavascript/Resources/js/test-easeactions.js b/samples/TestJavascript/Resources/js/test-easeactions.js index e88fc2d050..b9c64ac035 100644 --- a/samples/TestJavascript/Resources/js/test-easeactions.js +++ b/samples/TestJavascript/Resources/js/test-easeactions.js @@ -12,6 +12,8 @@ director = cc.Director.getInstance(); winSize = director.getWinSize(); centerPos = cc.p( winSize.width/2, winSize.height/2 ); +var TAG_ACTION1_EASE_ACTIONS = 1001; + var scenes = [] var currentScene = 0; diff --git a/samples/TestJavascript/proj.win32/TestJavascript.vcproj b/samples/TestJavascript/proj.win32/TestJavascript.vcproj index 1e44d6a6df..8af9dac184 100644 --- a/samples/TestJavascript/proj.win32/TestJavascript.vcproj +++ b/samples/TestJavascript/proj.win32/TestJavascript.vcproj @@ -49,7 +49,7 @@ + + + + + + + + + + Disabled - .;..\Classes;$(SolutionDir)scripting\javascript\spidermonkey-win32\include;$(SolutionDir)external\chipmunk\include\chipmunk;$(SolutionDir)scripting\javascript\bindings;$(SolutionDir)cocos2dx;$(SolutionDir)cocos2dx\include;$(SolutionDir)cocos2dx\kazmath\include;$(SolutionDir)cocos2dx\platform\win32;$(SolutionDir)cocos2dx\platform\third_party\win32;$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES;$(SolutionDir)CocosDenshion\include;%(AdditionalIncludeDirectories) + .;..\Classes;$(SolutionDir)scripting\javascript\spidermonkey-win32\include;$(SolutionDir)external\chipmunk\include\chipmunk;$(SolutionDir)scripting\javascript\bindings;$(SolutionDir)extensions;$(SolutionDir)cocos2dx;$(SolutionDir)cocos2dx\include;$(SolutionDir)cocos2dx\kazmath\include;$(SolutionDir)cocos2dx\platform\win32;$(SolutionDir)cocos2dx\platform\third_party\win32;$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES;$(SolutionDir)CocosDenshion\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks @@ -106,7 +106,7 @@ xcopy /Y /Q "$(SolutionDir)scripting\javascript\spidermonkey-win32\lib\*.*" "$(O testjs_p.c - .;..\Classes;$(SolutionDir)scripting\javascript\spidermonkey-win32\include;$(SolutionDir)external\chipmunk\include\chipmunk;$(SolutionDir)scripting\javascript\bindings;$(SolutionDir)cocos2dx;$(SolutionDir)cocos2dx\include;$(SolutionDir)cocos2dx\kazmath\include;$(SolutionDir)cocos2dx\platform\win32;$(SolutionDir)cocos2dx\platform\third_party\win32;$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES;$(SolutionDir)CocosDenshion\include;%(AdditionalIncludeDirectories) + .;..\Classes;$(SolutionDir)scripting\javascript\spidermonkey-win32\include;$(SolutionDir)external\chipmunk\include\chipmunk;$(SolutionDir)scripting\javascript\bindings;$(SolutionDir)extensions;$(SolutionDir)cocos2dx;$(SolutionDir)cocos2dx\include;$(SolutionDir)cocos2dx\kazmath\include;$(SolutionDir)cocos2dx\platform\win32;$(SolutionDir)cocos2dx\platform\third_party\win32;$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES;$(SolutionDir)CocosDenshion\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -137,8 +137,10 @@ xcopy /Y /Q "$(SolutionDir)scripting\javascript\spidermonkey-win32\lib\*.*" "$(O - + + + @@ -148,8 +150,10 @@ xcopy /Y /Q "$(SolutionDir)scripting\javascript\spidermonkey-win32\lib\*.*" "$(O - + + + diff --git a/samples/TestJavascript/proj.win32/TestJavascript.vcxproj.filters b/samples/TestJavascript/proj.win32/TestJavascript.vcxproj.filters index 8fb8c38806..93bc5303f2 100644 --- a/samples/TestJavascript/proj.win32/TestJavascript.vcxproj.filters +++ b/samples/TestJavascript/proj.win32/TestJavascript.vcxproj.filters @@ -14,6 +14,9 @@ {e93a77e1-af1e-4400-87d3-504b62ebdbb0} + + {146f26cf-13e1-4106-891b-4b0118ceac2b} + @@ -22,15 +25,6 @@ Classes - - bindings - - - bindings - - - bindings - bindings @@ -43,6 +37,21 @@ bindings + + bindings + + + bindings + + + bindings + + + bindings + + + bindings\generated + @@ -54,13 +63,7 @@ Classes - - bindings - - - bindings - - + bindings @@ -81,6 +84,18 @@ bindings + + bindings + + + bindings + + + bindings + + + bindings\generated + diff --git a/scripting/javascript/bindings/ScriptingCore.cpp b/scripting/javascript/bindings/ScriptingCore.cpp index 550bc9adfe..b4c6878578 100644 --- a/scripting/javascript/bindings/ScriptingCore.cpp +++ b/scripting/javascript/bindings/ScriptingCore.cpp @@ -421,7 +421,7 @@ JSBool ScriptingCore::forceGC(JSContext *cx, uint32_t argc, jsval *vp) static void dumpNamedRoot(const char *name, void *addr, JSGCRootType type, void *data) { - printf("Root: '%s' at %p\n", name, addr); + CCLOG("Root: '%s' at %p", name, addr); } JSBool ScriptingCore::dumpRoot(JSContext *cx, uint32_t argc, jsval *vp) diff --git a/scripting/javascript/bindings/js_bindings_ccbreader.cpp b/scripting/javascript/bindings/js_bindings_ccbreader.cpp index 50e7e98a35..0244706f0f 100644 --- a/scripting/javascript/bindings/js_bindings_ccbreader.cpp +++ b/scripting/javascript/bindings/js_bindings_ccbreader.cpp @@ -8,7 +8,6 @@ #include "js_bindings_ccbreader.h" #include "ScriptingCore.h" -#include "CCNodeLoaderLibrary.h" USING_NS_CC; USING_NS_CC_EXT; diff --git a/scripting/javascript/bindings/js_bindings_ccbreader.h b/scripting/javascript/bindings/js_bindings_ccbreader.h index 2ddc9f60c0..ef66a5adbd 100644 --- a/scripting/javascript/bindings/js_bindings_ccbreader.h +++ b/scripting/javascript/bindings/js_bindings_ccbreader.h @@ -6,13 +6,7 @@ // // #include "jsapi.h" -#include "CCBReader.h" -#include "CCBSelectorResolver.h" -#include "CCBMemberVariableAssigner.h" -#include "CCInvocation.h" -#include "ExtensionMacros.h" -#include "CCLayerLoader.h" - +#include "cocos-ext.h" #include "cocos2d_specifics.hpp" From a413496a1a442479a40bb0d438665fc065dc570a Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 24 Sep 2012 11:08:10 +0800 Subject: [PATCH 112/181] Delete 'cocos2d::' since extension is the sub-namespace of cocos2d. --- extensions/CCBReader/CCBAnimationManager.h | 54 +++++++++---------- extensions/CCBReader/CCBKeyframe.h | 8 +-- .../CCBReader/CCBMemberVariableAssigner.h | 2 +- extensions/CCBReader/CCBSelectorResolver.h | 4 +- extensions/CCBReader/CCBSequence.h | 2 +- extensions/CCBReader/CCBSequenceProperty.h | 2 +- extensions/CCBReader/CCBValue.cpp | 2 +- extensions/CCBReader/CCBValue.h | 10 ++-- extensions/CCBReader/CCData.h | 2 +- .../CCBReader/CCNode+CCBRelativePositioning.h | 4 +- extensions/CCBReader/CCNodeLoader.h | 4 +- .../GUI/CCControlExtension/CCInvocation.h | 8 +-- extensions/network/HttpClient.h | 2 +- extensions/network/HttpRequest.h | 10 ++-- extensions/network/HttpResponse.h | 2 +- 15 files changed, 58 insertions(+), 58 deletions(-) diff --git a/extensions/CCBReader/CCBAnimationManager.h b/extensions/CCBReader/CCBAnimationManager.h index 7bec78474b..1c6aa0db88 100644 --- a/extensions/CCBReader/CCBAnimationManager.h +++ b/extensions/CCBReader/CCBAnimationManager.h @@ -15,15 +15,15 @@ public: virtual void completedAnimationSequenceNamed(const char *name) = 0; }; -class CCBAnimationManager : public cocos2d::CCObject +class CCBAnimationManager : public CCObject { private: - cocos2d::CCArray *mSequences; - cocos2d::CCDictionary *mNodeSequences; - cocos2d::CCDictionary *mBaseValues; + CCArray *mSequences; + CCDictionary *mNodeSequences; + CCDictionary *mBaseValues; int mAutoPlaySequenceId; - cocos2d::CCNode *mRootNode; + CCNode *mRootNode; CCSize mRootContainerSize; CCBAnimationManagerDelegate *mDelegate; @@ -35,26 +35,26 @@ public: virtual bool init(); - cocos2d::CCArray* getSequences(); + CCArray* getSequences(); int getAutoPlaySequenceId(); void setAutoPlaySequenceId(int autoPlaySequenceId); - cocos2d::CCNode* getRootNode(); - void setRootNode(cocos2d::CCNode* pRootNode); // retain + CCNode* getRootNode(); + void setRootNode(CCNode* pRootNode); // retain - const cocos2d::CCSize& getRootContainerSize(); - void setRootContainerSize(const cocos2d::CCSize &rootContainerSize); + const CCSize& getRootContainerSize(); + void setRootContainerSize(const CCSize &rootContainerSize); CCBAnimationManagerDelegate* getDelegate(); void setDelegate(CCBAnimationManagerDelegate* pDelegate); // retain const char* getRunningSequenceName(); - const CCSize& getContainerSize(cocos2d::CCNode* pNode); + const CCSize& getContainerSize(CCNode* pNode); - void addNode(cocos2d::CCNode *pNode, cocos2d::CCDictionary *pSeq); - void setBaseValue(cocos2d::CCObject *pValue, cocos2d::CCNode *pNode, const char *pPropName); + void addNode(CCNode *pNode, CCDictionary *pSeq); + void setBaseValue(CCObject *pValue, CCNode *pNode, const char *pPropName); void runAnimations(const char *pName, float fTweenDuration); void runAnimations(const char *pName); @@ -63,33 +63,33 @@ public: void debug(); private: - cocos2d::CCObject* getBaseValue(cocos2d::CCNode *pNode, const char* pPropName); + CCObject* getBaseValue(CCNode *pNode, const char* pPropName); int getSequenceId(const char* pSequenceName); CCBSequence* getSequence(int nSequenceId); - cocos2d::CCActionInterval* getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const char *pPropName, cocos2d::CCNode *pNode); - void setAnimatedProperty(const char *pPropName, cocos2d::CCNode *pNode, cocos2d::CCObject *pValue, float fTweenDuraion); - void setFirstFrame(cocos2d::CCNode *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration); - cocos2d::CCActionInterval* getEaseAction(cocos2d::CCActionInterval *pAction, int nEasingType, float fEasingOpt); - void runAction(cocos2d::CCNode *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration); + CCActionInterval* getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const char *pPropName, CCNode *pNode); + void setAnimatedProperty(const char *pPropName, CCNode *pNode, CCObject *pValue, float fTweenDuraion); + void setFirstFrame(CCNode *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration); + CCActionInterval* getEaseAction(CCActionInterval *pAction, int nEasingType, float fEasingOpt); + void runAction(CCNode *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration); void sequenceCompleted(); }; -class CCBSetSpriteFrame : public cocos2d::CCActionInstant +class CCBSetSpriteFrame : public CCActionInstant { private: - cocos2d::CCSpriteFrame *mSpriteFrame; + CCSpriteFrame *mSpriteFrame; public: ~CCBSetSpriteFrame(); /** creates a Place action with a position */ - static CCBSetSpriteFrame* create(cocos2d::CCSpriteFrame *pSpriteFrame); - bool initWithSpriteFrame(cocos2d::CCSpriteFrame *pSpriteFrame); + static CCBSetSpriteFrame* create(CCSpriteFrame *pSpriteFrame); + bool initWithSpriteFrame(CCSpriteFrame *pSpriteFrame); virtual void update(float time); - virtual cocos2d::CCObject* copyWithZone(cocos2d::CCZone *pZone); + virtual CCObject* copyWithZone(CCZone *pZone); }; -class CCBRotateTo : public cocos2d::CCActionInterval +class CCBRotateTo : public CCActionInterval { private: float mStartAngle; @@ -100,8 +100,8 @@ public: static CCBRotateTo* create(float fDuration, float fAngle); bool initWithDuration(float fDuration, float fAngle); virtual void update(float time); - virtual cocos2d::CCObject* copyWithZone(cocos2d::CCZone *pZone); - virtual void startWithTarget(cocos2d::CCNode *pNode); + virtual CCObject* copyWithZone(CCZone *pZone); + virtual void startWithTarget(CCNode *pNode); }; NS_CC_EXT_END diff --git a/extensions/CCBReader/CCBKeyframe.h b/extensions/CCBReader/CCBKeyframe.h index 6a53760551..76d54ed02a 100644 --- a/extensions/CCBReader/CCBKeyframe.h +++ b/extensions/CCBReader/CCBKeyframe.h @@ -6,10 +6,10 @@ NS_CC_EXT_BEGIN -class CCBKeyframe : public cocos2d::CCObject +class CCBKeyframe : public CCObject { private: - cocos2d::CCObject *mValue; + CCObject *mValue; float mTime; int mEasingType; float mEasingOpt; @@ -18,8 +18,8 @@ public: CCBKeyframe(); ~CCBKeyframe(); - cocos2d::CCObject* getValue(); - void setValue(cocos2d::CCObject *pValue); // retain + CCObject* getValue(); + void setValue(CCObject *pValue); // retain float getTime(); void setTime(float fTime); diff --git a/extensions/CCBReader/CCBMemberVariableAssigner.h b/extensions/CCBReader/CCBMemberVariableAssigner.h index 41801d7980..9ca7cd8c8b 100644 --- a/extensions/CCBReader/CCBMemberVariableAssigner.h +++ b/extensions/CCBReader/CCBMemberVariableAssigner.h @@ -21,7 +21,7 @@ class CCBMemberVariableAssigner { public: virtual ~CCBMemberVariableAssigner() {}; - virtual bool onAssignCCBMemberVariable(CCObject * pTarget, cocos2d::CCString * pMemberVariableName, CCNode * pNode) = 0; + virtual bool onAssignCCBMemberVariable(CCObject * pTarget, CCString * pMemberVariableName, CCNode * pNode) = 0; }; NS_CC_EXT_END diff --git a/extensions/CCBReader/CCBSelectorResolver.h b/extensions/CCBReader/CCBSelectorResolver.h index 97d5c5df5b..2845f49aca 100644 --- a/extensions/CCBReader/CCBSelectorResolver.h +++ b/extensions/CCBReader/CCBSelectorResolver.h @@ -19,9 +19,9 @@ NS_CC_EXT_BEGIN class CCBSelectorResolver { public: virtual ~CCBSelectorResolver() {}; - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) = 0; + virtual SEL_MenuHandler onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) = 0; - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) = 0; + virtual extension::SEL_CCControlHandler onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) = 0; }; diff --git a/extensions/CCBReader/CCBSequence.h b/extensions/CCBReader/CCBSequence.h index b253f19888..80e4f6ce2c 100644 --- a/extensions/CCBReader/CCBSequence.h +++ b/extensions/CCBReader/CCBSequence.h @@ -7,7 +7,7 @@ NS_CC_EXT_BEGIN -class CCBSequence : public cocos2d::CCObject +class CCBSequence : public CCObject { private: float mDuration; diff --git a/extensions/CCBReader/CCBSequenceProperty.h b/extensions/CCBReader/CCBSequenceProperty.h index 4e790eeff4..0680700e39 100644 --- a/extensions/CCBReader/CCBSequenceProperty.h +++ b/extensions/CCBReader/CCBSequenceProperty.h @@ -7,7 +7,7 @@ NS_CC_EXT_BEGIN -class CCBSequenceProperty : public cocos2d::CCObject +class CCBSequenceProperty : public CCObject { private: std::string mName; diff --git a/extensions/CCBReader/CCBValue.cpp b/extensions/CCBReader/CCBValue.cpp index 3be6398bc1..79c93fb409 100644 --- a/extensions/CCBReader/CCBValue.cpp +++ b/extensions/CCBReader/CCBValue.cpp @@ -6,7 +6,7 @@ NS_CC_EXT_BEGIN // Implementation of ccColor3BWapper -ccColor3BWapper* ccColor3BWapper::create(const cocos2d::ccColor3B& color) +ccColor3BWapper* ccColor3BWapper::create(const ccColor3B& color) { ccColor3BWapper *ret = new ccColor3BWapper(); if (ret) diff --git a/extensions/CCBReader/CCBValue.h b/extensions/CCBReader/CCBValue.h index 2e760eb765..4c4c67332f 100644 --- a/extensions/CCBReader/CCBValue.h +++ b/extensions/CCBReader/CCBValue.h @@ -10,15 +10,15 @@ NS_CC_EXT_BEGIN -class ccColor3BWapper : public cocos2d::CCObject +class ccColor3BWapper : public CCObject { private: - cocos2d::ccColor3B color; + ccColor3B color; public: - static ccColor3BWapper* create(const cocos2d::ccColor3B& color); + static ccColor3BWapper* create(const ccColor3B& color); - const cocos2d::ccColor3B& getColor(); + const ccColor3B& getColor(); }; enum @@ -30,7 +30,7 @@ enum kUnsignedCharValue, }; -class CCBValue : public cocos2d::CCObject +class CCBValue : public CCObject { private: union diff --git a/extensions/CCBReader/CCData.h b/extensions/CCBReader/CCData.h index 5861339ab5..22b5dd967c 100644 --- a/extensions/CCBReader/CCData.h +++ b/extensions/CCBReader/CCData.h @@ -7,7 +7,7 @@ NS_CC_EXT_BEGIN -class CCData : public cocos2d::CCObject +class CCData : public CCObject { public: CCData(unsigned char *pBytes, const unsigned long nSize); diff --git a/extensions/CCBReader/CCNode+CCBRelativePositioning.h b/extensions/CCBReader/CCNode+CCBRelativePositioning.h index 066fb6202c..5de79563ea 100644 --- a/extensions/CCBReader/CCNode+CCBRelativePositioning.h +++ b/extensions/CCBReader/CCNode+CCBRelativePositioning.h @@ -6,9 +6,9 @@ NS_CC_EXT_BEGIN -extern cocos2d::CCPoint getAbsolutePosition(const cocos2d::CCPoint &pt, int nType, const cocos2d::CCSize &containerSize, const char *pPropName); +extern CCPoint getAbsolutePosition(const CCPoint &pt, int nType, const CCSize &containerSize, const char *pPropName); -extern void setRelativeScale(cocos2d::CCNode *pNode, float fScaleX, float fScaleY, int nType, const char* pPropName); +extern void setRelativeScale(CCNode *pNode, float fScaleX, float fScaleY, int nType, const char* pPropName); NS_CC_EXT_END diff --git a/extensions/CCBReader/CCNodeLoader.h b/extensions/CCBReader/CCNodeLoader.h index 175e96f0aa..f59134ebc9 100644 --- a/extensions/CCBReader/CCNodeLoader.h +++ b/extensions/CCBReader/CCNodeLoader.h @@ -19,11 +19,11 @@ NS_CC_EXT_BEGIN #define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) CCLog("Unexpected property: '%s'!\n", PROPERTY->getCString()); assert(false) #define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) CCLog("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false) -#define CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createCCNode(cocos2d::CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) { \ +#define CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createCCNode(CCNode * pParent, extension::CCBReader * pCCBReader) { \ return T::create(); \ } -#define CCB_PURE_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createCCNode(cocos2d::CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) = 0 +#define CCB_PURE_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createCCNode(CCNode * pParent, extension::CCBReader * pCCBReader) = 0 struct BlockData { SEL_MenuHandler mSELMenuHandler; diff --git a/extensions/GUI/CCControlExtension/CCInvocation.h b/extensions/GUI/CCControlExtension/CCInvocation.h index 034e57ea48..9aa88ad2d7 100644 --- a/extensions/GUI/CCControlExtension/CCInvocation.h +++ b/extensions/GUI/CCControlExtension/CCInvocation.h @@ -19,20 +19,20 @@ NS_CC_EXT_BEGIN typedef unsigned int CCControlEvent; -typedef void (cocos2d::CCObject::*SEL_CCControlHandler)(cocos2d::CCObject*, CCControlEvent); +typedef void (CCObject::*SEL_CCControlHandler)(CCObject*, CCControlEvent); #define cccontrol_selector(_SELECTOR) (SEL_CCControlHandler)(&_SELECTOR) -class CCInvocation : public cocos2d::CCObject +class CCInvocation : public CCObject { CC_SYNTHESIZE_READONLY(SEL_CCControlHandler, m_action, Action); CC_SYNTHESIZE_READONLY(CCObject*, m_target, Target); CC_SYNTHESIZE_READONLY(CCControlEvent, m_controlEvent, ControlEvent); public: - CCInvocation(cocos2d::CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent); + CCInvocation(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent); - void invoke(cocos2d::CCObject* sender); + void invoke(CCObject* sender); }; // end of GUI group diff --git a/extensions/network/HttpClient.h b/extensions/network/HttpClient.h index c63d32042a..41a227a83a 100644 --- a/extensions/network/HttpClient.h +++ b/extensions/network/HttpClient.h @@ -43,7 +43,7 @@ NS_CC_EXT_BEGIN /** @brief Singleton that handles asynchrounous http requests * Once the request completed, a callback will issued in main thread when it provided during make request */ -class CCHttpClient : public cocos2d::CCObject +class CCHttpClient : public CCObject { public: /** Return the shared instance **/ diff --git a/extensions/network/HttpRequest.h b/extensions/network/HttpRequest.h index 89c1a3f812..c6dd2a8781 100644 --- a/extensions/network/HttpRequest.h +++ b/extensions/network/HttpRequest.h @@ -35,7 +35,7 @@ NS_CC_EXT_BEGIN Please refer to samples/TestCpp/Classes/ExtensionTest/NetworkTest/HttpClientTest.cpp as a sample @since v2.0.2 */ -class CCHttpRequest : public cocos2d::CCObject +class CCHttpRequest : public CCObject { public: /** Use this enum type as param in setReqeustType(param) */ @@ -155,7 +155,7 @@ public: /** Required field. You should set the callback selector function at ack the http request completed */ - inline void setResponseCallback(cocos2d::CCObject* pTarget, cocos2d::SEL_CallFuncND pSelector) + inline void setResponseCallback(CCObject* pTarget, SEL_CallFuncND pSelector) { _pTarget = pTarget; _pSelector = pSelector; @@ -171,7 +171,7 @@ public: return _pTarget; } /** Get the selector function pointer, mainly used by CCHttpClient */ - inline cocos2d::SEL_CallFuncND getSelector() + inline SEL_CallFuncND getSelector() { return _pSelector; } @@ -182,8 +182,8 @@ protected: std::string _url; /// target url that this request is sent to std::vector _requestData; /// used for POST std::string _tag; /// user defined tag, to identify different requests in response callback - cocos2d::CCObject* _pTarget; /// callback target of pSelector function - cocos2d::SEL_CallFuncND _pSelector; /// callback function, e.g. MyLayer::onHttpResponse(CCObject *sender, void *data) + CCObject* _pTarget; /// callback target of pSelector function + SEL_CallFuncND _pSelector; /// callback function, e.g. MyLayer::onHttpResponse(CCObject *sender, void *data) void* _pUserData; /// You can add your customed data here }; diff --git a/extensions/network/HttpResponse.h b/extensions/network/HttpResponse.h index 4a5921221f..d0321451fb 100644 --- a/extensions/network/HttpResponse.h +++ b/extensions/network/HttpResponse.h @@ -36,7 +36,7 @@ NS_CC_EXT_BEGIN Please refer to samples/TestCpp/Classes/ExtensionTest/NetworkTest/HttpClientTest.cpp as a sample @since v2.0.2 */ -class CCHttpResponse : public cocos2d::CCObject +class CCHttpResponse : public CCObject { public: /** Constructor, it's used by CCHttpClient internal, users don't need to create HttpResponse manually From e4cee68688ebb057ee49bdcd86abc632f9e60b7b Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 24 Sep 2012 11:47:33 +0800 Subject: [PATCH 113/181] Added libExtensions.lib for TestJavascript vs2010 project. Removed some calling of 'USING_NS_CC;' in extensions. --- extensions/CCBReader/CCBFileLoader.cpp | 2 +- extensions/CCBReader/CCBReader.cpp | 2 +- extensions/CCBReader/CCBReader.h | 2 +- extensions/CCBReader/CCBSelectorResolver.h | 2 +- extensions/CCBReader/CCControlButtonLoader.cpp | 2 +- extensions/CCBReader/CCControlLoader.cpp | 2 +- extensions/CCBReader/CCLabelBMFontLoader.cpp | 2 +- extensions/CCBReader/CCLabelTTFLoader.cpp | 2 +- extensions/CCBReader/CCLayerColorLoader.cpp | 2 +- extensions/CCBReader/CCLayerGradientLoader.cpp | 2 +- extensions/CCBReader/CCLayerLoader.cpp | 2 +- extensions/CCBReader/CCMenuItemImageLoader.cpp | 2 +- extensions/CCBReader/CCMenuItemLoader.cpp | 2 +- extensions/CCBReader/CCNodeLoaderLibrary.cpp | 2 +- extensions/CCBReader/CCNodeLoaderLibrary.h | 2 ++ extensions/CCBReader/CCParticleSystemQuadLoader.cpp | 2 +- extensions/CCBReader/CCScale9SpriteLoader.cpp | 2 +- extensions/CCBReader/CCScrollViewLoader.cpp | 2 +- extensions/CCBReader/CCSpriteLoader.cpp | 2 -- samples/TestJavascript/proj.win32/TestJavascript.vcxproj | 4 ++-- scripting/javascript/bindings/CCPhysicsSprite.h | 4 ++++ scripting/javascript/bindings/cocosjs_manual_conversions.h | 6 ++++++ scripting/javascript/bindings/js_bindings_ccbreader.h | 6 ++++++ .../javascript/bindings/js_bindings_chipmunk_functions.hpp | 6 +++++- scripting/javascript/bindings/js_manual_conversions.h | 5 +++++ 25 files changed, 47 insertions(+), 22 deletions(-) diff --git a/extensions/CCBReader/CCBFileLoader.cpp b/extensions/CCBReader/CCBFileLoader.cpp index dabe5c955c..d51136d0d8 100644 --- a/extensions/CCBReader/CCBFileLoader.cpp +++ b/extensions/CCBReader/CCBFileLoader.cpp @@ -1,6 +1,6 @@ #include "CCBFileLoader.h" -USING_NS_CC; + NS_CC_EXT_BEGIN diff --git a/extensions/CCBReader/CCBReader.cpp b/extensions/CCBReader/CCBReader.cpp index 814952232c..7b43222d40 100644 --- a/extensions/CCBReader/CCBReader.cpp +++ b/extensions/CCBReader/CCBReader.cpp @@ -20,7 +20,7 @@ #endif using namespace std; -USING_NS_CC; + NS_CC_EXT_BEGIN; /************************************************************************* diff --git a/extensions/CCBReader/CCBReader.h b/extensions/CCBReader/CCBReader.h index 091f2a1007..406b128663 100644 --- a/extensions/CCBReader/CCBReader.h +++ b/extensions/CCBReader/CCBReader.h @@ -128,7 +128,7 @@ enum kCCBScaleTypeMultiplyResolution }; -USING_NS_CC; + NS_CC_EXT_BEGIN /** diff --git a/extensions/CCBReader/CCBSelectorResolver.h b/extensions/CCBReader/CCBSelectorResolver.h index 2845f49aca..b71cff9426 100644 --- a/extensions/CCBReader/CCBSelectorResolver.h +++ b/extensions/CCBReader/CCBSelectorResolver.h @@ -5,7 +5,7 @@ #include "ExtensionMacros.h" #include "../GUI/CCControlExtension/CCInvocation.h" -USING_NS_CC; + NS_CC_EXT_BEGIN #define CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(TARGET, SELECTORNAME, METHOD) if(pTarget == TARGET && pSelectorName->compare(SELECTORNAME) == 0) { \ diff --git a/extensions/CCBReader/CCControlButtonLoader.cpp b/extensions/CCBReader/CCControlButtonLoader.cpp index 4c439cbed0..07ac8b28c9 100644 --- a/extensions/CCBReader/CCControlButtonLoader.cpp +++ b/extensions/CCBReader/CCControlButtonLoader.cpp @@ -1,6 +1,6 @@ #include "CCControlButtonLoader.h" -USING_NS_CC; + NS_CC_EXT_BEGIN; #define PROPERTY_ZOOMONTOUCHDOWN "zoomOnTouchDown" diff --git a/extensions/CCBReader/CCControlLoader.cpp b/extensions/CCBReader/CCControlLoader.cpp index 8def017a8f..65566cce8e 100644 --- a/extensions/CCBReader/CCControlLoader.cpp +++ b/extensions/CCBReader/CCControlLoader.cpp @@ -1,6 +1,6 @@ #include "CCControlLoader.h" -USING_NS_CC; + NS_CC_EXT_BEGIN #define PROPERTY_ENABLED "enabled" diff --git a/extensions/CCBReader/CCLabelBMFontLoader.cpp b/extensions/CCBReader/CCLabelBMFontLoader.cpp index 51fe5cb13b..628d70fb5e 100644 --- a/extensions/CCBReader/CCLabelBMFontLoader.cpp +++ b/extensions/CCBReader/CCLabelBMFontLoader.cpp @@ -1,6 +1,6 @@ #include "CCLabelBMFontLoader.h" -USING_NS_CC; + NS_CC_EXT_BEGIN diff --git a/extensions/CCBReader/CCLabelTTFLoader.cpp b/extensions/CCBReader/CCLabelTTFLoader.cpp index 0ad2265e9a..db9545bfcd 100644 --- a/extensions/CCBReader/CCLabelTTFLoader.cpp +++ b/extensions/CCBReader/CCLabelTTFLoader.cpp @@ -1,6 +1,6 @@ #include "CCLabelTTFLoader.h" -USING_NS_CC; + #define PROPERTY_COLOR "color" #define PROPERTY_OPACITY "opacity" diff --git a/extensions/CCBReader/CCLayerColorLoader.cpp b/extensions/CCBReader/CCLayerColorLoader.cpp index 6d98beac21..ed8cb50726 100644 --- a/extensions/CCBReader/CCLayerColorLoader.cpp +++ b/extensions/CCBReader/CCLayerColorLoader.cpp @@ -1,6 +1,6 @@ #include "CCLayerColorLoader.h" -USING_NS_CC; + NS_CC_EXT_BEGIN diff --git a/extensions/CCBReader/CCLayerGradientLoader.cpp b/extensions/CCBReader/CCLayerGradientLoader.cpp index eef3cbccf4..4f560b673f 100644 --- a/extensions/CCBReader/CCLayerGradientLoader.cpp +++ b/extensions/CCBReader/CCLayerGradientLoader.cpp @@ -1,6 +1,6 @@ #include "CCLayerGradientLoader.h" -USING_NS_CC; + #define PROPERTY_STARTCOLOR "startColor" #define PROPERTY_ENDCOLOR "endColor" diff --git a/extensions/CCBReader/CCLayerLoader.cpp b/extensions/CCBReader/CCLayerLoader.cpp index 9442f7da99..7ae52430c4 100644 --- a/extensions/CCBReader/CCLayerLoader.cpp +++ b/extensions/CCBReader/CCLayerLoader.cpp @@ -1,6 +1,6 @@ #include "CCLayerLoader.h" -USING_NS_CC; + #define PROPERTY_TOUCH_ENABLED "isTouchEnabled" diff --git a/extensions/CCBReader/CCMenuItemImageLoader.cpp b/extensions/CCBReader/CCMenuItemImageLoader.cpp index c8a8f6d24d..10d65300d3 100644 --- a/extensions/CCBReader/CCMenuItemImageLoader.cpp +++ b/extensions/CCBReader/CCMenuItemImageLoader.cpp @@ -1,6 +1,6 @@ #include "CCMenuItemImageLoader.h" -USING_NS_CC; + #define PROPERTY_NORMALDISPLAYFRAME "normalSpriteFrame" #define PROPERTY_SELECTEDDISPLAYFRAME "selectedSpriteFrame" diff --git a/extensions/CCBReader/CCMenuItemLoader.cpp b/extensions/CCBReader/CCMenuItemLoader.cpp index a68bf881ac..08cc487e91 100644 --- a/extensions/CCBReader/CCMenuItemLoader.cpp +++ b/extensions/CCBReader/CCMenuItemLoader.cpp @@ -1,6 +1,6 @@ #include "CCMenuItemLoader.h" -USING_NS_CC; + #define PROPERTY_BLOCK "block" #define PROPERTY_ISENABLED "isEnabled" diff --git a/extensions/CCBReader/CCNodeLoaderLibrary.cpp b/extensions/CCBReader/CCNodeLoaderLibrary.cpp index 736f66b0df..35c791cc81 100644 --- a/extensions/CCBReader/CCNodeLoaderLibrary.cpp +++ b/extensions/CCBReader/CCNodeLoaderLibrary.cpp @@ -15,7 +15,7 @@ #include "CCParticleSystemQuadLoader.h" #include "CCScrollViewLoader.h" -USING_NS_CC; + NS_CC_EXT_BEGIN diff --git a/extensions/CCBReader/CCNodeLoaderLibrary.h b/extensions/CCBReader/CCNodeLoaderLibrary.h index 13e2bcb095..e7fb01bd94 100644 --- a/extensions/CCBReader/CCNodeLoaderLibrary.h +++ b/extensions/CCBReader/CCNodeLoaderLibrary.h @@ -6,6 +6,8 @@ NS_CC_EXT_BEGIN +class CCNodeLoader; + typedef std::map CCNodeLoaderMap; typedef std::pair CCNodeLoaderMapEntry; diff --git a/extensions/CCBReader/CCParticleSystemQuadLoader.cpp b/extensions/CCBReader/CCParticleSystemQuadLoader.cpp index ac8fbe3340..1c525a5431 100644 --- a/extensions/CCBReader/CCParticleSystemQuadLoader.cpp +++ b/extensions/CCBReader/CCParticleSystemQuadLoader.cpp @@ -1,6 +1,6 @@ #include "CCParticleSystemQuadLoader.h" -USING_NS_CC; + #define PROPERTY_EMITERMODE "emitterMode" #define PROPERTY_POSVAR "posVar" diff --git a/extensions/CCBReader/CCScale9SpriteLoader.cpp b/extensions/CCBReader/CCScale9SpriteLoader.cpp index 2eac14fa5a..4027e93b98 100644 --- a/extensions/CCBReader/CCScale9SpriteLoader.cpp +++ b/extensions/CCBReader/CCScale9SpriteLoader.cpp @@ -1,6 +1,6 @@ #include "CCScale9SpriteLoader.h" -USING_NS_CC; + #define PROPERTY_CONTENTSIZE "contentSize" #define PROPERTY_SPRITEFRAME "spriteFrame" diff --git a/extensions/CCBReader/CCScrollViewLoader.cpp b/extensions/CCBReader/CCScrollViewLoader.cpp index 387b01ada8..48b21410ca 100644 --- a/extensions/CCBReader/CCScrollViewLoader.cpp +++ b/extensions/CCBReader/CCScrollViewLoader.cpp @@ -1,6 +1,6 @@ #include "CCScrollViewLoader.h" -USING_NS_CC; + #define PROPERTY_CONTAINER "container" #define PROPERTY_DIRECTION "direction" diff --git a/extensions/CCBReader/CCSpriteLoader.cpp b/extensions/CCBReader/CCSpriteLoader.cpp index 6c487b54d1..dc29774a05 100644 --- a/extensions/CCBReader/CCSpriteLoader.cpp +++ b/extensions/CCBReader/CCSpriteLoader.cpp @@ -1,7 +1,5 @@ #include "CCSpriteLoader.h" -USING_NS_CC; - #define PROPERTY_FLIP "flip" #define PROPERTY_DISPLAYFRAME "displayFrame" #define PROPERTY_COLOR "color" diff --git a/samples/TestJavascript/proj.win32/TestJavascript.vcxproj b/samples/TestJavascript/proj.win32/TestJavascript.vcxproj index a7407cde10..109771451f 100644 --- a/samples/TestJavascript/proj.win32/TestJavascript.vcxproj +++ b/samples/TestJavascript/proj.win32/TestJavascript.vcxproj @@ -85,7 +85,7 @@ xcopy /Y /Q "$(SolutionDir)scripting\javascript\spidermonkey-win32\lib\*.*" "$(O - libcocos2d.lib;opengl32.lib;glew32.lib;libCocosDenshion.lib;libchipmunk.lib;mozjs.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;opengl32.lib;glew32.lib;libCocosDenshion.lib;libchipmunk.lib;mozjs.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -129,7 +129,7 @@ xcopy /Y /Q "$(SolutionDir)scripting\javascript\spidermonkey-win32\lib\*.*" "$(O - libcocos2d.lib;opengl32.lib;glew32.lib;libCocosDenshion.lib;libchipmunk.lib;mozjs.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;opengl32.lib;glew32.lib;libCocosDenshion.lib;libchipmunk.lib;mozjs.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 diff --git a/scripting/javascript/bindings/CCPhysicsSprite.h b/scripting/javascript/bindings/CCPhysicsSprite.h index 27b9d50270..f849b4520b 100644 --- a/scripting/javascript/bindings/CCPhysicsSprite.h +++ b/scripting/javascript/bindings/CCPhysicsSprite.h @@ -1,3 +1,6 @@ +#ifndef __CCPHYSICSSPRITE_H__ +#define __CCPHYSICSSPRITE_H__ + #include "sprite_nodes/CCSprite.h" #include "chipmunk.h" @@ -24,3 +27,4 @@ public: virtual void setRotation(float rotation); }; +#endif /* __CCPHYSICSSPRITE_H__ */ diff --git a/scripting/javascript/bindings/cocosjs_manual_conversions.h b/scripting/javascript/bindings/cocosjs_manual_conversions.h index 7a32f4c7a9..444deb1e68 100644 --- a/scripting/javascript/bindings/cocosjs_manual_conversions.h +++ b/scripting/javascript/bindings/cocosjs_manual_conversions.h @@ -1,3 +1,6 @@ +#ifndef __COCOSJS_MANUAL_CONVERSIONS_H__ +#define __COCOSJS_MANUAL_CONVERSIONS_H__ + #include "chipmunk.h" #include "cocos2d.h" #include "js_manual_conversions.h" @@ -17,3 +20,6 @@ jsval cpBB_to_jsval(JSContext *cx, cpBB bb ); #define cpVect_to_jsval CGPoint_to_jsval #define jsval_to_cpVect jsval_to_CGPoint + +#endif /* __COCOSJS_MANUAL_CONVERSIONS_H__ */ + diff --git a/scripting/javascript/bindings/js_bindings_ccbreader.h b/scripting/javascript/bindings/js_bindings_ccbreader.h index ef66a5adbd..a847cf3e44 100644 --- a/scripting/javascript/bindings/js_bindings_ccbreader.h +++ b/scripting/javascript/bindings/js_bindings_ccbreader.h @@ -5,6 +5,9 @@ // Created by Rohan Kuruvilla on 14/08/2012. // // +#ifndef __JS_BINDINGS_CCBREADER_H__ +#define __JS_BINDINGS_CCBREADER_H__ + #include "jsapi.h" #include "cocos-ext.h" #include "cocos2d_specifics.hpp" @@ -54,3 +57,6 @@ protected: void register_CCBuilderReader(JSContext *cx, JSObject *global); JSBool js_CocosBuilder_Run(JSContext *cx, uint32_t argc, jsval *vp); + +#endif /* __JS_BINDINGS_CCBREADER_H__ */ + diff --git a/scripting/javascript/bindings/js_bindings_chipmunk_functions.hpp b/scripting/javascript/bindings/js_bindings_chipmunk_functions.hpp index b8baf60267..21bd2b0d61 100644 --- a/scripting/javascript/bindings/js_bindings_chipmunk_functions.hpp +++ b/scripting/javascript/bindings/js_bindings_chipmunk_functions.hpp @@ -2,7 +2,8 @@ // Created by Rohan Kuruvilla // Copyright (c) 2012 Zynga Inc. All rights reserved. // - +#ifndef __JS_BINDINGS_CHIPMUNK_FUNCTIONS_HPP__ +#define __JS_BINDINGS_CHIPMUNK_FUNCTIONS_HPP__ JSBool JSPROXY_cpArbiterGetCount(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSPROXY_cpArbiterGetDepth(JSContext *cx, uint32_t argc, jsval *vp); @@ -280,3 +281,6 @@ JSBool JSPROXY_cpvslerpconst(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSPROXY_cpvsub(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSPROXY_cpvtoangle(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSPROXY_cpvunrotate(JSContext *cx, uint32_t argc, jsval *vp); + +#endif /* __JS_BINDINGS_CHIPMUNK_FUNCTIONS_HPP__ */ + diff --git a/scripting/javascript/bindings/js_manual_conversions.h b/scripting/javascript/bindings/js_manual_conversions.h index e67da4de09..c815bc04cf 100644 --- a/scripting/javascript/bindings/js_manual_conversions.h +++ b/scripting/javascript/bindings/js_manual_conversions.h @@ -2,6 +2,8 @@ // Created by Rohan Kuruvilla // Copyright (c) 2012 Zynga Inc. All rights reserved. // +#ifndef __JS_MANUAL_CONVERSIONS_H__ +#define __JS_MANUAL_CONVERSIONS_H__ #include "jsapi.h" @@ -21,3 +23,6 @@ jsval opaque_to_jsval( JSContext *cx, void* opaque); #ifdef __cplusplus } #endif + +#endif /* __JS_MANUAL_CONVERSIONS_H__ */ + From 5dfeb46235399cdfff201175ead97f482e7c3a73 Mon Sep 17 00:00:00 2001 From: walzer Date: Mon, 24 Sep 2012 11:58:29 +0800 Subject: [PATCH 114/181] move cxx-generator submodule pointer from db61f83 to 40ad793 as Rolando committed. --- tools/cxx-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cxx-generator b/tools/cxx-generator index db61f83996..40ad79373b 160000 --- a/tools/cxx-generator +++ b/tools/cxx-generator @@ -1 +1 @@ -Subproject commit db61f8399655dd90f09d550259b45ae8289364fe +Subproject commit 40ad79373b6c041a3312afb36da6985b91f0a3dc From e20b933f1a67d330cf647c03f5b1af0cbfc26e4b Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 24 Sep 2012 13:57:45 +0800 Subject: [PATCH 115/181] make TestJavaScript work and fix some warnings --- .../TestJavascript/Classes/AppDelegate.cpp | 2 - .../TestJavascript.xcodeproj/project.pbxproj | 459 +++++++++++++++--- .../javascript/bindings/cocos2d_specifics.hpp | 2 +- .../bindings/cocosjs_manual_conversions.h | 12 +- .../bindings/js_bindings_ccbreader.cpp | 2 +- .../bindings/js_bindings_chipmunk_manual.cpp | 2 +- .../bindings/js_manual_conversions.h | 28 +- 7 files changed, 425 insertions(+), 82 deletions(-) diff --git a/samples/TestJavascript/Classes/AppDelegate.cpp b/samples/TestJavascript/Classes/AppDelegate.cpp index 15a4ba180e..21b7b00104 100644 --- a/samples/TestJavascript/Classes/AppDelegate.cpp +++ b/samples/TestJavascript/Classes/AppDelegate.cpp @@ -34,8 +34,6 @@ bool AppDelegate::applicationDidFinishLaunching() // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); - CCScene * pScene = CCScene::create(); - ScriptingCore* sc = ScriptingCore::getInstance(); sc->addRegisterCallback(register_all_cocos2dx); sc->addRegisterCallback(register_cocos2dx_js_extensions); diff --git a/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj b/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj index d3b05e614b..ac3ec3c0fe 100644 --- a/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj +++ b/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj @@ -28,13 +28,58 @@ 15628F7815F0F5E5000CF24B /* tank1.png in Resources */ = {isa = PBXBuildFile; fileRef = 15628F6915F0F5E5000CF24B /* tank1.png */; }; 15628F7915F0F5E5000CF24B /* TileMaps in Resources */ = {isa = PBXBuildFile; fileRef = 15628F6A15F0F5E5000CF24B /* TileMaps */; }; 15628FA915F1057E000CF24B /* animations in Resources */ = {isa = PBXBuildFile; fileRef = 15628FA815F1057E000CF24B /* animations */; }; - 2628296215EC6C1B002C4240 /* ScriptingCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628295315EC6C1B002C4240 /* ScriptingCore.cpp */; }; - 2628296315EC6C1B002C4240 /* js_manual_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628295515EC6C1B002C4240 /* js_manual_conversions.cpp */; }; - 2628296415EC6C1B002C4240 /* js_bindings_chipmunk_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628295815EC6C1B002C4240 /* js_bindings_chipmunk_manual.cpp */; }; - 2628296515EC6C1B002C4240 /* js_bindings_chipmunk_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628295A15EC6C1B002C4240 /* js_bindings_chipmunk_functions.cpp */; }; - 2628296615EC6C1B002C4240 /* cocos2dx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628295C15EC6C1B002C4240 /* cocos2dx.cpp */; }; - 2628296715EC6C1B002C4240 /* cocos2d_specifics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628295E15EC6C1B002C4240 /* cocos2d_specifics.cpp */; }; - 2628296815EC6C1B002C4240 /* CCPhysicsSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628296015EC6C1B002C4240 /* CCPhysicsSprite.cpp */; }; + 15B37833161012B2008B02E1 /* CCBAnimationManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377C1161012B2008B02E1 /* CCBAnimationManager.cpp */; }; + 15B37834161012B2008B02E1 /* CCBFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377C3161012B2008B02E1 /* CCBFileLoader.cpp */; }; + 15B37835161012B2008B02E1 /* CCBKeyframe.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377C5161012B2008B02E1 /* CCBKeyframe.cpp */; }; + 15B37836161012B2008B02E1 /* CCBReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377C8161012B2008B02E1 /* CCBReader.cpp */; }; + 15B37837161012B2008B02E1 /* CCBSequence.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377CB161012B2008B02E1 /* CCBSequence.cpp */; }; + 15B37838161012B2008B02E1 /* CCBSequenceProperty.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377CD161012B2008B02E1 /* CCBSequenceProperty.cpp */; }; + 15B37839161012B2008B02E1 /* CCBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377CF161012B2008B02E1 /* CCBValue.cpp */; }; + 15B3783A161012B2008B02E1 /* CCControlButtonLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377D1161012B2008B02E1 /* CCControlButtonLoader.cpp */; }; + 15B3783B161012B2008B02E1 /* CCControlLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377D3161012B2008B02E1 /* CCControlLoader.cpp */; }; + 15B3783C161012B2008B02E1 /* CCData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377D5161012B2008B02E1 /* CCData.cpp */; }; + 15B3783D161012B2008B02E1 /* CCLabelBMFontLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377D7161012B2008B02E1 /* CCLabelBMFontLoader.cpp */; }; + 15B3783E161012B2008B02E1 /* CCLabelTTFLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377D9161012B2008B02E1 /* CCLabelTTFLoader.cpp */; }; + 15B3783F161012B2008B02E1 /* CCLayerColorLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377DB161012B2008B02E1 /* CCLayerColorLoader.cpp */; }; + 15B37840161012B2008B02E1 /* CCLayerGradientLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377DD161012B2008B02E1 /* CCLayerGradientLoader.cpp */; }; + 15B37841161012B2008B02E1 /* CCLayerLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377DF161012B2008B02E1 /* CCLayerLoader.cpp */; }; + 15B37842161012B2008B02E1 /* CCMenuItemImageLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377E1161012B2008B02E1 /* CCMenuItemImageLoader.cpp */; }; + 15B37843161012B2008B02E1 /* CCMenuItemLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377E3161012B2008B02E1 /* CCMenuItemLoader.cpp */; }; + 15B37844161012B2008B02E1 /* CCNode+CCBRelativePositioning.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377E6161012B2008B02E1 /* CCNode+CCBRelativePositioning.cpp */; }; + 15B37845161012B2008B02E1 /* CCNodeLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377E8161012B2008B02E1 /* CCNodeLoader.cpp */; }; + 15B37846161012B2008B02E1 /* CCNodeLoaderLibrary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377EA161012B2008B02E1 /* CCNodeLoaderLibrary.cpp */; }; + 15B37847161012B2008B02E1 /* CCParticleSystemQuadLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377ED161012B2008B02E1 /* CCParticleSystemQuadLoader.cpp */; }; + 15B37848161012B2008B02E1 /* CCScale9SpriteLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377EF161012B2008B02E1 /* CCScale9SpriteLoader.cpp */; }; + 15B37849161012B2008B02E1 /* CCScrollViewLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377F1161012B2008B02E1 /* CCScrollViewLoader.cpp */; }; + 15B3784A161012B2008B02E1 /* CCSpriteLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B377F3161012B2008B02E1 /* CCSpriteLoader.cpp */; }; + 15B3789C1610142E008B02E1 /* CCControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378701610142E008B02E1 /* CCControl.cpp */; }; + 15B3789D1610142E008B02E1 /* CCControlButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378721610142E008B02E1 /* CCControlButton.cpp */; }; + 15B3789E1610142E008B02E1 /* CCControlColourPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378741610142E008B02E1 /* CCControlColourPicker.cpp */; }; + 15B3789F1610142E008B02E1 /* CCControlHuePicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378771610142E008B02E1 /* CCControlHuePicker.cpp */; }; + 15B378A01610142E008B02E1 /* CCControlSaturationBrightnessPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378791610142E008B02E1 /* CCControlSaturationBrightnessPicker.cpp */; }; + 15B378A11610142E008B02E1 /* CCControlSlider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B3787B1610142E008B02E1 /* CCControlSlider.cpp */; }; + 15B378A21610142E008B02E1 /* CCControlSwitch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B3787D1610142E008B02E1 /* CCControlSwitch.cpp */; }; + 15B378A31610142E008B02E1 /* CCControlUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B3787F1610142E008B02E1 /* CCControlUtils.cpp */; }; + 15B378A41610142E008B02E1 /* CCInvocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378811610142E008B02E1 /* CCInvocation.cpp */; }; + 15B378A51610142E008B02E1 /* CCMenuPassive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378831610142E008B02E1 /* CCMenuPassive.cpp */; }; + 15B378A61610142E008B02E1 /* CCScale9Sprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378851610142E008B02E1 /* CCScale9Sprite.cpp */; }; + 15B378A71610142E008B02E1 /* CCSpacer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378871610142E008B02E1 /* CCSpacer.cpp */; }; + 15B378A81610142E008B02E1 /* CCEditBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B3788A1610142E008B02E1 /* CCEditBox.cpp */; }; + 15B378AA1610142E008B02E1 /* CCEditBoxImplIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 15B378901610142E008B02E1 /* CCEditBoxImplIOS.mm */; }; + 15B378AB1610142E008B02E1 /* EditBoxImplIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 15B378921610142E008B02E1 /* EditBoxImplIOS.mm */; }; + 15B378AC1610142E008B02E1 /* CCScrollView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378941610142E008B02E1 /* CCScrollView.cpp */; }; + 15B378AD1610142E008B02E1 /* CCSorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378961610142E008B02E1 /* CCSorting.cpp */; }; + 15B378AE1610142E008B02E1 /* CCTableView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378981610142E008B02E1 /* CCTableView.cpp */; }; + 15B378AF1610142E008B02E1 /* CCTableViewCell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B3789A1610142E008B02E1 /* CCTableViewCell.cpp */; }; + 15B378CB16102B59008B02E1 /* CCPhysicsSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378B216102B59008B02E1 /* CCPhysicsSprite.cpp */; }; + 15B378CC16102B59008B02E1 /* cocos2d_specifics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378B416102B59008B02E1 /* cocos2d_specifics.cpp */; }; + 15B378CD16102B59008B02E1 /* cocosjs_manual_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378B616102B59008B02E1 /* cocosjs_manual_conversions.cpp */; }; + 15B378CE16102B59008B02E1 /* cocos2dx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378B916102B59008B02E1 /* cocos2dx.cpp */; }; + 15B378D116102B59008B02E1 /* js_bindings_ccbreader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378BD16102B59008B02E1 /* js_bindings_ccbreader.cpp */; }; + 15B378D216102B59008B02E1 /* js_bindings_chipmunk_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378BF16102B59008B02E1 /* js_bindings_chipmunk_functions.cpp */; }; + 15B378D316102B59008B02E1 /* js_bindings_chipmunk_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378C116102B59008B02E1 /* js_bindings_chipmunk_manual.cpp */; }; + 15B378D416102B59008B02E1 /* js_manual_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378C416102B59008B02E1 /* js_manual_conversions.cpp */; }; + 15B378D516102B59008B02E1 /* ScriptingCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B378C616102B59008B02E1 /* ScriptingCore.cpp */; }; 262829CC15EC7196002C4240 /* .gitignore in Resources */ = {isa = PBXBuildFile; fileRef = 2628297D15EC7196002C4240 /* .gitignore */; }; 262829CD15EC7196002C4240 /* Android.mk in Resources */ = {isa = PBXBuildFile; fileRef = 2628297E15EC7196002C4240 /* Android.mk */; }; 262829CE15EC7196002C4240 /* chipmunk-docs.html in Resources */ = {isa = PBXBuildFile; fileRef = 2628297F15EC7196002C4240 /* chipmunk-docs.html */; }; @@ -142,23 +187,121 @@ 15628F6915F0F5E5000CF24B /* tank1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = tank1.png; path = ../Resources/tank1.png; sourceTree = ""; }; 15628F6A15F0F5E5000CF24B /* TileMaps */ = {isa = PBXFileReference; lastKnownFileType = folder; name = TileMaps; path = ../Resources/TileMaps; sourceTree = ""; }; 15628FA815F1057E000CF24B /* animations */ = {isa = PBXFileReference; lastKnownFileType = folder; name = animations; path = ../Resources/animations; sourceTree = ""; }; - 2628295015EC6C1B002C4240 /* uthash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uthash.h; sourceTree = ""; }; - 2628295115EC6C1B002C4240 /* spidermonkey_specifics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spidermonkey_specifics.h; sourceTree = ""; }; - 2628295215EC6C1B002C4240 /* ScriptingCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptingCore.h; sourceTree = ""; }; - 2628295315EC6C1B002C4240 /* ScriptingCore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptingCore.cpp; sourceTree = ""; }; - 2628295415EC6C1B002C4240 /* js_manual_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_manual_conversions.h; sourceTree = ""; }; - 2628295515EC6C1B002C4240 /* js_manual_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_manual_conversions.cpp; sourceTree = ""; }; - 2628295615EC6C1B002C4240 /* js_bindings_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_config.h; sourceTree = ""; }; - 2628295715EC6C1B002C4240 /* js_bindings_chipmunk_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = js_bindings_chipmunk_manual.hpp; sourceTree = ""; }; - 2628295815EC6C1B002C4240 /* js_bindings_chipmunk_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_manual.cpp; sourceTree = ""; }; - 2628295915EC6C1B002C4240 /* js_bindings_chipmunk_functions.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = js_bindings_chipmunk_functions.hpp; sourceTree = ""; }; - 2628295A15EC6C1B002C4240 /* js_bindings_chipmunk_functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_functions.cpp; sourceTree = ""; }; - 2628295B15EC6C1B002C4240 /* cocos2dx.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cocos2dx.hpp; sourceTree = ""; }; - 2628295C15EC6C1B002C4240 /* cocos2dx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocos2dx.cpp; sourceTree = ""; }; - 2628295D15EC6C1B002C4240 /* cocos2d_specifics.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cocos2d_specifics.hpp; sourceTree = ""; }; - 2628295E15EC6C1B002C4240 /* cocos2d_specifics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocos2d_specifics.cpp; sourceTree = ""; }; - 2628295F15EC6C1B002C4240 /* CCPhysicsSprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsSprite.h; sourceTree = ""; }; - 2628296015EC6C1B002C4240 /* CCPhysicsSprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsSprite.cpp; sourceTree = ""; }; + 15B377C1161012B2008B02E1 /* CCBAnimationManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBAnimationManager.cpp; sourceTree = ""; }; + 15B377C2161012B2008B02E1 /* CCBAnimationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBAnimationManager.h; sourceTree = ""; }; + 15B377C3161012B2008B02E1 /* CCBFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBFileLoader.cpp; sourceTree = ""; }; + 15B377C4161012B2008B02E1 /* CCBFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBFileLoader.h; sourceTree = ""; }; + 15B377C5161012B2008B02E1 /* CCBKeyframe.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBKeyframe.cpp; sourceTree = ""; }; + 15B377C6161012B2008B02E1 /* CCBKeyframe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBKeyframe.h; sourceTree = ""; }; + 15B377C7161012B2008B02E1 /* CCBMemberVariableAssigner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBMemberVariableAssigner.h; sourceTree = ""; }; + 15B377C8161012B2008B02E1 /* CCBReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBReader.cpp; sourceTree = ""; }; + 15B377C9161012B2008B02E1 /* CCBReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBReader.h; sourceTree = ""; }; + 15B377CA161012B2008B02E1 /* CCBSelectorResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBSelectorResolver.h; sourceTree = ""; }; + 15B377CB161012B2008B02E1 /* CCBSequence.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBSequence.cpp; sourceTree = ""; }; + 15B377CC161012B2008B02E1 /* CCBSequence.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBSequence.h; sourceTree = ""; }; + 15B377CD161012B2008B02E1 /* CCBSequenceProperty.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBSequenceProperty.cpp; sourceTree = ""; }; + 15B377CE161012B2008B02E1 /* CCBSequenceProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBSequenceProperty.h; sourceTree = ""; }; + 15B377CF161012B2008B02E1 /* CCBValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBValue.cpp; sourceTree = ""; }; + 15B377D0161012B2008B02E1 /* CCBValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBValue.h; sourceTree = ""; }; + 15B377D1161012B2008B02E1 /* CCControlButtonLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlButtonLoader.cpp; sourceTree = ""; }; + 15B377D2161012B2008B02E1 /* CCControlButtonLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlButtonLoader.h; sourceTree = ""; }; + 15B377D3161012B2008B02E1 /* CCControlLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlLoader.cpp; sourceTree = ""; }; + 15B377D4161012B2008B02E1 /* CCControlLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlLoader.h; sourceTree = ""; }; + 15B377D5161012B2008B02E1 /* CCData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCData.cpp; sourceTree = ""; }; + 15B377D6161012B2008B02E1 /* CCData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCData.h; sourceTree = ""; }; + 15B377D7161012B2008B02E1 /* CCLabelBMFontLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLabelBMFontLoader.cpp; sourceTree = ""; }; + 15B377D8161012B2008B02E1 /* CCLabelBMFontLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLabelBMFontLoader.h; sourceTree = ""; }; + 15B377D9161012B2008B02E1 /* CCLabelTTFLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLabelTTFLoader.cpp; sourceTree = ""; }; + 15B377DA161012B2008B02E1 /* CCLabelTTFLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLabelTTFLoader.h; sourceTree = ""; }; + 15B377DB161012B2008B02E1 /* CCLayerColorLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLayerColorLoader.cpp; sourceTree = ""; }; + 15B377DC161012B2008B02E1 /* CCLayerColorLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLayerColorLoader.h; sourceTree = ""; }; + 15B377DD161012B2008B02E1 /* CCLayerGradientLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLayerGradientLoader.cpp; sourceTree = ""; }; + 15B377DE161012B2008B02E1 /* CCLayerGradientLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLayerGradientLoader.h; sourceTree = ""; }; + 15B377DF161012B2008B02E1 /* CCLayerLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLayerLoader.cpp; sourceTree = ""; }; + 15B377E0161012B2008B02E1 /* CCLayerLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLayerLoader.h; sourceTree = ""; }; + 15B377E1161012B2008B02E1 /* CCMenuItemImageLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMenuItemImageLoader.cpp; sourceTree = ""; }; + 15B377E2161012B2008B02E1 /* CCMenuItemImageLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMenuItemImageLoader.h; sourceTree = ""; }; + 15B377E3161012B2008B02E1 /* CCMenuItemLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMenuItemLoader.cpp; sourceTree = ""; }; + 15B377E4161012B2008B02E1 /* CCMenuItemLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMenuItemLoader.h; sourceTree = ""; }; + 15B377E5161012B2008B02E1 /* CCMenuLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMenuLoader.h; sourceTree = ""; }; + 15B377E6161012B2008B02E1 /* CCNode+CCBRelativePositioning.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "CCNode+CCBRelativePositioning.cpp"; sourceTree = ""; }; + 15B377E7161012B2008B02E1 /* CCNode+CCBRelativePositioning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CCNode+CCBRelativePositioning.h"; sourceTree = ""; }; + 15B377E8161012B2008B02E1 /* CCNodeLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCNodeLoader.cpp; sourceTree = ""; }; + 15B377E9161012B2008B02E1 /* CCNodeLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeLoader.h; sourceTree = ""; }; + 15B377EA161012B2008B02E1 /* CCNodeLoaderLibrary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCNodeLoaderLibrary.cpp; sourceTree = ""; }; + 15B377EB161012B2008B02E1 /* CCNodeLoaderLibrary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeLoaderLibrary.h; sourceTree = ""; }; + 15B377EC161012B2008B02E1 /* CCNodeLoaderListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeLoaderListener.h; sourceTree = ""; }; + 15B377ED161012B2008B02E1 /* CCParticleSystemQuadLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCParticleSystemQuadLoader.cpp; sourceTree = ""; }; + 15B377EE161012B2008B02E1 /* CCParticleSystemQuadLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCParticleSystemQuadLoader.h; sourceTree = ""; }; + 15B377EF161012B2008B02E1 /* CCScale9SpriteLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScale9SpriteLoader.cpp; sourceTree = ""; }; + 15B377F0161012B2008B02E1 /* CCScale9SpriteLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScale9SpriteLoader.h; sourceTree = ""; }; + 15B377F1161012B2008B02E1 /* CCScrollViewLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScrollViewLoader.cpp; sourceTree = ""; }; + 15B377F2161012B2008B02E1 /* CCScrollViewLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScrollViewLoader.h; sourceTree = ""; }; + 15B377F3161012B2008B02E1 /* CCSpriteLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSpriteLoader.cpp; sourceTree = ""; }; + 15B377F4161012B2008B02E1 /* CCSpriteLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSpriteLoader.h; sourceTree = ""; }; + 15B377F5161012B2008B02E1 /* cocos-ext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "cocos-ext.h"; sourceTree = ""; }; + 15B377F6161012B2008B02E1 /* ExtensionMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtensionMacros.h; sourceTree = ""; }; + 15B378701610142E008B02E1 /* CCControl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControl.cpp; sourceTree = ""; }; + 15B378711610142E008B02E1 /* CCControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControl.h; sourceTree = ""; }; + 15B378721610142E008B02E1 /* CCControlButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlButton.cpp; sourceTree = ""; }; + 15B378731610142E008B02E1 /* CCControlButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlButton.h; sourceTree = ""; }; + 15B378741610142E008B02E1 /* CCControlColourPicker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlColourPicker.cpp; sourceTree = ""; }; + 15B378751610142E008B02E1 /* CCControlColourPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlColourPicker.h; sourceTree = ""; }; + 15B378761610142E008B02E1 /* CCControlExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlExtensions.h; sourceTree = ""; }; + 15B378771610142E008B02E1 /* CCControlHuePicker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlHuePicker.cpp; sourceTree = ""; }; + 15B378781610142E008B02E1 /* CCControlHuePicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlHuePicker.h; sourceTree = ""; }; + 15B378791610142E008B02E1 /* CCControlSaturationBrightnessPicker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSaturationBrightnessPicker.cpp; sourceTree = ""; }; + 15B3787A1610142E008B02E1 /* CCControlSaturationBrightnessPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlSaturationBrightnessPicker.h; sourceTree = ""; }; + 15B3787B1610142E008B02E1 /* CCControlSlider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSlider.cpp; sourceTree = ""; }; + 15B3787C1610142E008B02E1 /* CCControlSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlSlider.h; sourceTree = ""; }; + 15B3787D1610142E008B02E1 /* CCControlSwitch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSwitch.cpp; sourceTree = ""; }; + 15B3787E1610142E008B02E1 /* CCControlSwitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlSwitch.h; sourceTree = ""; }; + 15B3787F1610142E008B02E1 /* CCControlUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlUtils.cpp; sourceTree = ""; }; + 15B378801610142E008B02E1 /* CCControlUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlUtils.h; sourceTree = ""; }; + 15B378811610142E008B02E1 /* CCInvocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCInvocation.cpp; sourceTree = ""; }; + 15B378821610142E008B02E1 /* CCInvocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCInvocation.h; sourceTree = ""; }; + 15B378831610142E008B02E1 /* CCMenuPassive.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMenuPassive.cpp; sourceTree = ""; }; + 15B378841610142E008B02E1 /* CCMenuPassive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMenuPassive.h; sourceTree = ""; }; + 15B378851610142E008B02E1 /* CCScale9Sprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScale9Sprite.cpp; sourceTree = ""; }; + 15B378861610142E008B02E1 /* CCScale9Sprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScale9Sprite.h; sourceTree = ""; }; + 15B378871610142E008B02E1 /* CCSpacer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSpacer.cpp; sourceTree = ""; }; + 15B378881610142E008B02E1 /* CCSpacer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSpacer.h; sourceTree = ""; }; + 15B3788A1610142E008B02E1 /* CCEditBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCEditBox.cpp; sourceTree = ""; }; + 15B3788B1610142E008B02E1 /* CCEditBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEditBox.h; sourceTree = ""; }; + 15B3788C1610142E008B02E1 /* CCEditBoxImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImpl.h; sourceTree = ""; }; + 15B3788F1610142E008B02E1 /* CCEditBoxImplIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImplIOS.h; sourceTree = ""; }; + 15B378901610142E008B02E1 /* CCEditBoxImplIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CCEditBoxImplIOS.mm; sourceTree = ""; }; + 15B378911610142E008B02E1 /* EditBoxImplIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditBoxImplIOS.h; sourceTree = ""; }; + 15B378921610142E008B02E1 /* EditBoxImplIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EditBoxImplIOS.mm; sourceTree = ""; }; + 15B378941610142E008B02E1 /* CCScrollView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScrollView.cpp; sourceTree = ""; }; + 15B378951610142E008B02E1 /* CCScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScrollView.h; sourceTree = ""; }; + 15B378961610142E008B02E1 /* CCSorting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSorting.cpp; sourceTree = ""; }; + 15B378971610142E008B02E1 /* CCSorting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSorting.h; sourceTree = ""; }; + 15B378981610142E008B02E1 /* CCTableView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTableView.cpp; sourceTree = ""; }; + 15B378991610142E008B02E1 /* CCTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTableView.h; sourceTree = ""; }; + 15B3789A1610142E008B02E1 /* CCTableViewCell.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTableViewCell.cpp; sourceTree = ""; }; + 15B3789B1610142E008B02E1 /* CCTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTableViewCell.h; sourceTree = ""; }; + 15B378B216102B59008B02E1 /* CCPhysicsSprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsSprite.cpp; sourceTree = ""; }; + 15B378B316102B59008B02E1 /* CCPhysicsSprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsSprite.h; sourceTree = ""; }; + 15B378B416102B59008B02E1 /* cocos2d_specifics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocos2d_specifics.cpp; sourceTree = ""; }; + 15B378B516102B59008B02E1 /* cocos2d_specifics.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cocos2d_specifics.hpp; sourceTree = ""; }; + 15B378B616102B59008B02E1 /* cocosjs_manual_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocosjs_manual_conversions.cpp; sourceTree = ""; }; + 15B378B716102B59008B02E1 /* cocosjs_manual_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cocosjs_manual_conversions.h; sourceTree = ""; }; + 15B378B916102B59008B02E1 /* cocos2dx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocos2dx.cpp; sourceTree = ""; }; + 15B378BA16102B59008B02E1 /* cocos2dx.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cocos2dx.hpp; sourceTree = ""; }; + 15B378BD16102B59008B02E1 /* js_bindings_ccbreader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_ccbreader.cpp; sourceTree = ""; }; + 15B378BE16102B59008B02E1 /* js_bindings_ccbreader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_ccbreader.h; sourceTree = ""; }; + 15B378BF16102B59008B02E1 /* js_bindings_chipmunk_functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_functions.cpp; sourceTree = ""; }; + 15B378C016102B59008B02E1 /* js_bindings_chipmunk_functions.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = js_bindings_chipmunk_functions.hpp; sourceTree = ""; }; + 15B378C116102B59008B02E1 /* js_bindings_chipmunk_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_manual.cpp; sourceTree = ""; }; + 15B378C216102B59008B02E1 /* js_bindings_chipmunk_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = js_bindings_chipmunk_manual.hpp; sourceTree = ""; }; + 15B378C316102B59008B02E1 /* js_bindings_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_config.h; sourceTree = ""; }; + 15B378C416102B59008B02E1 /* js_manual_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_manual_conversions.cpp; sourceTree = ""; }; + 15B378C516102B59008B02E1 /* js_manual_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_manual_conversions.h; sourceTree = ""; }; + 15B378C616102B59008B02E1 /* ScriptingCore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptingCore.cpp; sourceTree = ""; }; + 15B378C716102B59008B02E1 /* ScriptingCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptingCore.h; sourceTree = ""; }; + 15B378C816102B59008B02E1 /* spidermonkey_specifics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spidermonkey_specifics.h; sourceTree = ""; }; + 15B378C916102B59008B02E1 /* uthash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uthash.h; sourceTree = ""; }; 2628297D15EC7196002C4240 /* .gitignore */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .gitignore; sourceTree = ""; }; 2628297E15EC7196002C4240 /* Android.mk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Android.mk; sourceTree = ""; }; 2628297F15EC7196002C4240 /* chipmunk-docs.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "chipmunk-docs.html"; sourceTree = ""; }; @@ -340,6 +483,185 @@ name = Resources; sourceTree = ""; }; + 15B377BE161012B2008B02E1 /* extensions */ = { + isa = PBXGroup; + children = ( + 15B3786E1610142E008B02E1 /* GUI */, + 15B377C0161012B2008B02E1 /* CCBReader */, + 15B377F5161012B2008B02E1 /* cocos-ext.h */, + 15B377F6161012B2008B02E1 /* ExtensionMacros.h */, + ); + name = extensions; + path = ../../../extensions; + sourceTree = ""; + }; + 15B377C0161012B2008B02E1 /* CCBReader */ = { + isa = PBXGroup; + children = ( + 15B377C1161012B2008B02E1 /* CCBAnimationManager.cpp */, + 15B377C2161012B2008B02E1 /* CCBAnimationManager.h */, + 15B377C3161012B2008B02E1 /* CCBFileLoader.cpp */, + 15B377C4161012B2008B02E1 /* CCBFileLoader.h */, + 15B377C5161012B2008B02E1 /* CCBKeyframe.cpp */, + 15B377C6161012B2008B02E1 /* CCBKeyframe.h */, + 15B377C7161012B2008B02E1 /* CCBMemberVariableAssigner.h */, + 15B377C8161012B2008B02E1 /* CCBReader.cpp */, + 15B377C9161012B2008B02E1 /* CCBReader.h */, + 15B377CA161012B2008B02E1 /* CCBSelectorResolver.h */, + 15B377CB161012B2008B02E1 /* CCBSequence.cpp */, + 15B377CC161012B2008B02E1 /* CCBSequence.h */, + 15B377CD161012B2008B02E1 /* CCBSequenceProperty.cpp */, + 15B377CE161012B2008B02E1 /* CCBSequenceProperty.h */, + 15B377CF161012B2008B02E1 /* CCBValue.cpp */, + 15B377D0161012B2008B02E1 /* CCBValue.h */, + 15B377D1161012B2008B02E1 /* CCControlButtonLoader.cpp */, + 15B377D2161012B2008B02E1 /* CCControlButtonLoader.h */, + 15B377D3161012B2008B02E1 /* CCControlLoader.cpp */, + 15B377D4161012B2008B02E1 /* CCControlLoader.h */, + 15B377D5161012B2008B02E1 /* CCData.cpp */, + 15B377D6161012B2008B02E1 /* CCData.h */, + 15B377D7161012B2008B02E1 /* CCLabelBMFontLoader.cpp */, + 15B377D8161012B2008B02E1 /* CCLabelBMFontLoader.h */, + 15B377D9161012B2008B02E1 /* CCLabelTTFLoader.cpp */, + 15B377DA161012B2008B02E1 /* CCLabelTTFLoader.h */, + 15B377DB161012B2008B02E1 /* CCLayerColorLoader.cpp */, + 15B377DC161012B2008B02E1 /* CCLayerColorLoader.h */, + 15B377DD161012B2008B02E1 /* CCLayerGradientLoader.cpp */, + 15B377DE161012B2008B02E1 /* CCLayerGradientLoader.h */, + 15B377DF161012B2008B02E1 /* CCLayerLoader.cpp */, + 15B377E0161012B2008B02E1 /* CCLayerLoader.h */, + 15B377E1161012B2008B02E1 /* CCMenuItemImageLoader.cpp */, + 15B377E2161012B2008B02E1 /* CCMenuItemImageLoader.h */, + 15B377E3161012B2008B02E1 /* CCMenuItemLoader.cpp */, + 15B377E4161012B2008B02E1 /* CCMenuItemLoader.h */, + 15B377E5161012B2008B02E1 /* CCMenuLoader.h */, + 15B377E6161012B2008B02E1 /* CCNode+CCBRelativePositioning.cpp */, + 15B377E7161012B2008B02E1 /* CCNode+CCBRelativePositioning.h */, + 15B377E8161012B2008B02E1 /* CCNodeLoader.cpp */, + 15B377E9161012B2008B02E1 /* CCNodeLoader.h */, + 15B377EA161012B2008B02E1 /* CCNodeLoaderLibrary.cpp */, + 15B377EB161012B2008B02E1 /* CCNodeLoaderLibrary.h */, + 15B377EC161012B2008B02E1 /* CCNodeLoaderListener.h */, + 15B377ED161012B2008B02E1 /* CCParticleSystemQuadLoader.cpp */, + 15B377EE161012B2008B02E1 /* CCParticleSystemQuadLoader.h */, + 15B377EF161012B2008B02E1 /* CCScale9SpriteLoader.cpp */, + 15B377F0161012B2008B02E1 /* CCScale9SpriteLoader.h */, + 15B377F1161012B2008B02E1 /* CCScrollViewLoader.cpp */, + 15B377F2161012B2008B02E1 /* CCScrollViewLoader.h */, + 15B377F3161012B2008B02E1 /* CCSpriteLoader.cpp */, + 15B377F4161012B2008B02E1 /* CCSpriteLoader.h */, + ); + path = CCBReader; + sourceTree = ""; + }; + 15B3786E1610142E008B02E1 /* GUI */ = { + isa = PBXGroup; + children = ( + 15B3786F1610142E008B02E1 /* CCControlExtension */, + 15B378891610142E008B02E1 /* CCEditBox */, + 15B378931610142E008B02E1 /* CCScrollView */, + ); + path = GUI; + sourceTree = ""; + }; + 15B3786F1610142E008B02E1 /* CCControlExtension */ = { + isa = PBXGroup; + children = ( + 15B378701610142E008B02E1 /* CCControl.cpp */, + 15B378711610142E008B02E1 /* CCControl.h */, + 15B378721610142E008B02E1 /* CCControlButton.cpp */, + 15B378731610142E008B02E1 /* CCControlButton.h */, + 15B378741610142E008B02E1 /* CCControlColourPicker.cpp */, + 15B378751610142E008B02E1 /* CCControlColourPicker.h */, + 15B378761610142E008B02E1 /* CCControlExtensions.h */, + 15B378771610142E008B02E1 /* CCControlHuePicker.cpp */, + 15B378781610142E008B02E1 /* CCControlHuePicker.h */, + 15B378791610142E008B02E1 /* CCControlSaturationBrightnessPicker.cpp */, + 15B3787A1610142E008B02E1 /* CCControlSaturationBrightnessPicker.h */, + 15B3787B1610142E008B02E1 /* CCControlSlider.cpp */, + 15B3787C1610142E008B02E1 /* CCControlSlider.h */, + 15B3787D1610142E008B02E1 /* CCControlSwitch.cpp */, + 15B3787E1610142E008B02E1 /* CCControlSwitch.h */, + 15B3787F1610142E008B02E1 /* CCControlUtils.cpp */, + 15B378801610142E008B02E1 /* CCControlUtils.h */, + 15B378811610142E008B02E1 /* CCInvocation.cpp */, + 15B378821610142E008B02E1 /* CCInvocation.h */, + 15B378831610142E008B02E1 /* CCMenuPassive.cpp */, + 15B378841610142E008B02E1 /* CCMenuPassive.h */, + 15B378851610142E008B02E1 /* CCScale9Sprite.cpp */, + 15B378861610142E008B02E1 /* CCScale9Sprite.h */, + 15B378871610142E008B02E1 /* CCSpacer.cpp */, + 15B378881610142E008B02E1 /* CCSpacer.h */, + ); + path = CCControlExtension; + sourceTree = ""; + }; + 15B378891610142E008B02E1 /* CCEditBox */ = { + isa = PBXGroup; + children = ( + 15B3788A1610142E008B02E1 /* CCEditBox.cpp */, + 15B3788B1610142E008B02E1 /* CCEditBox.h */, + 15B3788C1610142E008B02E1 /* CCEditBoxImpl.h */, + 15B3788F1610142E008B02E1 /* CCEditBoxImplIOS.h */, + 15B378901610142E008B02E1 /* CCEditBoxImplIOS.mm */, + 15B378911610142E008B02E1 /* EditBoxImplIOS.h */, + 15B378921610142E008B02E1 /* EditBoxImplIOS.mm */, + ); + path = CCEditBox; + sourceTree = ""; + }; + 15B378931610142E008B02E1 /* CCScrollView */ = { + isa = PBXGroup; + children = ( + 15B378941610142E008B02E1 /* CCScrollView.cpp */, + 15B378951610142E008B02E1 /* CCScrollView.h */, + 15B378961610142E008B02E1 /* CCSorting.cpp */, + 15B378971610142E008B02E1 /* CCSorting.h */, + 15B378981610142E008B02E1 /* CCTableView.cpp */, + 15B378991610142E008B02E1 /* CCTableView.h */, + 15B3789A1610142E008B02E1 /* CCTableViewCell.cpp */, + 15B3789B1610142E008B02E1 /* CCTableViewCell.h */, + ); + path = CCScrollView; + sourceTree = ""; + }; + 15B378B016102B59008B02E1 /* bindings */ = { + isa = PBXGroup; + children = ( + 15B378B216102B59008B02E1 /* CCPhysicsSprite.cpp */, + 15B378B316102B59008B02E1 /* CCPhysicsSprite.h */, + 15B378B416102B59008B02E1 /* cocos2d_specifics.cpp */, + 15B378B516102B59008B02E1 /* cocos2d_specifics.hpp */, + 15B378B616102B59008B02E1 /* cocosjs_manual_conversions.cpp */, + 15B378B716102B59008B02E1 /* cocosjs_manual_conversions.h */, + 15B378B816102B59008B02E1 /* generated */, + 15B378BD16102B59008B02E1 /* js_bindings_ccbreader.cpp */, + 15B378BE16102B59008B02E1 /* js_bindings_ccbreader.h */, + 15B378BF16102B59008B02E1 /* js_bindings_chipmunk_functions.cpp */, + 15B378C016102B59008B02E1 /* js_bindings_chipmunk_functions.hpp */, + 15B378C116102B59008B02E1 /* js_bindings_chipmunk_manual.cpp */, + 15B378C216102B59008B02E1 /* js_bindings_chipmunk_manual.hpp */, + 15B378C316102B59008B02E1 /* js_bindings_config.h */, + 15B378C416102B59008B02E1 /* js_manual_conversions.cpp */, + 15B378C516102B59008B02E1 /* js_manual_conversions.h */, + 15B378C616102B59008B02E1 /* ScriptingCore.cpp */, + 15B378C716102B59008B02E1 /* ScriptingCore.h */, + 15B378C816102B59008B02E1 /* spidermonkey_specifics.h */, + 15B378C916102B59008B02E1 /* uthash.h */, + ); + name = bindings; + path = ../../../scripting/javascript/bindings; + sourceTree = ""; + }; + 15B378B816102B59008B02E1 /* generated */ = { + isa = PBXGroup; + children = ( + 15B378B916102B59008B02E1 /* cocos2dx.cpp */, + 15B378BA16102B59008B02E1 /* cocos2dx.hpp */, + ); + path = generated; + sourceTree = ""; + }; 2628297C15EC7196002C4240 /* chipmunk */ = { isa = PBXGroup; children = ( @@ -486,10 +808,11 @@ A92275321517C094001B78AA = { isa = PBXGroup; children = ( + 15B378B016102B59008B02E1 /* bindings */, + 15B377BE161012B2008B02E1 /* extensions */, 15628F5B15F0F5C2000CF24B /* Resources */, 2628297C15EC7196002C4240 /* chipmunk */, 15426AE915B5733200712A7F /* cocos2dx.xcodeproj */, - F2837A9C15B9639100A5707B /* bindings */, D4545214156E28EF00887EB5 /* Classes */, 15426FC415B5743C00712A7F /* CocosDenshion */, A92275401517C094001B78AA /* Frameworks */, @@ -547,31 +870,6 @@ path = ../Classes; sourceTree = ""; }; - F2837A9C15B9639100A5707B /* bindings */ = { - isa = PBXGroup; - children = ( - 2628295015EC6C1B002C4240 /* uthash.h */, - 2628295115EC6C1B002C4240 /* spidermonkey_specifics.h */, - 2628295215EC6C1B002C4240 /* ScriptingCore.h */, - 2628295315EC6C1B002C4240 /* ScriptingCore.cpp */, - 2628295415EC6C1B002C4240 /* js_manual_conversions.h */, - 2628295515EC6C1B002C4240 /* js_manual_conversions.cpp */, - 2628295615EC6C1B002C4240 /* js_bindings_config.h */, - 2628295715EC6C1B002C4240 /* js_bindings_chipmunk_manual.hpp */, - 2628295815EC6C1B002C4240 /* js_bindings_chipmunk_manual.cpp */, - 2628295915EC6C1B002C4240 /* js_bindings_chipmunk_functions.hpp */, - 2628295A15EC6C1B002C4240 /* js_bindings_chipmunk_functions.cpp */, - 2628295B15EC6C1B002C4240 /* cocos2dx.hpp */, - 2628295C15EC6C1B002C4240 /* cocos2dx.cpp */, - 2628295D15EC6C1B002C4240 /* cocos2d_specifics.hpp */, - 2628295E15EC6C1B002C4240 /* cocos2d_specifics.cpp */, - 2628295F15EC6C1B002C4240 /* CCPhysicsSprite.h */, - 2628296015EC6C1B002C4240 /* CCPhysicsSprite.cpp */, - ); - name = bindings; - path = ../../../scripting/javascript/bindings; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -688,13 +986,6 @@ 15426FE815B5743C00712A7F /* CocosDenshion.m in Sources */, 15426FE915B5743C00712A7F /* SimpleAudioEngine.mm in Sources */, 15426FEA15B5743C00712A7F /* SimpleAudioEngine_objc.m in Sources */, - 2628296215EC6C1B002C4240 /* ScriptingCore.cpp in Sources */, - 2628296315EC6C1B002C4240 /* js_manual_conversions.cpp in Sources */, - 2628296415EC6C1B002C4240 /* js_bindings_chipmunk_manual.cpp in Sources */, - 2628296515EC6C1B002C4240 /* js_bindings_chipmunk_functions.cpp in Sources */, - 2628296615EC6C1B002C4240 /* cocos2dx.cpp in Sources */, - 2628296715EC6C1B002C4240 /* cocos2d_specifics.cpp in Sources */, - 2628296815EC6C1B002C4240 /* CCPhysicsSprite.cpp in Sources */, 262829D415EC7196002C4240 /* Makefile in Sources */, 262829DB15EC7196002C4240 /* chipmunk.c in Sources */, 262829DD15EC7196002C4240 /* cpConstraint.c in Sources */, @@ -725,6 +1016,58 @@ 262829F615EC7196002C4240 /* cpSpatialIndex.c in Sources */, 262829F715EC7196002C4240 /* cpSweep1D.c in Sources */, 262829F815EC7196002C4240 /* cpVect.c in Sources */, + 15B37833161012B2008B02E1 /* CCBAnimationManager.cpp in Sources */, + 15B37834161012B2008B02E1 /* CCBFileLoader.cpp in Sources */, + 15B37835161012B2008B02E1 /* CCBKeyframe.cpp in Sources */, + 15B37836161012B2008B02E1 /* CCBReader.cpp in Sources */, + 15B37837161012B2008B02E1 /* CCBSequence.cpp in Sources */, + 15B37838161012B2008B02E1 /* CCBSequenceProperty.cpp in Sources */, + 15B37839161012B2008B02E1 /* CCBValue.cpp in Sources */, + 15B3783A161012B2008B02E1 /* CCControlButtonLoader.cpp in Sources */, + 15B3783B161012B2008B02E1 /* CCControlLoader.cpp in Sources */, + 15B3783C161012B2008B02E1 /* CCData.cpp in Sources */, + 15B3783D161012B2008B02E1 /* CCLabelBMFontLoader.cpp in Sources */, + 15B3783E161012B2008B02E1 /* CCLabelTTFLoader.cpp in Sources */, + 15B3783F161012B2008B02E1 /* CCLayerColorLoader.cpp in Sources */, + 15B37840161012B2008B02E1 /* CCLayerGradientLoader.cpp in Sources */, + 15B37841161012B2008B02E1 /* CCLayerLoader.cpp in Sources */, + 15B37842161012B2008B02E1 /* CCMenuItemImageLoader.cpp in Sources */, + 15B37843161012B2008B02E1 /* CCMenuItemLoader.cpp in Sources */, + 15B37844161012B2008B02E1 /* CCNode+CCBRelativePositioning.cpp in Sources */, + 15B37845161012B2008B02E1 /* CCNodeLoader.cpp in Sources */, + 15B37846161012B2008B02E1 /* CCNodeLoaderLibrary.cpp in Sources */, + 15B37847161012B2008B02E1 /* CCParticleSystemQuadLoader.cpp in Sources */, + 15B37848161012B2008B02E1 /* CCScale9SpriteLoader.cpp in Sources */, + 15B37849161012B2008B02E1 /* CCScrollViewLoader.cpp in Sources */, + 15B3784A161012B2008B02E1 /* CCSpriteLoader.cpp in Sources */, + 15B3789C1610142E008B02E1 /* CCControl.cpp in Sources */, + 15B3789D1610142E008B02E1 /* CCControlButton.cpp in Sources */, + 15B3789E1610142E008B02E1 /* CCControlColourPicker.cpp in Sources */, + 15B3789F1610142E008B02E1 /* CCControlHuePicker.cpp in Sources */, + 15B378A01610142E008B02E1 /* CCControlSaturationBrightnessPicker.cpp in Sources */, + 15B378A11610142E008B02E1 /* CCControlSlider.cpp in Sources */, + 15B378A21610142E008B02E1 /* CCControlSwitch.cpp in Sources */, + 15B378A31610142E008B02E1 /* CCControlUtils.cpp in Sources */, + 15B378A41610142E008B02E1 /* CCInvocation.cpp in Sources */, + 15B378A51610142E008B02E1 /* CCMenuPassive.cpp in Sources */, + 15B378A61610142E008B02E1 /* CCScale9Sprite.cpp in Sources */, + 15B378A71610142E008B02E1 /* CCSpacer.cpp in Sources */, + 15B378A81610142E008B02E1 /* CCEditBox.cpp in Sources */, + 15B378AA1610142E008B02E1 /* CCEditBoxImplIOS.mm in Sources */, + 15B378AB1610142E008B02E1 /* EditBoxImplIOS.mm in Sources */, + 15B378AC1610142E008B02E1 /* CCScrollView.cpp in Sources */, + 15B378AD1610142E008B02E1 /* CCSorting.cpp in Sources */, + 15B378AE1610142E008B02E1 /* CCTableView.cpp in Sources */, + 15B378AF1610142E008B02E1 /* CCTableViewCell.cpp in Sources */, + 15B378CB16102B59008B02E1 /* CCPhysicsSprite.cpp in Sources */, + 15B378CC16102B59008B02E1 /* cocos2d_specifics.cpp in Sources */, + 15B378CD16102B59008B02E1 /* cocosjs_manual_conversions.cpp in Sources */, + 15B378CE16102B59008B02E1 /* cocos2dx.cpp in Sources */, + 15B378D116102B59008B02E1 /* js_bindings_ccbreader.cpp in Sources */, + 15B378D216102B59008B02E1 /* js_bindings_chipmunk_functions.cpp in Sources */, + 15B378D316102B59008B02E1 /* js_bindings_chipmunk_manual.cpp in Sources */, + 15B378D416102B59008B02E1 /* js_manual_conversions.cpp in Sources */, + 15B378D516102B59008B02E1 /* ScriptingCore.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -816,6 +1159,7 @@ "$(SRCROOT)/../../../cocos2dx/platform/ios", "$(SRCROOT)/../../../external/chipmunk/include/chipmunk", "$(SRCROOT)/../../../scripting/javascript/spidermonkey-ios/include", + "$(SRCROOT)/../../../scripting/javascript/bindings", ); INFOPLIST_FILE = Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1; @@ -854,6 +1198,7 @@ "$(SRCROOT)/../../../cocos2dx/platform/ios", "$(SRCROOT)/../../../external/chipmunk/include/chipmunk", "$(SRCROOT)/../../../scripting/javascript/spidermonkey-ios/include", + "$(SRCROOT)/../../../scripting/javascript/bindings", ); INFOPLIST_FILE = Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1; diff --git a/scripting/javascript/bindings/cocos2d_specifics.hpp b/scripting/javascript/bindings/cocos2d_specifics.hpp index 83055be039..98d47f3324 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.hpp +++ b/scripting/javascript/bindings/cocos2d_specifics.hpp @@ -106,7 +106,7 @@ class JSTouchDelegate: public CCTouchDelegate, public CCNode { void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent) { CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent); - jsval retval; + //jsval retval; ScriptingCore::getInstance()->executeCustomTouchEvent(CCTOUCHMOVED, pTouch, _mObj); } diff --git a/scripting/javascript/bindings/cocosjs_manual_conversions.h b/scripting/javascript/bindings/cocosjs_manual_conversions.h index 444deb1e68..49adcbabcf 100644 --- a/scripting/javascript/bindings/cocosjs_manual_conversions.h +++ b/scripting/javascript/bindings/cocosjs_manual_conversions.h @@ -5,18 +5,18 @@ #include "cocos2d.h" #include "js_manual_conversions.h" -#ifdef __cplusplus -extern "C" { -#endif +//#ifdef __cplusplus +//extern "C" { +//#endif JSBool jsval_to_CGPoint( JSContext *cx, jsval vp, cpVect *out ); jsval CGPoint_to_jsval( JSContext *cx, cpVect p ); JSBool jsval_to_cpBB( JSContext *cx, jsval vp, cpBB *ret ); jsval cpBB_to_jsval(JSContext *cx, cpBB bb ); -#ifdef __cplusplus -} -#endif +//#ifdef __cplusplus +//} +//#endif #define cpVect_to_jsval CGPoint_to_jsval #define jsval_to_cpVect jsval_to_CGPoint diff --git a/scripting/javascript/bindings/js_bindings_ccbreader.cpp b/scripting/javascript/bindings/js_bindings_ccbreader.cpp index 0244706f0f..a73657b5ed 100644 --- a/scripting/javascript/bindings/js_bindings_ccbreader.cpp +++ b/scripting/javascript/bindings/js_bindings_ccbreader.cpp @@ -90,7 +90,7 @@ static CCNode* loadReader(const char *file, jsval owner) { ccBCallbackProxy->setJSOwner(owner); //ccbReader->setOwner(dynamic_cast(ccBCallbackProxy)); - CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast(ccBCallbackProxy); + //CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast(ccBCallbackProxy); CCNode * node = ccbReader->readNodeGraphFromFile(file, dynamic_cast(ccBCallbackProxy)); diff --git a/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp b/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp index 7a8e2b1576..b1cedd301a 100644 --- a/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp +++ b/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp @@ -400,7 +400,7 @@ template js_type_class_t *js_get_type_from_native(T* native_obj) { js_type_class_t *typeProxy; uint32_t typeId = reinterpret_cast(typeid(*native_obj).name()); - const char *nam = typeid(*native_obj).name(); + //const char *nam = typeid(*native_obj).name(); HASH_FIND_INT(_js_global_type_ht, &typeId, typeProxy); if (!typeProxy) { TypeInfo *typeInfo = dynamic_cast(native_obj); diff --git a/scripting/javascript/bindings/js_manual_conversions.h b/scripting/javascript/bindings/js_manual_conversions.h index c815bc04cf..118751d3ab 100644 --- a/scripting/javascript/bindings/js_manual_conversions.h +++ b/scripting/javascript/bindings/js_manual_conversions.h @@ -7,22 +7,22 @@ #include "jsapi.h" -#ifdef __cplusplus -extern "C" { -#endif +//#ifdef __cplusplus +//extern "C" { +//#endif -JSBool jsval_to_opaque( JSContext *cx, jsval vp, void **out ); -JSBool jsval_to_int( JSContext *cx, jsval vp, int *out); -JSBool jsval_to_long( JSContext *cx, jsval vp, long *out); -JSBool jsval_to_longlong( JSContext *cx, jsval vp, long long *out); -jsval int_to_jsval( JSContext *cx, int l); -jsval long_to_jsval( JSContext *cx, long l); -jsval longlong_to_jsval( JSContext *cx, long long l); -jsval opaque_to_jsval( JSContext *cx, void* opaque); +extern JSBool jsval_to_opaque( JSContext *cx, jsval vp, void **out ); +extern JSBool jsval_to_int( JSContext *cx, jsval vp, int *out); +extern JSBool jsval_to_long( JSContext *cx, jsval vp, long *out); +extern JSBool jsval_to_longlong( JSContext *cx, jsval vp, long long *out); +extern jsval int_to_jsval( JSContext *cx, int l); +extern jsval long_to_jsval( JSContext *cx, long l); +extern jsval longlong_to_jsval( JSContext *cx, long long l); +extern jsval opaque_to_jsval( JSContext *cx, void* opaque); -#ifdef __cplusplus -} -#endif +//#ifdef __cplusplus +//} +//#endif #endif /* __JS_MANUAL_CONVERSIONS_H__ */ From 7088b19a1a45d3ff69b390cef0dd46aa1085ac52 Mon Sep 17 00:00:00 2001 From: walzer Date: Mon, 24 Sep 2012 13:59:16 +0800 Subject: [PATCH 116/181] add sample code in HelloCpp & SimpleGame to teach how to adapt design resolution to different iPhone screens (HVGA, 3.5 inch retina, and 4.0 inch retina) --- samples/HelloCpp/Classes/AppDelegate.cpp | 2 +- .../Default-568h@2x.png.REMOVED.git-id | 1 + .../proj.ios/Default@2x.png.REMOVED.git-id | 1 + .../HelloCpp.xcodeproj/project.pbxproj | 20 +++++++++++-------- .../Default-568h@2x.png.REMOVED.git-id | 1 + .../proj.ios/Default@2x.png.REMOVED.git-id | 1 + .../HelloLua.xcodeproj/project.pbxproj | 10 +++++++--- .../Default-568h@2x.png.REMOVED.git-id | 1 + .../proj.ios/Default@2x.png.REMOVED.git-id | 1 + .../SimpleGame.xcodeproj/project.pbxproj | 6 +++++- .../Default-568h@2x.png.REMOVED.git-id | 1 + .../proj.ios/Default@2x.png.REMOVED.git-id | 1 + .../project.pbxproj.REMOVED.git-id | 2 +- .../Default-568h@2x.png.REMOVED.git-id | 1 + .../proj.ios/Default@2x.png.REMOVED.git-id | 1 + .../TestJavascript.xcodeproj/project.pbxproj | 12 +++++++++++ .../Default-568h@2x.png.REMOVED.git-id | 1 + .../proj.ios/Default@2x.png.REMOVED.git-id | 1 + .../TestLua.xcodeproj/project.pbxproj | 12 +++++++++-- 19 files changed, 60 insertions(+), 16 deletions(-) create mode 100644 samples/HelloCpp/proj.ios/Default-568h@2x.png.REMOVED.git-id create mode 100644 samples/HelloCpp/proj.ios/Default@2x.png.REMOVED.git-id create mode 100644 samples/HelloLua/proj.ios/Default-568h@2x.png.REMOVED.git-id create mode 100644 samples/HelloLua/proj.ios/Default@2x.png.REMOVED.git-id create mode 100644 samples/SimpleGame/proj.ios/Default-568h@2x.png.REMOVED.git-id create mode 100644 samples/SimpleGame/proj.ios/Default@2x.png.REMOVED.git-id create mode 100644 samples/TestCpp/proj.ios/Default-568h@2x.png.REMOVED.git-id create mode 100644 samples/TestCpp/proj.ios/Default@2x.png.REMOVED.git-id create mode 100644 samples/TestJavascript/proj.ios/Default-568h@2x.png.REMOVED.git-id create mode 100644 samples/TestJavascript/proj.ios/Default@2x.png.REMOVED.git-id create mode 100644 samples/TestLua/proj.ios/Default-568h@2x.png.REMOVED.git-id create mode 100644 samples/TestLua/proj.ios/Default@2x.png.REMOVED.git-id diff --git a/samples/HelloCpp/Classes/AppDelegate.cpp b/samples/HelloCpp/Classes/AppDelegate.cpp index d04664af37..c03e87a8aa 100644 --- a/samples/HelloCpp/Classes/AppDelegate.cpp +++ b/samples/HelloCpp/Classes/AppDelegate.cpp @@ -33,7 +33,7 @@ bool AppDelegate::applicationDidFinishLaunching() { // iphone // try to enable retina on device - // notice: passby CCDirecor::enableRetinaDisplay() + // notice: passby CCDirecor::enableRetinaDisplay(), call CCEGLView::enableRetina() directly if (true == CCEGLView::sharedOpenGLView()->enableRetina()) { // iphone hd diff --git a/samples/HelloCpp/proj.ios/Default-568h@2x.png.REMOVED.git-id b/samples/HelloCpp/proj.ios/Default-568h@2x.png.REMOVED.git-id new file mode 100644 index 0000000000..8f5838f3a8 --- /dev/null +++ b/samples/HelloCpp/proj.ios/Default-568h@2x.png.REMOVED.git-id @@ -0,0 +1 @@ +66c6d1cead373b45218424f6a82f370897e443e4 \ No newline at end of file diff --git a/samples/HelloCpp/proj.ios/Default@2x.png.REMOVED.git-id b/samples/HelloCpp/proj.ios/Default@2x.png.REMOVED.git-id new file mode 100644 index 0000000000..8843505b20 --- /dev/null +++ b/samples/HelloCpp/proj.ios/Default@2x.png.REMOVED.git-id @@ -0,0 +1 @@ +84689888a14a2123d2b39f7f2f61be8c15207479 \ No newline at end of file diff --git a/samples/HelloCpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj b/samples/HelloCpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj index b3a98f857d..356f4f7fc3 100644 --- a/samples/HelloCpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj +++ b/samples/HelloCpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj @@ -13,7 +13,6 @@ 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; - 782F4619153FEDF0009FC2E5 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 782F4617153FEDF0009FC2E5 /* Default.png */; }; BF1373EF128A898400D9F789 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492D4B1289302400A09262 /* OpenGLES.framework */; }; BF1373F0128A899500D9F789 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492C21128924A800A09262 /* libxml2.dylib */; }; BF1373F1128A899E00D9F789 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492B6912891AC600A09262 /* libz.dylib */; }; @@ -22,7 +21,9 @@ BF23D4E8143315EB00657E08 /* HelloWorldScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BF23D4E5143315EB00657E08 /* HelloWorldScene.cpp */; }; BF365AA812A103F70050DCF4 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF365AA712A103F70050DCF4 /* AppController.mm */; }; BF4DE6AD138BB89600CF907D /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF4DE6AC138BB89600CF907D /* RootViewController.mm */; }; - D41A0A92160F1229004552AE /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D41A0A91160F1229004552AE /* Default-568h@2x.png */; }; + D446FD79161028E9000ADA7B /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FD78161028E9000ADA7B /* Default.png */; }; + D446FD7B161028ED000ADA7B /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FD7A161028ED000ADA7B /* Default@2x.png */; }; + D446FD7D161028F4000ADA7B /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FD7C161028F4000ADA7B /* Default-568h@2x.png */; }; D4ABB4B313B4395300552E6E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D4ABB4B213B4395300552E6E /* main.m */; }; D4EF94E815BD319200D803EB /* Icon-57.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF94E715BD319200D803EB /* Icon-57.png */; }; D4EF94EA15BD319500D803EB /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF94E915BD319500D803EB /* Icon-114.png */; }; @@ -58,7 +59,6 @@ 781C33B11547F06B00633F88 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; 781C33B31547F06B00633F88 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; 781C33B51547F06B00633F88 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; - 782F4617153FEDF0009FC2E5 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = SOURCE_ROOT; }; BF137426128A8E4600D9F789 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; BF23D4E3143315EB00657E08 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; BF23D4E4143315EB00657E08 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; @@ -71,7 +71,9 @@ BF492D4B1289302400A09262 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; BF4DE6AB138BB89600CF907D /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; BF4DE6AC138BB89600CF907D /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; - D41A0A91160F1229004552AE /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + D446FD78161028E9000ADA7B /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Default.png; path = ../proj.ios/Default.png; sourceTree = ""; }; + D446FD7A161028ED000ADA7B /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "../proj.ios/Default@2x.png"; sourceTree = ""; }; + D446FD7C161028F4000ADA7B /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../proj.ios/Default-568h@2x.png"; sourceTree = ""; }; D4ABB4B213B4395300552E6E /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; D4EF94E715BD319200D803EB /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-57.png"; path = "../proj.ios/Icon-57.png"; sourceTree = ""; }; D4EF94E915BD319500D803EB /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-114.png"; path = "../proj.ios/Icon-114.png"; sourceTree = ""; }; @@ -117,7 +119,6 @@ 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { isa = PBXGroup; children = ( - D41A0A91160F1229004552AE /* Default-568h@2x.png */, 154269C815B5644500712A7F /* cocos2dx.xcodeproj */, BF23D4E2143315EB00657E08 /* Classes */, 29B97323FDCFA39411CA2CEA /* Frameworks */, @@ -154,7 +155,9 @@ D4EF94EB15BD319B00D803EB /* Icon-72.png */, D4EF94E915BD319500D803EB /* Icon-114.png */, D4EF94E715BD319200D803EB /* Icon-57.png */, - 782F4617153FEDF0009FC2E5 /* Default.png */, + D446FD7C161028F4000ADA7B /* Default-568h@2x.png */, + D446FD7A161028ED000ADA7B /* Default@2x.png */, + D446FD78161028E9000ADA7B /* Default.png */, ); name = Resources; path = ../Resources; @@ -253,14 +256,15 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 782F4619153FEDF0009FC2E5 /* Default.png in Resources */, D4EF94E815BD319200D803EB /* Icon-57.png in Resources */, D4EF94EA15BD319500D803EB /* Icon-114.png in Resources */, D4EF94EC15BD319B00D803EB /* Icon-72.png in Resources */, D4EF94EE15BD319D00D803EB /* Icon-144.png in Resources */, 15003FA315D2601D00B6775A /* iphone in Resources */, 15003FA515D2602400B6775A /* iphonehd in Resources */, - D41A0A92160F1229004552AE /* Default-568h@2x.png in Resources */, + D446FD79161028E9000ADA7B /* Default.png in Resources */, + D446FD7B161028ED000ADA7B /* Default@2x.png in Resources */, + D446FD7D161028F4000ADA7B /* Default-568h@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/samples/HelloLua/proj.ios/Default-568h@2x.png.REMOVED.git-id b/samples/HelloLua/proj.ios/Default-568h@2x.png.REMOVED.git-id new file mode 100644 index 0000000000..8f5838f3a8 --- /dev/null +++ b/samples/HelloLua/proj.ios/Default-568h@2x.png.REMOVED.git-id @@ -0,0 +1 @@ +66c6d1cead373b45218424f6a82f370897e443e4 \ No newline at end of file diff --git a/samples/HelloLua/proj.ios/Default@2x.png.REMOVED.git-id b/samples/HelloLua/proj.ios/Default@2x.png.REMOVED.git-id new file mode 100644 index 0000000000..8843505b20 --- /dev/null +++ b/samples/HelloLua/proj.ios/Default@2x.png.REMOVED.git-id @@ -0,0 +1 @@ +84689888a14a2123d2b39f7f2f61be8c15207479 \ No newline at end of file diff --git a/samples/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj b/samples/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj index c3e2d3a7b4..9f415b21fa 100644 --- a/samples/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj +++ b/samples/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj @@ -31,6 +31,7 @@ BF82F42213A8652A00616D55 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BF82F42013A8652A00616D55 /* main.m */; }; D403B5D9135D1AF1004B518D /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D403B5D8135D1AF1004B518D /* libxml2.dylib */; }; D41A0AA2160F13F8004552AE /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D41A0AA1160F13F8004552AE /* Default-568h@2x.png */; }; + D446FD3B16102085000ADA7B /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FD3A16102085000ADA7B /* Default@2x.png */; }; D4CEAD7913B4634300780515 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = D4CEAD7713B4634300780515 /* RootViewController.mm */; }; D4EF94D715BD311700D803EB /* Icon-57.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF94D615BD311700D803EB /* Icon-57.png */; }; D4EF94D915BD311A00D803EB /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF94D815BD311A00D803EB /* Icon-114.png */; }; @@ -139,7 +140,8 @@ BF82F42013A8652A00616D55 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; BF82F42313A8654600616D55 /* HelloLua_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelloLua_Prefix.pch; sourceTree = ""; }; D403B5D8135D1AF1004B518D /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; }; - D41A0AA1160F13F8004552AE /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + D41A0AA1160F13F8004552AE /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../proj.ios/Default-568h@2x.png"; sourceTree = ""; }; + D446FD3A16102085000ADA7B /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "../proj.ios/Default@2x.png"; sourceTree = ""; }; D4CEAD7713B4634300780515 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; D4CEAD7813B4634300780515 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; D4EF94D615BD311700D803EB /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-57.png"; path = "../proj.ios/Icon-57.png"; sourceTree = ""; }; @@ -303,7 +305,6 @@ 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { isa = PBXGroup; children = ( - D41A0AA1160F13F8004552AE /* Default-568h@2x.png */, 15426A2B15B571B300712A7F /* cocos2dx.xcodeproj */, BF82F41413A864B000616D55 /* Classes */, 15426A3715B5722100712A7F /* CocosDenshion */, @@ -355,7 +356,6 @@ D4EF94D615BD311700D803EB /* Icon-57.png */, 78947C5E14EBB9B000DBD5A6 /* background.mp3 */, 78947C5F14EBB9B000DBD5A6 /* crop.png */, - 78DC4C9815490B9500317402 /* Default.png */, 78947C6114EBB9B000DBD5A6 /* dog.png */, 78947C6214EBB9B000DBD5A6 /* effect1.wav */, 78947C6314EBB9B000DBD5A6 /* farm.jpg */, @@ -364,6 +364,9 @@ 78947C6914EBB9B000DBD5A6 /* land.png */, 78947C6A14EBB9B000DBD5A6 /* menu1.png */, 78947C6B14EBB9B000DBD5A6 /* menu2.png */, + 78DC4C9815490B9500317402 /* Default.png */, + D446FD3A16102085000ADA7B /* Default@2x.png */, + D41A0AA1160F13F8004552AE /* Default-568h@2x.png */, ); name = Resources; path = ../Resources; @@ -592,6 +595,7 @@ D4EF94DB15BD311E00D803EB /* Icon-72.png in Resources */, D4EF94DD15BD312100D803EB /* Icon-144.png in Resources */, D41A0AA2160F13F8004552AE /* Default-568h@2x.png in Resources */, + D446FD3B16102085000ADA7B /* Default@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/samples/SimpleGame/proj.ios/Default-568h@2x.png.REMOVED.git-id b/samples/SimpleGame/proj.ios/Default-568h@2x.png.REMOVED.git-id new file mode 100644 index 0000000000..8f5838f3a8 --- /dev/null +++ b/samples/SimpleGame/proj.ios/Default-568h@2x.png.REMOVED.git-id @@ -0,0 +1 @@ +66c6d1cead373b45218424f6a82f370897e443e4 \ No newline at end of file diff --git a/samples/SimpleGame/proj.ios/Default@2x.png.REMOVED.git-id b/samples/SimpleGame/proj.ios/Default@2x.png.REMOVED.git-id new file mode 100644 index 0000000000..8843505b20 --- /dev/null +++ b/samples/SimpleGame/proj.ios/Default@2x.png.REMOVED.git-id @@ -0,0 +1 @@ +84689888a14a2123d2b39f7f2f61be8c15207479 \ No newline at end of file diff --git a/samples/SimpleGame/proj.ios/SimpleGame.xcodeproj/project.pbxproj b/samples/SimpleGame/proj.ios/SimpleGame.xcodeproj/project.pbxproj index c968300d11..f5ca456817 100644 --- a/samples/SimpleGame/proj.ios/SimpleGame.xcodeproj/project.pbxproj +++ b/samples/SimpleGame/proj.ios/SimpleGame.xcodeproj/project.pbxproj @@ -20,6 +20,7 @@ BF365AA812A103F70050DCF4 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF365AA712A103F70050DCF4 /* AppController.mm */; }; BF4DE6AD138BB89600CF907D /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF4DE6AC138BB89600CF907D /* RootViewController.mm */; }; D41A0AC6160F14F5004552AE /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D41A0AC5160F14F5004552AE /* Default-568h@2x.png */; }; + D446FD47161020AC000ADA7B /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FD46161020AB000ADA7B /* Default@2x.png */; }; D4ABB4B313B4395300552E6E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D4ABB4B213B4395300552E6E /* main.m */; }; D4E6BC8515FCB4A4008BF525 /* libcocos2dx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D4E6BC8315FCB477008BF525 /* libcocos2dx.a */; }; D4E6BC9215FCB5BA008BF525 /* GameOverScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D4E6BC9015FCB5BA008BF525 /* GameOverScene.cpp */; }; @@ -73,6 +74,7 @@ BF4DE6AB138BB89600CF907D /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; BF4DE6AC138BB89600CF907D /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; D41A0AC5160F14F5004552AE /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../proj.ios/Default-568h@2x.png"; sourceTree = ""; }; + D446FD46161020AB000ADA7B /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "../proj.ios/Default@2x.png"; sourceTree = ""; }; D4ABB4B213B4395300552E6E /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; D4E6BC7B15FCB477008BF525 /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = ""; }; D4E6BC9015FCB5BA008BF525 /* GameOverScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GameOverScene.cpp; sourceTree = ""; }; @@ -163,7 +165,6 @@ 784521C214EBA449009D533B /* Resources */ = { isa = PBXGroup; children = ( - D41A0AC5160F14F5004552AE /* Default-568h@2x.png */, D4E6BCC415FCB6AA008BF525 /* background-music-aac.wav */, D4E6BCC515FCB6AA008BF525 /* hd */, D4E6BCC615FCB6AA008BF525 /* pew-pew-lei.wav */, @@ -173,6 +174,8 @@ D4EF94E915BD319500D803EB /* Icon-114.png */, D4EF94E715BD319200D803EB /* Icon-57.png */, 782F4617153FEDF0009FC2E5 /* Default.png */, + D446FD46161020AB000ADA7B /* Default@2x.png */, + D41A0AC5160F14F5004552AE /* Default-568h@2x.png */, ); name = Resources; path = ../Resources; @@ -324,6 +327,7 @@ D4E6BCCA15FCB6AA008BF525 /* pew-pew-lei.wav in Resources */, D4E6BCCB15FCB6AA008BF525 /* sd in Resources */, D41A0AC6160F14F5004552AE /* Default-568h@2x.png in Resources */, + D446FD47161020AC000ADA7B /* Default@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/samples/TestCpp/proj.ios/Default-568h@2x.png.REMOVED.git-id b/samples/TestCpp/proj.ios/Default-568h@2x.png.REMOVED.git-id new file mode 100644 index 0000000000..8f5838f3a8 --- /dev/null +++ b/samples/TestCpp/proj.ios/Default-568h@2x.png.REMOVED.git-id @@ -0,0 +1 @@ +66c6d1cead373b45218424f6a82f370897e443e4 \ No newline at end of file diff --git a/samples/TestCpp/proj.ios/Default@2x.png.REMOVED.git-id b/samples/TestCpp/proj.ios/Default@2x.png.REMOVED.git-id new file mode 100644 index 0000000000..8843505b20 --- /dev/null +++ b/samples/TestCpp/proj.ios/Default@2x.png.REMOVED.git-id @@ -0,0 +1 @@ +84689888a14a2123d2b39f7f2f61be8c15207479 \ No newline at end of file diff --git a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id index d7957fba4e..d3eb89e997 100644 --- a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -e652ef54a5d039edc73428b5f296f4b3ed83af7c \ No newline at end of file +cbe8a4c43be345c2fcb9b0e46e02ef3a1fc21c80 \ No newline at end of file diff --git a/samples/TestJavascript/proj.ios/Default-568h@2x.png.REMOVED.git-id b/samples/TestJavascript/proj.ios/Default-568h@2x.png.REMOVED.git-id new file mode 100644 index 0000000000..8f5838f3a8 --- /dev/null +++ b/samples/TestJavascript/proj.ios/Default-568h@2x.png.REMOVED.git-id @@ -0,0 +1 @@ +66c6d1cead373b45218424f6a82f370897e443e4 \ No newline at end of file diff --git a/samples/TestJavascript/proj.ios/Default@2x.png.REMOVED.git-id b/samples/TestJavascript/proj.ios/Default@2x.png.REMOVED.git-id new file mode 100644 index 0000000000..8843505b20 --- /dev/null +++ b/samples/TestJavascript/proj.ios/Default@2x.png.REMOVED.git-id @@ -0,0 +1 @@ +84689888a14a2123d2b39f7f2f61be8c15207479 \ No newline at end of file diff --git a/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj b/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj index 7a2d38c9ed..c60493883c 100644 --- a/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj +++ b/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj @@ -88,6 +88,9 @@ A922754C1517C094001B78AA /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754B1517C094001B78AA /* UIKit.framework */; }; A922754E1517C094001B78AA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754D1517C094001B78AA /* Foundation.framework */; }; A92275501517C094001B78AA /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754F1517C094001B78AA /* CoreGraphics.framework */; }; + D446FDA316102D7D000ADA7B /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FDA216102D7D000ADA7B /* Default.png */; }; + D446FDA516102D82000ADA7B /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FDA416102D82000ADA7B /* Default@2x.png */; }; + D446FDA716102D86000ADA7B /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FDA616102D86000ADA7B /* Default-568h@2x.png */; }; D45446D3156DE74F00887EB5 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = D45446CE156DE74F00887EB5 /* AppController.mm */; }; D45446D4156DE74F00887EB5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D45446CF156DE74F00887EB5 /* main.m */; }; D45446D5156DE74F00887EB5 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = D45446D2156DE74F00887EB5 /* RootViewController.mm */; }; @@ -239,6 +242,9 @@ A922754B1517C094001B78AA /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; A922754D1517C094001B78AA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; A922754F1517C094001B78AA /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + D446FDA216102D7D000ADA7B /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; + D446FDA416102D82000ADA7B /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; + D446FDA616102D86000ADA7B /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; D45446CD156DE74F00887EB5 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; D45446CE156DE74F00887EB5 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; D45446CF156DE74F00887EB5 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -321,6 +327,9 @@ 15628F5B15F0F5C2000CF24B /* Resources */ = { isa = PBXGroup; children = ( + D446FDA616102D86000ADA7B /* Default-568h@2x.png */, + D446FDA416102D82000ADA7B /* Default@2x.png */, + D446FDA216102D7D000ADA7B /* Default.png */, 15628FA815F1057E000CF24B /* animations */, 15628F5D15F0F5E5000CF24B /* ballbounce.wav */, 15628F5E15F0F5E5000CF24B /* cowbell.wav */, @@ -669,6 +678,9 @@ 15628F7815F0F5E5000CF24B /* tank1.png in Resources */, 15628F7915F0F5E5000CF24B /* TileMaps in Resources */, 15628FA915F1057E000CF24B /* animations in Resources */, + D446FDA316102D7D000ADA7B /* Default.png in Resources */, + D446FDA516102D82000ADA7B /* Default@2x.png in Resources */, + D446FDA716102D86000ADA7B /* Default-568h@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/samples/TestLua/proj.ios/Default-568h@2x.png.REMOVED.git-id b/samples/TestLua/proj.ios/Default-568h@2x.png.REMOVED.git-id new file mode 100644 index 0000000000..8f5838f3a8 --- /dev/null +++ b/samples/TestLua/proj.ios/Default-568h@2x.png.REMOVED.git-id @@ -0,0 +1 @@ +66c6d1cead373b45218424f6a82f370897e443e4 \ No newline at end of file diff --git a/samples/TestLua/proj.ios/Default@2x.png.REMOVED.git-id b/samples/TestLua/proj.ios/Default@2x.png.REMOVED.git-id new file mode 100644 index 0000000000..8843505b20 --- /dev/null +++ b/samples/TestLua/proj.ios/Default@2x.png.REMOVED.git-id @@ -0,0 +1 @@ +84689888a14a2123d2b39f7f2f61be8c15207479 \ No newline at end of file diff --git a/samples/TestLua/proj.ios/TestLua.xcodeproj/project.pbxproj b/samples/TestLua/proj.ios/TestLua.xcodeproj/project.pbxproj index 35550d4cf0..dee01f110e 100644 --- a/samples/TestLua/proj.ios/TestLua.xcodeproj/project.pbxproj +++ b/samples/TestLua/proj.ios/TestLua.xcodeproj/project.pbxproj @@ -12,6 +12,8 @@ 158B579D15EC9D86009FCBB4 /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = 158B579915EC9D86009FCBB4 /* Icon-114.png */; }; 158B579E15EC9D86009FCBB4 /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = 158B579A15EC9D86009FCBB4 /* Icon-144.png */; }; D41A0AE5160F1640004552AE /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D41A0AE4160F1640004552AE /* Default-568h@2x.png */; }; + D446FD9616102D5B000ADA7B /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FD9516102D5B000ADA7B /* Default.png */; }; + D446FD9816102D61000ADA7B /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FD9716102D61000ADA7B /* Default@2x.png */; }; F293B3CD15EB7BE500256477 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F293B3CC15EB7BE500256477 /* QuartzCore.framework */; }; F293B3CF15EB7BE500256477 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F293B3CE15EB7BE500256477 /* OpenGLES.framework */; }; F293B3D115EB7BE500256477 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F293B3D015EB7BE500256477 /* OpenAL.framework */; }; @@ -131,7 +133,9 @@ 158B579815EC9D86009FCBB4 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = SOURCE_ROOT; }; 158B579915EC9D86009FCBB4 /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-114.png"; sourceTree = SOURCE_ROOT; }; 158B579A15EC9D86009FCBB4 /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-144.png"; sourceTree = SOURCE_ROOT; }; - D41A0AE4160F1640004552AE /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + D41A0AE4160F1640004552AE /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../../TestLua/proj.ios/Default-568h@2x.png"; sourceTree = ""; }; + D446FD9516102D5B000ADA7B /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Default.png; path = ../../TestLua/proj.ios/Default.png; sourceTree = ""; }; + D446FD9716102D61000ADA7B /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "../../TestLua/proj.ios/Default@2x.png"; sourceTree = ""; }; F293B3C815EB7BE500256477 /* TestLua.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestLua.app; sourceTree = BUILT_PRODUCTS_DIR; }; F293B3CC15EB7BE500256477 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; F293B3CE15EB7BE500256477 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; @@ -296,7 +300,6 @@ F293B3BD15EB7BE500256477 = { isa = PBXGroup; children = ( - D41A0AE4160F1640004552AE /* Default-568h@2x.png */, F2A154E615EB8BCD00C9B0B6 /* cocos2dx.xcodeproj */, F2A1554A15EB921600C9B0B6 /* extensions */, F2A1553815EB91A000C9B0B6 /* chipmunk */, @@ -499,6 +502,9 @@ F293BC4615EB859D00256477 /* Resources */ = { isa = PBXGroup; children = ( + D446FD9716102D61000ADA7B /* Default@2x.png */, + D446FD9516102D5B000ADA7B /* Default.png */, + D41A0AE4160F1640004552AE /* Default-568h@2x.png */, 158B579715EC9D86009FCBB4 /* Icon-57.png */, 158B579815EC9D86009FCBB4 /* Icon-72.png */, 158B579915EC9D86009FCBB4 /* Icon-114.png */, @@ -714,6 +720,8 @@ 158B579D15EC9D86009FCBB4 /* Icon-114.png in Resources */, 158B579E15EC9D86009FCBB4 /* Icon-144.png in Resources */, D41A0AE5160F1640004552AE /* Default-568h@2x.png in Resources */, + D446FD9616102D5B000ADA7B /* Default.png in Resources */, + D446FD9816102D61000ADA7B /* Default@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; From 78ef574962a2bca754b256f260d112a07fd6d107 Mon Sep 17 00:00:00 2001 From: walzer Date: Mon, 24 Sep 2012 14:14:53 +0800 Subject: [PATCH 117/181] add touch callback to HelloCpp. Users can learn setDesignResolution easily. --- samples/HelloCpp/Classes/HelloWorldScene.cpp | 11 +++++++++++ samples/HelloCpp/Classes/HelloWorldScene.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/samples/HelloCpp/Classes/HelloWorldScene.cpp b/samples/HelloCpp/Classes/HelloWorldScene.cpp index 83f84f3e00..e9935d46f7 100644 --- a/samples/HelloCpp/Classes/HelloWorldScene.cpp +++ b/samples/HelloCpp/Classes/HelloWorldScene.cpp @@ -72,6 +72,9 @@ bool HelloWorld::init() // add the sprite as a child to this layer this->addChild(pSprite, 0); + // enable standard touch + this->setTouchEnabled(true); + return true; } @@ -83,3 +86,11 @@ void HelloWorld::menuCloseCallback(CCObject* pSender) exit(0); #endif } + +void HelloWorld::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent) +{ + CCTouch* touch = (CCTouch*)(* pTouches->begin()); + CCPoint pos = touch->getLocation(); + + CCLog("touch, x = %f, y = %f", pos.x, pos.y); +} diff --git a/samples/HelloCpp/Classes/HelloWorldScene.h b/samples/HelloCpp/Classes/HelloWorldScene.h index 654c107b3e..4379df7ff0 100644 --- a/samples/HelloCpp/Classes/HelloWorldScene.h +++ b/samples/HelloCpp/Classes/HelloWorldScene.h @@ -15,6 +15,9 @@ public: // a selector callback void menuCloseCallback(CCObject* pSender); + // touch callback + void ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent); + // implement the "static node()" method manually CREATE_FUNC(HelloWorld); }; From f17545a1aea1ab1fab5b10d1b8b38e1cd145638e Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 24 Sep 2012 15:26:18 +0800 Subject: [PATCH 118/181] fix a compile error --- extensions/CCBReader/CCNodeLoader.h | 4 ++-- .../CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/CCBReader/CCNodeLoader.h b/extensions/CCBReader/CCNodeLoader.h index f59134ebc9..175e96f0aa 100644 --- a/extensions/CCBReader/CCNodeLoader.h +++ b/extensions/CCBReader/CCNodeLoader.h @@ -19,11 +19,11 @@ NS_CC_EXT_BEGIN #define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) CCLog("Unexpected property: '%s'!\n", PROPERTY->getCString()); assert(false) #define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) CCLog("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false) -#define CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createCCNode(CCNode * pParent, extension::CCBReader * pCCBReader) { \ +#define CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createCCNode(cocos2d::CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) { \ return T::create(); \ } -#define CCB_PURE_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createCCNode(CCNode * pParent, extension::CCBReader * pCCBReader) = 0 +#define CCB_PURE_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createCCNode(cocos2d::CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) = 0 struct BlockData { SEL_MenuHandler mSELMenuHandler; diff --git a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h index fd37933ad6..7da3a95e1f 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h +++ b/samples/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h @@ -15,7 +15,7 @@ public: AnimationsTestLayer(); virtual ~AnimationsTestLayer(); - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(CCObject * pTarget, cocos2d::CCString * pSelectorName); virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, cocos2d::CCString * pMemberVariableName, cocos2d::CCNode * pNode); From e0fe233752b66d8ba6776719f636029df8836702 Mon Sep 17 00:00:00 2001 From: ncrothe Date: Mon, 24 Sep 2012 12:15:53 +0300 Subject: [PATCH 119/181] Update samples/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp Added test to show use of HttpRequest::setHeaders --- .../NetworkTest/HttpClientTest.cpp | 44 ++++++++++++++----- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/samples/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp b/samples/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp index 7a0741db42..abe50a6030 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp +++ b/samples/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp @@ -101,18 +101,40 @@ void HttpClientTest::onMenuGetTestClicked(cocos2d::CCObject *sender) void HttpClientTest::onMenuPostTestClicked(cocos2d::CCObject *sender) { - CCHttpRequest* request = new CCHttpRequest(); - request->setUrl("http://www.httpbin.org/post"); - request->setRequestType(CCHttpRequest::kHttpPost); - request->setResponseCallback(this, callfuncND_selector(HttpClientTest::onHttpRequestCompleted)); + // test 1 + { + CCHttpRequest* request = new CCHttpRequest(); + request->setUrl("http://www.httpbin.org/post"); + request->setRequestType(CCHttpRequest::kHttpPost); + request->setResponseCallback(this, callfuncND_selector(HttpClientTest::onHttpRequestCompleted)); + + // write the post data + const char* postData = "visitor=cocos2d&TestSuite=Extensions Test/NetworkTest"; + request->setRequestData(postData, strlen(postData)); + + request->setTag("POST test1"); + CCHttpClient::getInstance()->send(request); + request->release(); + } - // write the post data - const char* postData = "visitor=cocos2d&TestSuite=Extensions Test/NetowrkTest"; - request->setRequestData(postData, strlen(postData)); - - request->setTag("POST test"); - CCHttpClient::getInstance()->send(request); - request->release(); + // test 2: set Content-Type + { + CCHttpRequest* request = new CCHttpRequest(); + request->setUrl("http://www.httpbin.org/post"); + request->setRequestType(CCHttpRequest::kHttpPost); + std::vector headers; + headers.push_back("Content-Type: application/json; charset=utf-8"); + request->setHeaders(headers); + request->setResponseCallback(this, callfuncND_selector(HttpClientTest::onHttpRequestCompleted)); + + // write the post data + const char* postData = "visitor=cocos2d&TestSuite=Extensions Test/NetworkTest"; + request->setRequestData(postData, strlen(postData)); + + request->setTag("POST test2"); + CCHttpClient::getInstance()->send(request); + request->release(); + } // waiting m_labelStatusCode->setString("waiting..."); From a568c1d22181f71868596948c6c8c150f438dc79 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 24 Sep 2012 17:24:00 +0800 Subject: [PATCH 120/181] revert modification of AppDelegate.cpp --- samples/HelloCpp/Classes/AppDelegate.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/samples/HelloCpp/Classes/AppDelegate.cpp b/samples/HelloCpp/Classes/AppDelegate.cpp index c03e87a8aa..864ac4cb54 100644 --- a/samples/HelloCpp/Classes/AppDelegate.cpp +++ b/samples/HelloCpp/Classes/AppDelegate.cpp @@ -33,12 +33,10 @@ bool AppDelegate::applicationDidFinishLaunching() { // iphone // try to enable retina on device - // notice: passby CCDirecor::enableRetinaDisplay(), call CCEGLView::enableRetina() directly - if (true == CCEGLView::sharedOpenGLView()->enableRetina()) + if (true == CCDirector::sharedDirector()->enableRetinaDisplay(true)) { // iphone hd CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd"); - CCEGLView::sharedOpenGLView()->setDesignResolutionSize(960, 640, kResolutionNoBorder); } else { From 624bedad38d4f8750a86f842c24c3f27ae348f85 Mon Sep 17 00:00:00 2001 From: Byung Choi Date: Mon, 24 Sep 2012 20:14:42 +0900 Subject: [PATCH 121/181] fixed cocos2dx linux makefile to link libfontconfig --- cocos2dx/proj.linux/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/proj.linux/Makefile b/cocos2dx/proj.linux/Makefile index 1a5b8aa59d..97832f1929 100644 --- a/cocos2dx/proj.linux/Makefile +++ b/cocos2dx/proj.linux/Makefile @@ -205,7 +205,7 @@ STATICLIBS = $(STATICLIBS_DIR)/libfreetype.a \ $(STATICLIBS_DIR)/libtiff.a \ SHAREDLIBS = -SHAREDLIBS += -lglfw -lGL -lcurl +SHAREDLIBS += -lglfw -lGL -lcurl -lfontconfig SHAREDLIBS += -Wl,-rpath,../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib SHAREDLIBS += -L../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib -lGLEW From 609c4b12f9520151da4575efde1839fe4ba79eb4 Mon Sep 17 00:00:00 2001 From: walzer Date: Mon, 24 Sep 2012 21:14:08 +0800 Subject: [PATCH 122/181] revert back SimpleGame to enableRetinaDisplay approach. Update background image of HelloCpp to 640x1136. --- .../iphonehd/HelloWorld.png.REMOVED.git-id | 2 +- samples/SimpleGame/Classes/AppDelegate.cpp | 6 ++---- .../SimpleGame/Classes/HelloWorldScene.cpp | 19 +++---------------- samples/SimpleGame/Classes/HelloWorldScene.h | 1 - 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/samples/HelloCpp/Resources/iphonehd/HelloWorld.png.REMOVED.git-id b/samples/HelloCpp/Resources/iphonehd/HelloWorld.png.REMOVED.git-id index d81514b887..9540c0bfb7 100644 --- a/samples/HelloCpp/Resources/iphonehd/HelloWorld.png.REMOVED.git-id +++ b/samples/HelloCpp/Resources/iphonehd/HelloWorld.png.REMOVED.git-id @@ -1 +1 @@ -e35126a63c774b4967e6b0e31082d7a32f58ed02 \ No newline at end of file +6b7a2544be32ce26e75737865743649598d83bdf \ No newline at end of file diff --git a/samples/SimpleGame/Classes/AppDelegate.cpp b/samples/SimpleGame/Classes/AppDelegate.cpp index a614d78518..e810c9fa23 100644 --- a/samples/SimpleGame/Classes/AppDelegate.cpp +++ b/samples/SimpleGame/Classes/AppDelegate.cpp @@ -31,17 +31,15 @@ bool AppDelegate::applicationDidFinishLaunching() { } else if (target == kTargetIphone) { - if (CCEGLView::sharedOpenGLView()->enableRetina()) + if (CCDirector::sharedDirector()->enableRetinaDisplay(true)) { - // well, it's a iPhone 4 and above, with 960x480 Retina resolution + // well, it's a iPhone 4, iPhone 4S or iPhone 5 CCFileUtils::sharedFileUtils()->setResourceDirectory("hd"); - CCEGLView::sharedOpenGLView()->setDesignResolutionSize(960, 640, kResolutionNoBorder); } else { // iPhone 3GS and before, with 480x320 resolution CCFileUtils::sharedFileUtils()->setResourceDirectory("sd"); - CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionNoBorder); } } else diff --git a/samples/SimpleGame/Classes/HelloWorldScene.cpp b/samples/SimpleGame/Classes/HelloWorldScene.cpp index 04e523e338..50708b2e56 100755 --- a/samples/SimpleGame/Classes/HelloWorldScene.cpp +++ b/samples/SimpleGame/Classes/HelloWorldScene.cpp @@ -4,8 +4,6 @@ using namespace cocos2d; -extern float g_scaleRatio; - HelloWorld::~HelloWorld() { if (_targets) @@ -28,18 +26,7 @@ HelloWorld::HelloWorld() :_targets(NULL) ,_projectiles(NULL) ,_projectilesDestroyed(0) -,_scaleRatio(1.0) { - if ( 0 == strcmp(CCFileUtils::sharedFileUtils()->getResourceDirectory(), "hd/") ) - { - // AppDelegate.cpp used hd resource & 960x640 design resolution - _scaleRatio = 2.0; - } - else - { - // sd - _scaleRatio = 1.0; - } } CCScene* HelloWorld::scene() @@ -106,7 +93,7 @@ bool HelloWorld::init() ///////////////////////////// // 2. add your codes below... - CCSprite *player = CCSprite::create("Player.png", CCRectMake(0, 0, 27*_scaleRatio, 40*_scaleRatio) ); + CCSprite *player = CCSprite::create("Player.png", CCRectMake(0, 0, 27, 40) ); player->setPosition( ccp(origin.x + player->getContentSize().width/2, origin.y + visibleSize.height/2) ); @@ -140,7 +127,7 @@ void HelloWorld::menuCloseCallback(CCObject* pSender) // cpp with cocos2d-x void HelloWorld::addTarget() { - CCSprite *target = CCSprite::create("Target.png", CCRectMake(0,0,27*_scaleRatio,40*_scaleRatio) ); + CCSprite *target = CCSprite::create("Target.png", CCRectMake(0,0,27,40) ); // Determine where to spawn the target along the Y axis CCSize winSize = CCDirector::sharedDirector()->getVisibleSize(); @@ -212,7 +199,7 @@ void HelloWorld::ccTouchesEnded(CCSet* touches, CCEvent* event) // Set up initial location of projectile CCSize winSize = CCDirector::sharedDirector()->getVisibleSize(); - CCSprite *projectile = CCSprite::create("Projectile.png", CCRectMake(0, 0, 20*_scaleRatio, 20*_scaleRatio)); + CCSprite *projectile = CCSprite::create("Projectile.png", CCRectMake(0, 0, 20, 20)); projectile->setPosition( ccp(20, winSize.height/2) ); // Determinie offset of location to projectile diff --git a/samples/SimpleGame/Classes/HelloWorldScene.h b/samples/SimpleGame/Classes/HelloWorldScene.h index d88c7aa81b..c1fcbd2f1c 100755 --- a/samples/SimpleGame/Classes/HelloWorldScene.h +++ b/samples/SimpleGame/Classes/HelloWorldScene.h @@ -38,7 +38,6 @@ protected: cocos2d::CCArray *_targets; cocos2d::CCArray *_projectiles; int _projectilesDestroyed; - float _scaleRatio; void addTarget(); From 06f639edabfa306e5340df796f4aa60979d25289 Mon Sep 17 00:00:00 2001 From: walzer Date: Mon, 24 Sep 2012 21:22:20 +0800 Subject: [PATCH 123/181] update copyright to 2012, update cocos2d version to 2.0.3 1. update all copyright from 2010-2011 to 2010-2012 cocos2d-x.org 2. update COCOS2D_VERSION to 0x00020003 3. update const char* cocos2dVersion() to "cocos2d-2.0-x-2.0.3" --- CocosDenshion/include/SimpleAudioEngine.h | 2 +- cocos2dx/CCCamera.cpp | 2 +- cocos2dx/CCCamera.h | 2 +- cocos2dx/CCDirector.h | 2 +- cocos2dx/CCDrawingPrimitives.cpp | 2 +- cocos2dx/CCScheduler.cpp | 2 +- cocos2dx/CCScheduler.h | 2 +- cocos2dx/actions/CCAction.cpp | 2 +- cocos2dx/actions/CCActionCamera.cpp | 2 +- cocos2dx/actions/CCActionCamera.h | 2 +- cocos2dx/actions/CCActionEase.cpp | 2 +- cocos2dx/actions/CCActionEase.h | 2 +- cocos2dx/actions/CCActionGrid.cpp | 2 +- cocos2dx/actions/CCActionGrid.h | 2 +- cocos2dx/actions/CCActionInterval.cpp | 2 +- cocos2dx/actions/CCActionInterval.h | 2 +- cocos2dx/actions/CCActionManager.cpp | 2 +- cocos2dx/actions/CCActionManager.h | 2 +- cocos2dx/actions/CCActionPageTurn3D.cpp | 2 +- cocos2dx/actions/CCActionPageTurn3D.h | 2 +- cocos2dx/actions/CCActionProgressTimer.cpp | 2 +- cocos2dx/actions/CCActionProgressTimer.h | 2 +- cocos2dx/actions/CCActionTiledGrid.h | 2 +- cocos2dx/actions/CCActionTween.cpp | 2 +- cocos2dx/actions/CCActionTween.h | 2 +- cocos2dx/base_nodes/CCAtlasNode.cpp | 2 +- cocos2dx/base_nodes/CCAtlasNode.h | 2 +- cocos2dx/cocos2d.cpp | 4 ++-- cocos2dx/effects/CCGrabber.cpp | 2 +- cocos2dx/effects/CCGrabber.h | 2 +- cocos2dx/effects/CCGrid.cpp | 2 +- cocos2dx/effects/CCGrid.h | 2 +- cocos2dx/include/CCProtocols.h | 2 +- cocos2dx/include/ccConfig.h | 2 +- cocos2dx/include/ccMacros.h | 2 +- cocos2dx/include/ccTypes.h | 2 +- cocos2dx/include/cocos2d.h | 4 ++-- cocos2dx/label_nodes/CCLabelAtlas.cpp | 2 +- cocos2dx/label_nodes/CCLabelAtlas.h | 2 +- cocos2dx/label_nodes/CCLabelBMFont.cpp | 2 +- cocos2dx/label_nodes/CCLabelBMFont.h | 2 +- cocos2dx/label_nodes/CCLabelTTF.cpp | 2 +- cocos2dx/label_nodes/CCLabelTTF.h | 2 +- cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp | 2 +- cocos2dx/layers_scenes_transitions_nodes/CCTransition.h | 2 +- .../layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp | 2 +- .../layers_scenes_transitions_nodes/CCTransitionPageTurn.h | 2 +- .../layers_scenes_transitions_nodes/CCTransitionProgress.cpp | 2 +- .../layers_scenes_transitions_nodes/CCTransitionProgress.h | 2 +- cocos2dx/particle_nodes/CCParticleExamples.cpp | 2 +- cocos2dx/particle_nodes/CCParticleExamples.h | 2 +- cocos2dx/platform/ios/CCFileUtils.mm | 2 +- cocos2dx/script_support/CCScriptSupport.cpp | 2 +- cocos2dx/script_support/CCScriptSupport.h | 2 +- cocos2dx/shaders/CCShaderCache.cpp | 2 +- cocos2dx/shaders/CCShaderCache.h | 2 +- cocos2dx/shaders/ccGLStateCache.cpp | 2 +- cocos2dx/shaders/ccGLStateCache.h | 2 +- cocos2dx/shaders/ccShaders.cpp | 2 +- cocos2dx/shaders/ccShaders.h | 2 +- cocos2dx/sprite_nodes/CCAnimation.cpp | 2 +- cocos2dx/sprite_nodes/CCAnimation.h | 2 +- cocos2dx/sprite_nodes/CCAnimationCache.cpp | 2 +- cocos2dx/sprite_nodes/CCAnimationCache.h | 2 +- cocos2dx/sprite_nodes/CCSprite.h | 2 +- cocos2dx/sprite_nodes/CCSpriteFrame.cpp | 2 +- cocos2dx/sprite_nodes/CCSpriteFrame.h | 2 +- cocos2dx/support/CCNotificationCenter.cpp | 2 +- cocos2dx/support/CCNotificationCenter.h | 2 +- cocos2dx/support/CCPointExtension.cpp | 2 +- cocos2dx/support/CCPointExtension.h | 2 +- cocos2dx/support/CCProfiling.cpp | 2 +- cocos2dx/support/CCProfiling.h | 2 +- cocos2dx/support/CCUserDefault.cpp | 2 +- cocos2dx/support/CCUserDefault.h | 2 +- cocos2dx/support/TransformUtils.cpp | 2 +- cocos2dx/support/TransformUtils.h | 2 +- cocos2dx/textures/CCTextureAtlas.cpp | 2 +- cocos2dx/textures/CCTextureAtlas.h | 2 +- cocos2dx/textures/CCTextureCache.cpp | 2 +- cocos2dx/textures/CCTextureCache.h | 2 +- cocos2dx/textures/CCTexturePVR.cpp | 2 +- cocos2dx/tilemap_parallax_nodes/CCParallaxNode.cpp | 2 +- cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h | 2 +- cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp | 2 +- cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h | 2 +- cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp | 2 +- cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.h | 2 +- cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.cpp | 2 +- cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.h | 2 +- cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp | 2 +- cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h | 2 +- cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.cpp | 2 +- cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.h | 2 +- cocos2dx/touch_dispatcher/CCTouchDelegateProtocol.h | 2 +- cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp | 2 +- cocos2dx/touch_dispatcher/CCTouchDispatcher.h | 2 +- cocos2dx/touch_dispatcher/CCTouchHandler.cpp | 2 +- cocos2dx/touch_dispatcher/CCTouchHandler.h | 2 +- 99 files changed, 101 insertions(+), 101 deletions(-) diff --git a/CocosDenshion/include/SimpleAudioEngine.h b/CocosDenshion/include/SimpleAudioEngine.h index 8d370ba3fe..8c9cf1c8c1 100644 --- a/CocosDenshion/include/SimpleAudioEngine.h +++ b/CocosDenshion/include/SimpleAudioEngine.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Steve Oldmeadow http://www.cocos2d-x.org diff --git a/cocos2dx/CCCamera.cpp b/cocos2dx/CCCamera.cpp index d13020e7cb..d478a3fdad 100644 --- a/cocos2dx/CCCamera.cpp +++ b/cocos2dx/CCCamera.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada http://www.cocos2d-x.org diff --git a/cocos2dx/CCCamera.h b/cocos2dx/CCCamera.h index e38f6c478d..f355622bfc 100644 --- a/cocos2dx/CCCamera.h +++ b/cocos2dx/CCCamera.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/CCDirector.h b/cocos2dx/CCDirector.h index 9cbc06d6b2..a29ef4db6d 100644 --- a/cocos2dx/CCDirector.h +++ b/cocos2dx/CCDirector.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/CCDrawingPrimitives.cpp b/cocos2dx/CCDrawingPrimitives.cpp index a8f90027d9..574b4e3ac0 100644 --- a/cocos2dx/CCDrawingPrimitives.cpp +++ b/cocos2dx/CCDrawingPrimitives.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/CCScheduler.cpp b/cocos2dx/CCScheduler.cpp index e7ce2c8e23..6d9e6f01f2 100644 --- a/cocos2dx/CCScheduler.cpp +++ b/cocos2dx/CCScheduler.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/CCScheduler.h b/cocos2dx/CCScheduler.h index af3ed28958..51fc2ef6af 100644 --- a/cocos2dx/CCScheduler.h +++ b/cocos2dx/CCScheduler.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/actions/CCAction.cpp b/cocos2dx/actions/CCAction.cpp index 4097900773..9f79a5954e 100644 --- a/cocos2dx/actions/CCAction.cpp +++ b/cocos2dx/actions/CCAction.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/actions/CCActionCamera.cpp b/cocos2dx/actions/CCActionCamera.cpp index b26aea88ad..f166f0dda1 100644 --- a/cocos2dx/actions/CCActionCamera.cpp +++ b/cocos2dx/actions/CCActionCamera.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/actions/CCActionCamera.h b/cocos2dx/actions/CCActionCamera.h index 93560acf92..23a80a1dc7 100644 --- a/cocos2dx/actions/CCActionCamera.h +++ b/cocos2dx/actions/CCActionCamera.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada http://www.cocos2d-x.org diff --git a/cocos2dx/actions/CCActionEase.cpp b/cocos2dx/actions/CCActionEase.cpp index 20319b46fc..11e7b655fa 100644 --- a/cocos2dx/actions/CCActionEase.cpp +++ b/cocos2dx/actions/CCActionEase.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2009 Jason Booth http://www.cocos2d-x.org diff --git a/cocos2dx/actions/CCActionEase.h b/cocos2dx/actions/CCActionEase.h index e7e9aeb38b..0118d3e136 100644 --- a/cocos2dx/actions/CCActionEase.h +++ b/cocos2dx/actions/CCActionEase.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2009 Jason Booth http://www.cocos2d-x.org diff --git a/cocos2dx/actions/CCActionGrid.cpp b/cocos2dx/actions/CCActionGrid.cpp index b7466062e9..dcf753e2a0 100644 --- a/cocos2dx/actions/CCActionGrid.cpp +++ b/cocos2dx/actions/CCActionGrid.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 On-Core http://www.cocos2d-x.org diff --git a/cocos2dx/actions/CCActionGrid.h b/cocos2dx/actions/CCActionGrid.h index 24d5e6e2ef..3afaed4049 100644 --- a/cocos2dx/actions/CCActionGrid.h +++ b/cocos2dx/actions/CCActionGrid.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 On-Core http://www.cocos2d-x.org diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index 194d3f693c..feb14944f9 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/actions/CCActionInterval.h b/cocos2dx/actions/CCActionInterval.h index bdd147e478..23f887cb9d 100644 --- a/cocos2dx/actions/CCActionInterval.h +++ b/cocos2dx/actions/CCActionInterval.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2011 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/actions/CCActionManager.cpp b/cocos2dx/actions/CCActionManager.cpp index 5fd2514a75..6308e7c8d1 100644 --- a/cocos2dx/actions/CCActionManager.cpp +++ b/cocos2dx/actions/CCActionManager.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Valentin Milea Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/actions/CCActionManager.h b/cocos2dx/actions/CCActionManager.h index 0f2fba72c5..f789993cb3 100644 --- a/cocos2dx/actions/CCActionManager.h +++ b/cocos2dx/actions/CCActionManager.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Valentin Milea Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/actions/CCActionPageTurn3D.cpp b/cocos2dx/actions/CCActionPageTurn3D.cpp index 8397c454dc..fb932974d6 100644 --- a/cocos2dx/actions/CCActionPageTurn3D.cpp +++ b/cocos2dx/actions/CCActionPageTurn3D.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/ http://www.cocos2d-x.org diff --git a/cocos2dx/actions/CCActionPageTurn3D.h b/cocos2dx/actions/CCActionPageTurn3D.h index 6de968494a..3f9117132e 100644 --- a/cocos2dx/actions/CCActionPageTurn3D.h +++ b/cocos2dx/actions/CCActionPageTurn3D.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/ http://www.cocos2d-x.org diff --git a/cocos2dx/actions/CCActionProgressTimer.cpp b/cocos2dx/actions/CCActionProgressTimer.cpp index bb6846dff7..5c1ba81133 100644 --- a/cocos2dx/actions/CCActionProgressTimer.cpp +++ b/cocos2dx/actions/CCActionProgressTimer.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (C) 2010 Lam Pham http://www.cocos2d-x.org diff --git a/cocos2dx/actions/CCActionProgressTimer.h b/cocos2dx/actions/CCActionProgressTimer.h index e75a529f2a..aa408c0960 100644 --- a/cocos2dx/actions/CCActionProgressTimer.h +++ b/cocos2dx/actions/CCActionProgressTimer.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (C) 2010 Lam Pham http://www.cocos2d-x.org diff --git a/cocos2dx/actions/CCActionTiledGrid.h b/cocos2dx/actions/CCActionTiledGrid.h index 020772fe54..06bdd3abd6 100644 --- a/cocos2dx/actions/CCActionTiledGrid.h +++ b/cocos2dx/actions/CCActionTiledGrid.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 On-Core http://www.cocos2d-x.org diff --git a/cocos2dx/actions/CCActionTween.cpp b/cocos2dx/actions/CCActionTween.cpp index 7e775cf614..6aefcd16fc 100644 --- a/cocos2dx/actions/CCActionTween.cpp +++ b/cocos2dx/actions/CCActionTween.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright 2009 lhunath (Maarten Billemont) http://www.cocos2d-x.org diff --git a/cocos2dx/actions/CCActionTween.h b/cocos2dx/actions/CCActionTween.h index 2d9197c501..8fc4a7eb82 100644 --- a/cocos2dx/actions/CCActionTween.h +++ b/cocos2dx/actions/CCActionTween.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright 2009 lhunath (Maarten Billemont) http://www.cocos2d-x.org diff --git a/cocos2dx/base_nodes/CCAtlasNode.cpp b/cocos2dx/base_nodes/CCAtlasNode.cpp index db54b2052f..cae3c9caf7 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.cpp +++ b/cocos2dx/base_nodes/CCAtlasNode.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/base_nodes/CCAtlasNode.h b/cocos2dx/base_nodes/CCAtlasNode.h index 50885b3778..c239fa57d6 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.h +++ b/cocos2dx/base_nodes/CCAtlasNode.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/cocos2d.cpp b/cocos2dx/cocos2d.cpp index 23bb23fb79..3d374740de 100644 --- a/cocos2dx/cocos2d.cpp +++ b/cocos2dx/cocos2d.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -30,7 +30,7 @@ NS_CC_BEGIN const char* cocos2dVersion() { - return "cocos2d-2.0-x-2.0.2"; + return "cocos2d-2.0-x-2.0.3"; } NS_CC_END diff --git a/cocos2dx/effects/CCGrabber.cpp b/cocos2dx/effects/CCGrabber.cpp index 6a408960c9..0b63766a9f 100644 --- a/cocos2dx/effects/CCGrabber.cpp +++ b/cocos2dx/effects/CCGrabber.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 On-Core http://www.cocos2d-x.org diff --git a/cocos2dx/effects/CCGrabber.h b/cocos2dx/effects/CCGrabber.h index 701b2643fc..9dad0c9554 100644 --- a/cocos2dx/effects/CCGrabber.h +++ b/cocos2dx/effects/CCGrabber.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 On-Core http://www.cocos2d-x.org diff --git a/cocos2dx/effects/CCGrid.cpp b/cocos2dx/effects/CCGrid.cpp index 9bd870c036..3e09ce029c 100644 --- a/cocos2dx/effects/CCGrid.cpp +++ b/cocos2dx/effects/CCGrid.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 On-Core http://www.cocos2d-x.org diff --git a/cocos2dx/effects/CCGrid.h b/cocos2dx/effects/CCGrid.h index e6e49c1a5e..13b01271ca 100644 --- a/cocos2dx/effects/CCGrid.h +++ b/cocos2dx/effects/CCGrid.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 On-Core http://www.cocos2d-x.org diff --git a/cocos2dx/include/CCProtocols.h b/cocos2dx/include/CCProtocols.h index 6ea1c60664..febee5a16d 100644 --- a/cocos2dx/include/CCProtocols.h +++ b/cocos2dx/include/CCProtocols.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada http://www.cocos2d-x.org diff --git a/cocos2dx/include/ccConfig.h b/cocos2dx/include/ccConfig.h index 569c377898..e6502cf630 100644 --- a/cocos2dx/include/ccConfig.h +++ b/cocos2dx/include/ccConfig.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/include/ccMacros.h b/cocos2dx/include/ccMacros.h index e3c3dff77c..a461b29fbb 100644 --- a/cocos2dx/include/ccMacros.h +++ b/cocos2dx/include/ccMacros.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/include/ccTypes.h b/cocos2dx/include/ccTypes.h index 790de5cab1..cf24eaaece 100644 --- a/cocos2dx/include/ccTypes.h +++ b/cocos2dx/include/ccTypes.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/include/cocos2d.h b/cocos2dx/include/cocos2d.h index 5c637a8a69..52bd76ad88 100755 --- a/cocos2dx/include/cocos2d.h +++ b/cocos2dx/include/cocos2d.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -29,7 +29,7 @@ THE SOFTWARE. // 0x00 HI ME LO // 00 02 00 00 -#define COCOS2D_VERSION 0x00020000 +#define COCOS2D_VERSION 0x00020003 // // all cocos2d include files diff --git a/cocos2dx/label_nodes/CCLabelAtlas.cpp b/cocos2dx/label_nodes/CCLabelAtlas.cpp index 5bf84f02f5..8a834918f5 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.cpp +++ b/cocos2dx/label_nodes/CCLabelAtlas.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/label_nodes/CCLabelAtlas.h b/cocos2dx/label_nodes/CCLabelAtlas.h index 01cc8b8ec6..5c8918503e 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.h +++ b/cocos2dx/label_nodes/CCLabelAtlas.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 299fd7553d..f919ac2fb7 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/label_nodes/CCLabelBMFont.h b/cocos2dx/label_nodes/CCLabelBMFont.h index 0488b3df3e..83d6b7c791 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.h +++ b/cocos2dx/label_nodes/CCLabelBMFont.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index 1aaa340771..b073ea8bb6 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada http://www.cocos2d-x.org diff --git a/cocos2dx/label_nodes/CCLabelTTF.h b/cocos2dx/label_nodes/CCLabelTTF.h index 68cda8fc84..394bae3c25 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.h +++ b/cocos2dx/label_nodes/CCLabelTTF.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada http://www.cocos2d-x.org diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp index 8a0fa94a5f..e26943c9a1 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h index a146af445a..38a9e525f8 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp index 14986f6f69..706c1d425f 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/ http://www.cocos2d-x.org diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h index 6d31e63a06..63f7c3771f 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/ http://www.cocos2d-x.org diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp index ee9b0cfb69..06b75864dc 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Lam Pham Copyright (c) 2012 Ricardo Quesada diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h index 7ae48686be..5bbf0ce856 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Lam Pham Copyright (c) 2012 Ricardo Quesada diff --git a/cocos2dx/particle_nodes/CCParticleExamples.cpp b/cocos2dx/particle_nodes/CCParticleExamples.cpp index b931458302..c13c74623e 100644 --- a/cocos2dx/particle_nodes/CCParticleExamples.cpp +++ b/cocos2dx/particle_nodes/CCParticleExamples.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/particle_nodes/CCParticleExamples.h b/cocos2dx/particle_nodes/CCParticleExamples.h index b36033149d..c6b91847b8 100644 --- a/cocos2dx/particle_nodes/CCParticleExamples.h +++ b/cocos2dx/particle_nodes/CCParticleExamples.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/platform/ios/CCFileUtils.mm b/cocos2dx/platform/ios/CCFileUtils.mm index 5f5c62ac2a..f266d52ed9 100644 --- a/cocos2dx/platform/ios/CCFileUtils.mm +++ b/cocos2dx/platform/ios/CCFileUtils.mm @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. http://www.cocos2d-x.org diff --git a/cocos2dx/script_support/CCScriptSupport.cpp b/cocos2dx/script_support/CCScriptSupport.cpp index cfe788731f..bcaab5f11e 100644 --- a/cocos2dx/script_support/CCScriptSupport.cpp +++ b/cocos2dx/script_support/CCScriptSupport.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2010-2011 cocos2d-x.org + Copyright (c) 2010-2012 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos2dx/script_support/CCScriptSupport.h b/cocos2dx/script_support/CCScriptSupport.h index 93856a8c2c..822c09f6cb 100644 --- a/cocos2dx/script_support/CCScriptSupport.h +++ b/cocos2dx/script_support/CCScriptSupport.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2010-2011 cocos2d-x.org + Copyright (c) 2010-2012 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos2dx/shaders/CCShaderCache.cpp b/cocos2dx/shaders/CCShaderCache.cpp index 2ff29d8976..92c0782895 100644 --- a/cocos2dx/shaders/CCShaderCache.cpp +++ b/cocos2dx/shaders/CCShaderCache.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/shaders/CCShaderCache.h b/cocos2dx/shaders/CCShaderCache.h index 455c58eb06..b28c5b1e10 100644 --- a/cocos2dx/shaders/CCShaderCache.h +++ b/cocos2dx/shaders/CCShaderCache.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/shaders/ccGLStateCache.cpp b/cocos2dx/shaders/ccGLStateCache.cpp index 0863250f0e..e27a07ace3 100644 --- a/cocos2dx/shaders/ccGLStateCache.cpp +++ b/cocos2dx/shaders/ccGLStateCache.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/shaders/ccGLStateCache.h b/cocos2dx/shaders/ccGLStateCache.h index ce9529935b..3d4f31afd4 100644 --- a/cocos2dx/shaders/ccGLStateCache.h +++ b/cocos2dx/shaders/ccGLStateCache.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/shaders/ccShaders.cpp b/cocos2dx/shaders/ccShaders.cpp index 1ebf0c49b6..a58819bb64 100644 --- a/cocos2dx/shaders/ccShaders.cpp +++ b/cocos2dx/shaders/ccShaders.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. http://www.cocos2d-x.org diff --git a/cocos2dx/shaders/ccShaders.h b/cocos2dx/shaders/ccShaders.h index c9fec3a1ca..239007331a 100644 --- a/cocos2dx/shaders/ccShaders.h +++ b/cocos2dx/shaders/ccShaders.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. http://www.cocos2d-x.org diff --git a/cocos2dx/sprite_nodes/CCAnimation.cpp b/cocos2dx/sprite_nodes/CCAnimation.cpp index fca1da0e0e..f52527dbc5 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.cpp +++ b/cocos2dx/sprite_nodes/CCAnimation.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/sprite_nodes/CCAnimation.h b/cocos2dx/sprite_nodes/CCAnimation.h index 9d92817894..8bf9dc8949 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.h +++ b/cocos2dx/sprite_nodes/CCAnimation.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/sprite_nodes/CCAnimationCache.cpp b/cocos2dx/sprite_nodes/CCAnimationCache.cpp index 0a6fdea4ac..e725774ed8 100644 --- a/cocos2dx/sprite_nodes/CCAnimationCache.cpp +++ b/cocos2dx/sprite_nodes/CCAnimationCache.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/sprite_nodes/CCAnimationCache.h b/cocos2dx/sprite_nodes/CCAnimationCache.h index ac86cc5494..264396e7ee 100644 --- a/cocos2dx/sprite_nodes/CCAnimationCache.h +++ b/cocos2dx/sprite_nodes/CCAnimationCache.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/sprite_nodes/CCSprite.h b/cocos2dx/sprite_nodes/CCSprite.h index ed5994b765..2b1469ec9e 100644 --- a/cocos2dx/sprite_nodes/CCSprite.h +++ b/cocos2dx/sprite_nodes/CCSprite.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/sprite_nodes/CCSpriteFrame.cpp b/cocos2dx/sprite_nodes/CCSpriteFrame.cpp index 616a22c62f..8277ae2ee6 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrame.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrame.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2011 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/sprite_nodes/CCSpriteFrame.h b/cocos2dx/sprite_nodes/CCSpriteFrame.h index 6f2f2a03dc..4eecbcb11a 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrame.h +++ b/cocos2dx/sprite_nodes/CCSpriteFrame.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2011 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/support/CCNotificationCenter.cpp b/cocos2dx/support/CCNotificationCenter.cpp index 71b0af28dc..f08ba42fc4 100644 --- a/cocos2dx/support/CCNotificationCenter.cpp +++ b/cocos2dx/support/CCNotificationCenter.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Erawppa http://www.cocos2d-x.org diff --git a/cocos2dx/support/CCNotificationCenter.h b/cocos2dx/support/CCNotificationCenter.h index 0876b5b7a7..183c5f7020 100644 --- a/cocos2dx/support/CCNotificationCenter.h +++ b/cocos2dx/support/CCNotificationCenter.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Erawppa http://www.cocos2d-x.org diff --git a/cocos2dx/support/CCPointExtension.cpp b/cocos2dx/support/CCPointExtension.cpp index 50831f1464..d3400c6fa4 100644 --- a/cocos2dx/support/CCPointExtension.cpp +++ b/cocos2dx/support/CCPointExtension.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2007 Scott Lembcke Copyright (c) 2010 Lam Pham diff --git a/cocos2dx/support/CCPointExtension.h b/cocos2dx/support/CCPointExtension.h index d288704af5..b5c76a165c 100644 --- a/cocos2dx/support/CCPointExtension.h +++ b/cocos2dx/support/CCPointExtension.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2007 Scott Lembcke Copyright (c) 2010 Lam Pham diff --git a/cocos2dx/support/CCProfiling.cpp b/cocos2dx/support/CCProfiling.cpp index 27099de0ee..8f741f373a 100644 --- a/cocos2dx/support/CCProfiling.cpp +++ b/cocos2dx/support/CCProfiling.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Stuart Carnie http://www.cocos2d-x.org diff --git a/cocos2dx/support/CCProfiling.h b/cocos2dx/support/CCProfiling.h index 3a6b902c47..1923f78a2c 100644 --- a/cocos2dx/support/CCProfiling.h +++ b/cocos2dx/support/CCProfiling.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Stuart Carnie http://www.cocos2d-x.org diff --git a/cocos2dx/support/CCUserDefault.cpp b/cocos2dx/support/CCUserDefault.cpp index 2c13b2cf51..8c404c3c41 100644 --- a/cocos2dx/support/CCUserDefault.cpp +++ b/cocos2dx/support/CCUserDefault.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos2dx/support/CCUserDefault.h b/cocos2dx/support/CCUserDefault.h index 9c845f3f7f..a7991e82a0 100644 --- a/cocos2dx/support/CCUserDefault.h +++ b/cocos2dx/support/CCUserDefault.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos2dx/support/TransformUtils.cpp b/cocos2dx/support/TransformUtils.cpp index 0958670e22..d205b921cd 100644 --- a/cocos2dx/support/TransformUtils.cpp +++ b/cocos2dx/support/TransformUtils.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Valentin Milea http://www.cocos2d-x.org diff --git a/cocos2dx/support/TransformUtils.h b/cocos2dx/support/TransformUtils.h index 7ea972943e..94b742e58a 100644 --- a/cocos2dx/support/TransformUtils.h +++ b/cocos2dx/support/TransformUtils.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Valentin Milea http://www.cocos2d-x.org diff --git a/cocos2dx/textures/CCTextureAtlas.cpp b/cocos2dx/textures/CCTextureAtlas.cpp index 04532049fb..88bee3c94d 100644 --- a/cocos2dx/textures/CCTextureAtlas.cpp +++ b/cocos2dx/textures/CCTextureAtlas.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/textures/CCTextureAtlas.h b/cocos2dx/textures/CCTextureAtlas.h index ee9376cfcb..0f90c8d4a5 100644 --- a/cocos2dx/textures/CCTextureAtlas.h +++ b/cocos2dx/textures/CCTextureAtlas.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index c150af905b..0d89a6d614 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/textures/CCTextureCache.h b/cocos2dx/textures/CCTextureCache.h index 3f7bb1ef01..0db94e670e 100644 --- a/cocos2dx/textures/CCTextureCache.h +++ b/cocos2dx/textures/CCTextureCache.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp index eb28b96134..6e25a52f91 100644 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -1,6 +1,6 @@ /**************************************************************************** Copyright (c) 2011 Jirka Fajfr for cocos2d-x -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008 Apple Inc. All Rights Reserved. http://www.cocos2d-x.org diff --git a/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.cpp b/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.cpp index 746d58a837..b05f027d86 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h b/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h index ab658b39a4..d503cd153a 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h +++ b/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp index 03860d6a66..f27108cff2 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h index 0ebfc48206..850c11b6ca 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp index ff74ded472..806b7673a6 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Neophit Copyright (c) 2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.h b/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.h index 667784c2a4..f83b69ee35 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Neophit Copyright (c) 2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.cpp index 72a997e11c..71d807f7d0 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.h b/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.h index 6e672cd625..184c857e2a 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp index b11d4812d7..b02eeb3d02 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Максим Аксенов Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h index c1fe4522bf..dc2e1a334c 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.cpp b/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.cpp index 0b3f375425..c0968b1c1b 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.h b/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.h index 0994166cd8..5dd5742246 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/touch_dispatcher/CCTouchDelegateProtocol.h b/cocos2dx/touch_dispatcher/CCTouchDelegateProtocol.h index 4565ae52a4..eee7cb45d9 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDelegateProtocol.h +++ b/cocos2dx/touch_dispatcher/CCTouchDelegateProtocol.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Valentin Milea http://www.cocos2d-x.org diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp index 315b1a14d9..9af256688c 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Valentin Milea http://www.cocos2d-x.org diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.h b/cocos2dx/touch_dispatcher/CCTouchDispatcher.h index b2b1de685d..c7f4629a21 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.h +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Valentin Milea http://www.cocos2d-x.org diff --git a/cocos2dx/touch_dispatcher/CCTouchHandler.cpp b/cocos2dx/touch_dispatcher/CCTouchHandler.cpp index 224b1c1003..ce758212f4 100644 --- a/cocos2dx/touch_dispatcher/CCTouchHandler.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchHandler.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Valentin Milea http://www.cocos2d-x.org diff --git a/cocos2dx/touch_dispatcher/CCTouchHandler.h b/cocos2dx/touch_dispatcher/CCTouchHandler.h index 1b6eb222c1..5e8b6959dd 100644 --- a/cocos2dx/touch_dispatcher/CCTouchHandler.h +++ b/cocos2dx/touch_dispatcher/CCTouchHandler.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Valentin Milea http://www.cocos2d-x.org From 8693c549971fd72e96e53c702d51c3f39e5f5006 Mon Sep 17 00:00:00 2001 From: Donald Alan Morrison Date: Mon, 24 Sep 2012 14:55:40 -0700 Subject: [PATCH 124/181] Minor memory-logic error. textField is a retain property, so assigning to it retains it, and assigning NULL to it releases it. Also, an init method called release outside the proper scope (the do{}while(0); block). If you don't like the autorelease pool, it's easy enough to change this fix. Aside: someone pulled tools/cxx-generator again, not me(!) :-) --- extensions/GUI/CCEditBox/EditBoxImplIOS.mm | 7 ++----- tools/cxx-generator | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/extensions/GUI/CCEditBox/EditBoxImplIOS.mm b/extensions/GUI/CCEditBox/EditBoxImplIOS.mm index 7d88596e20..30bac05245 100644 --- a/extensions/GUI/CCEditBox/EditBoxImplIOS.mm +++ b/extensions/GUI/CCEditBox/EditBoxImplIOS.mm @@ -51,7 +51,7 @@ { [textField_ resignFirstResponder]; [textField_ removeFromSuperview]; - [textField_ release]; + self.textField = NULL; [super dealloc]; } @@ -63,7 +63,7 @@ { if (self == nil) break; editState_ = NO; - textField_ = [[CustomUITextField alloc] initWithFrame: frameRect]; + textField_ = [[[CustomUITextField alloc] initWithFrame: frameRect] autorelease]; if (!textField_) break; [textField_ setTextColor:[UIColor whiteColor]]; textField_.font = [UIFont systemFontOfSize:frameRect.size.height*2/3]; //TODO need to delete hard code here. @@ -79,9 +79,6 @@ return self; }while(0); - [textField_ release]; - - return nil; } diff --git a/tools/cxx-generator b/tools/cxx-generator index 40ad79373b..5154f8898b 160000 --- a/tools/cxx-generator +++ b/tools/cxx-generator @@ -1 +1 @@ -Subproject commit 40ad79373b6c041a3312afb36da6985b91f0a3dc +Subproject commit 5154f8898bb8755bda496a84fa39abe97d6a9b44 From 74b9e2539b63395d8720cff596a7f631dc8af28c Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 25 Sep 2012 12:13:06 +0800 Subject: [PATCH 125/181] fix auto building error --- .../org/cocos2dx/lib/Cocos2dxGLSurfaceView.java | 2 ++ .../cocos2dx/lib/Cocos2dxTextInputWraper.java | 16 +++++++++++++--- tools/jenkins_scripts/build.xml | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java index 5c719f999c..fc1ae21f5d 100644 --- a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java @@ -257,9 +257,11 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView { break; } + /* if (BuildConfig.DEBUG) { Cocos2dxGLSurfaceView.dumpMotionEvent(pMotionEvent); } + */ return true; } diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTextInputWraper.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTextInputWraper.java index e3a4685e4d..0f5c7f6d4a 100644 --- a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTextInputWraper.java +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTextInputWraper.java @@ -79,22 +79,26 @@ public class Cocos2dxTextInputWraper implements TextWatcher, OnEditorActionListe return; } - if (BuildConfig.DEBUG) { - Log.d(TAG, "afterTextChanged: " + s); - } + //if (BuildConfig.DEBUG) { + //Log.d(TAG, "afterTextChanged: " + s); + //} int nModified = s.length() - this.mText.length(); if (nModified > 0) { final String insertText = s.subSequence(this.mText.length(), s.length()).toString(); this.mCocos2dxGLSurfaceView.insertText(insertText); + /* if (BuildConfig.DEBUG) { Log.d(TAG, "insertText(" + insertText + ")"); } + */ } else { for (; nModified < 0; ++nModified) { this.mCocos2dxGLSurfaceView.deleteBackward(); + /* if (BuildConfig.DEBUG) { Log.d(TAG, "deleteBackward"); } + */ } } this.mText = s.toString(); @@ -102,9 +106,11 @@ public class Cocos2dxTextInputWraper implements TextWatcher, OnEditorActionListe @Override public void beforeTextChanged(final CharSequence pCharSequence, final int start, final int count, final int after) { + /* if (BuildConfig.DEBUG) { Log.d(TAG, "beforeTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",after: " + after); } + */ this.mText = pCharSequence.toString(); } @@ -119,9 +125,11 @@ public class Cocos2dxTextInputWraper implements TextWatcher, OnEditorActionListe // user press the action button, delete all old text and insert new text for (int i = this.mOriginText.length(); i > 0; i--) { this.mCocos2dxGLSurfaceView.deleteBackward(); + /* if (BuildConfig.DEBUG) { Log.d(TAG, "deleteBackward"); } + */ } String text = pTextView.getText().toString(); @@ -136,9 +144,11 @@ public class Cocos2dxTextInputWraper implements TextWatcher, OnEditorActionListe final String insertText = text; this.mCocos2dxGLSurfaceView.insertText(insertText); + /* if (BuildConfig.DEBUG) { Log.d(TAG, "insertText(" + insertText + ")"); } + */ } return false; } diff --git a/tools/jenkins_scripts/build.xml b/tools/jenkins_scripts/build.xml index dc1291ca26..06c54399fb 100644 --- a/tools/jenkins_scripts/build.xml +++ b/tools/jenkins_scripts/build.xml @@ -51,7 +51,7 @@ - + From 1a6581383cea03275ac46b9170a2b8bad20b79e7 Mon Sep 17 00:00:00 2001 From: folecr Date: Mon, 24 Sep 2012 16:16:50 -0700 Subject: [PATCH 126/181] Spidermonkey headers are not used for generation --- tools/tojs/cocos2dx.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index 32cea11f19..415ebcb4fe 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -17,10 +17,9 @@ cocos_headers = -I%(cocosdir)s/cocos2dx/include -I%(cocosdir)s/cocos2dx/platform cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common -spidermonkey_headers = -I%(mozilladir)s/spidermonkey/dist/include # extra arguments for clang -extra_arguments = %(android_headers)s %(clang_headers)s %(spidermonkey_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s # what headers to parse headers = %(cocosdir)s/cocos2dx/include/cocos2d.h From d01b6093d8663d098db5692115c2eedd371e592d Mon Sep 17 00:00:00 2001 From: folecr Date: Mon, 24 Sep 2012 21:14:41 -0700 Subject: [PATCH 127/181] gendbings.sh generates userconf.ini * ... and reads userconf.ini from current working directory * ... also specify that this script is run by /bin/bash --- tools/tojs/genbindings.sh | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/tools/tojs/genbindings.sh b/tools/tojs/genbindings.sh index 945f61d1d4..48885fcd7f 100755 --- a/tools/tojs/genbindings.sh +++ b/tools/tojs/genbindings.sh @@ -1,10 +1,12 @@ +#!/bin/bash + # exit this script if any commmand fails set -e # read user.cfg if it exists and is readable _CFG_FILE=$(dirname "$0")"/user.cfg" -if [ -e "$_CFG_FILE" ] +if [ -f "$_CFG_FILE" ] then [ -r "$_CFG_FILE" ] || die "Fatal Error: $_CFG_FILE exists but is unreadable" . "$_CFG_FILE" @@ -12,6 +14,11 @@ fi # paths +if [ -z "${NDK_ROOT+aaa}" ]; then +# ... if NDK_ROOT is not set, use "$HOME/bin/android-ndk" + NDK_ROOT="$HOME/bin/android-ndk" +fi + if [ -z "${CLANG_ROOT+aaa}" ]; then # ... if CLANG_ROOT is not set, use "$HOME/bin/clang+llvm-3.1" CLANG_ROOT="$HOME/bin/clang+llvm-3.1" @@ -40,12 +47,34 @@ if [ -z "${TOJS_ROOT+aaa}" ]; then fi echo "Paths" +echo " NDK_ROOT: $NDK_ROOT" echo " CLANG_ROOT: $CLANG_ROOT" echo " PYTHON_BIN: $PYTHON_BIN" echo " COCOS2DX_ROOT: $COCOS2DX_ROOT" echo " CXX_GENERATOR_ROOT: $CXX_GENERATOR_ROOT" echo " TO_JS_ROOT: $TO_JS_ROOT" +# write userconf.ini + +_CONF_INI_FILE="$PWD/userconf.ini" +if [ -f "$_CONF_INI_FILE" ] +then + rm "$_CONF_INI_FILE" +fi + +_CONTENTS="" +_CONTENTS+="[DEFAULT]"'\n' +_CONTENTS+="androidndkdir=$NDK_ROOT"'\n' +_CONTENTS+="clangllvmdir=$CLANG_ROOT"'\n' +_CONTENTS+="cocosdir=$COCOS2DX_ROOT"'\n' +_CONTENTS+="cxxgeneratordir=$CXX_GENERATOR_ROOT"'\n' +echo +echo "generating userconf.ini..." +echo --- +echo -e "$_CONTENTS" +echo -e "$_CONTENTS" > "$_CONF_INI_FILE" +echo --- + # Generate bindings for cocos2dx echo "Generating bindings for cocos2dx..." set -x From b5cfc3034befe1fcff747b985eb793ddba0f8987 Mon Sep 17 00:00:00 2001 From: folecr Date: Mon, 24 Sep 2012 16:16:14 -0700 Subject: [PATCH 128/181] Jenkins script to generate JS bindings --- .../mac/android/generate-js-cxx-bindings.sh | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 tools/jenkins_scripts/mac/android/generate-js-cxx-bindings.sh diff --git a/tools/jenkins_scripts/mac/android/generate-js-cxx-bindings.sh b/tools/jenkins_scripts/mac/android/generate-js-cxx-bindings.sh new file mode 100755 index 0000000000..f1ad4aec6a --- /dev/null +++ b/tools/jenkins_scripts/mac/android/generate-js-cxx-bindings.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Generate JS bindings for Cocos2D-X +# ... using Android NDK system headers + +# Environment variables required +# * $PYTHON_BIN +# * $CLANG_ROOT +# * $NDK_ROOT +# * $COCOS2DX_ROOT + +compileresult=0 + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +COCOS2DX_ROOT="$DIR"/../../../../ /bin/bash ../../../tojs/genbindings.sh + +compileresult=$[$compileresult+$?] + +# return the compileresult. +if [ $compileresult != 0 ]; then + exit 1 +else + exit 0 +fi From 364d7a487a7d1f0602aaa4573b7b55b79b8403c2 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 25 Sep 2012 14:42:45 +0800 Subject: [PATCH 129/181] Update cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java Comment some debug codes, because it will cause auto-building fail. --- .../java/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java index c89439b0af..668675965a 100644 --- a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java @@ -108,9 +108,11 @@ public class Cocos2dxAccelerometer implements SensorEventListener { } Cocos2dxAccelerometer.onSensorChanged(x, y, z, pSensorEvent.timestamp); + /* if(BuildConfig.DEBUG) { Log.d(TAG, "x = " + pSensorEvent.values[0] + " y = " + pSensorEvent.values[1] + " z = " + pSensorEvent.values[2]); } + */ } @Override From e24ad0380be56a62857559dc3a33e1291ad28193 Mon Sep 17 00:00:00 2001 From: jzgenius Date: Tue, 25 Sep 2012 14:54:13 +0800 Subject: [PATCH 130/181] [fix] CCNotificationObserver performSelector & CCNotificationObserver function. Let's m_object is right perform to target. --- cocos2dx/support/CCNotificationCenter.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cocos2dx/support/CCNotificationCenter.cpp b/cocos2dx/support/CCNotificationCenter.cpp index f08ba42fc4..4d678f4a18 100644 --- a/cocos2dx/support/CCNotificationCenter.cpp +++ b/cocos2dx/support/CCNotificationCenter.cpp @@ -177,6 +177,9 @@ CCNotificationObserver::CCNotificationObserver(CCObject *target, CCNotificationObserver::~CCNotificationObserver() { + CC_SAFE_RELEASE_NULL(m_object); + CC_SAFE_RELEASE_NULL(m_target); + if (m_name) delete m_name; } @@ -185,7 +188,11 @@ void CCNotificationObserver::performSelector(CCObject *obj) { if (m_target) { - (m_target->*m_selector)(obj); + if (obj) { + (m_target->*m_selector)(obj); + } else { + (m_target->*m_selector)(m_object); + } } } From da97921099c013b0c2558e4cfadfc9b98d748cc4 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 25 Sep 2012 16:21:28 +0800 Subject: [PATCH 131/181] fix compile errors of TestJavaScript --- .../TestJavascript.xcodeproj/project.pbxproj | 459 +++++++++++++++--- 1 file changed, 402 insertions(+), 57 deletions(-) diff --git a/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj b/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj index c60493883c..d1b4dfa46b 100644 --- a/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj +++ b/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj @@ -7,6 +7,58 @@ objects = { /* Begin PBXBuildFile section */ + 15384E5716119CC30021DC07 /* CCPhysicsSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E3E16119CC30021DC07 /* CCPhysicsSprite.cpp */; }; + 15384E5816119CC30021DC07 /* cocos2d_specifics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E4016119CC30021DC07 /* cocos2d_specifics.cpp */; }; + 15384E5916119CC30021DC07 /* cocosjs_manual_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E4216119CC30021DC07 /* cocosjs_manual_conversions.cpp */; }; + 15384E5A16119CC30021DC07 /* cocos2dx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E4516119CC30021DC07 /* cocos2dx.cpp */; }; + 15384E5D16119CC30021DC07 /* js_bindings_ccbreader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E4916119CC30021DC07 /* js_bindings_ccbreader.cpp */; }; + 15384E5E16119CC30021DC07 /* js_bindings_chipmunk_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E4B16119CC30021DC07 /* js_bindings_chipmunk_functions.cpp */; }; + 15384E5F16119CC30021DC07 /* js_bindings_chipmunk_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E4D16119CC30021DC07 /* js_bindings_chipmunk_manual.cpp */; }; + 15384E6016119CC30021DC07 /* js_manual_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E5016119CC30021DC07 /* js_manual_conversions.cpp */; }; + 15384E6116119CC30021DC07 /* ScriptingCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E5216119CC30021DC07 /* ScriptingCore.cpp */; }; + 15384ED716119D5E0021DC07 /* CCBAnimationManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E6516119D5E0021DC07 /* CCBAnimationManager.cpp */; }; + 15384ED816119D5E0021DC07 /* CCBFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E6716119D5E0021DC07 /* CCBFileLoader.cpp */; }; + 15384ED916119D5E0021DC07 /* CCBKeyframe.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E6916119D5E0021DC07 /* CCBKeyframe.cpp */; }; + 15384EDA16119D5E0021DC07 /* CCBReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E6C16119D5E0021DC07 /* CCBReader.cpp */; }; + 15384EDB16119D5E0021DC07 /* CCBSequence.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E6F16119D5E0021DC07 /* CCBSequence.cpp */; }; + 15384EDC16119D5E0021DC07 /* CCBSequenceProperty.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E7116119D5E0021DC07 /* CCBSequenceProperty.cpp */; }; + 15384EDD16119D5E0021DC07 /* CCBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E7316119D5E0021DC07 /* CCBValue.cpp */; }; + 15384EDE16119D5E0021DC07 /* CCControlButtonLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E7516119D5E0021DC07 /* CCControlButtonLoader.cpp */; }; + 15384EDF16119D5E0021DC07 /* CCControlLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E7716119D5E0021DC07 /* CCControlLoader.cpp */; }; + 15384EE016119D5E0021DC07 /* CCData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E7916119D5E0021DC07 /* CCData.cpp */; }; + 15384EE116119D5E0021DC07 /* CCLabelBMFontLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E7B16119D5E0021DC07 /* CCLabelBMFontLoader.cpp */; }; + 15384EE216119D5E0021DC07 /* CCLabelTTFLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E7D16119D5E0021DC07 /* CCLabelTTFLoader.cpp */; }; + 15384EE316119D5E0021DC07 /* CCLayerColorLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E7F16119D5E0021DC07 /* CCLayerColorLoader.cpp */; }; + 15384EE416119D5E0021DC07 /* CCLayerGradientLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E8116119D5E0021DC07 /* CCLayerGradientLoader.cpp */; }; + 15384EE516119D5E0021DC07 /* CCLayerLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E8316119D5E0021DC07 /* CCLayerLoader.cpp */; }; + 15384EE616119D5E0021DC07 /* CCMenuItemImageLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E8516119D5E0021DC07 /* CCMenuItemImageLoader.cpp */; }; + 15384EE716119D5E0021DC07 /* CCMenuItemLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E8716119D5E0021DC07 /* CCMenuItemLoader.cpp */; }; + 15384EE816119D5E0021DC07 /* CCNode+CCBRelativePositioning.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E8A16119D5E0021DC07 /* CCNode+CCBRelativePositioning.cpp */; }; + 15384EE916119D5E0021DC07 /* CCNodeLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E8C16119D5E0021DC07 /* CCNodeLoader.cpp */; }; + 15384EEA16119D5E0021DC07 /* CCNodeLoaderLibrary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E8E16119D5E0021DC07 /* CCNodeLoaderLibrary.cpp */; }; + 15384EEB16119D5E0021DC07 /* CCParticleSystemQuadLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E9116119D5E0021DC07 /* CCParticleSystemQuadLoader.cpp */; }; + 15384EEC16119D5E0021DC07 /* CCScale9SpriteLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E9316119D5E0021DC07 /* CCScale9SpriteLoader.cpp */; }; + 15384EED16119D5E0021DC07 /* CCScrollViewLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E9516119D5E0021DC07 /* CCScrollViewLoader.cpp */; }; + 15384EEE16119D5E0021DC07 /* CCSpriteLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E9716119D5E0021DC07 /* CCSpriteLoader.cpp */; }; + 15384EEF16119D5E0021DC07 /* CCControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E9D16119D5E0021DC07 /* CCControl.cpp */; }; + 15384EF016119D5E0021DC07 /* CCControlButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E9F16119D5E0021DC07 /* CCControlButton.cpp */; }; + 15384EF116119D5E0021DC07 /* CCControlColourPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EA116119D5E0021DC07 /* CCControlColourPicker.cpp */; }; + 15384EF216119D5E0021DC07 /* CCControlHuePicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EA416119D5E0021DC07 /* CCControlHuePicker.cpp */; }; + 15384EF316119D5E0021DC07 /* CCControlSaturationBrightnessPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EA616119D5E0021DC07 /* CCControlSaturationBrightnessPicker.cpp */; }; + 15384EF416119D5E0021DC07 /* CCControlSlider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EA816119D5E0021DC07 /* CCControlSlider.cpp */; }; + 15384EF516119D5E0021DC07 /* CCControlSwitch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EAA16119D5E0021DC07 /* CCControlSwitch.cpp */; }; + 15384EF616119D5E0021DC07 /* CCControlUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EAC16119D5E0021DC07 /* CCControlUtils.cpp */; }; + 15384EF716119D5E0021DC07 /* CCInvocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EAE16119D5E0021DC07 /* CCInvocation.cpp */; }; + 15384EF816119D5E0021DC07 /* CCMenuPassive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EB016119D5E0021DC07 /* CCMenuPassive.cpp */; }; + 15384EF916119D5E0021DC07 /* CCScale9Sprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EB216119D5E0021DC07 /* CCScale9Sprite.cpp */; }; + 15384EFA16119D5E0021DC07 /* CCSpacer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EB416119D5E0021DC07 /* CCSpacer.cpp */; }; + 15384EFB16119D5E0021DC07 /* CCEditBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EB716119D5E0021DC07 /* CCEditBox.cpp */; }; + 15384EFD16119D5E0021DC07 /* CCEditBoxImplIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 15384EBD16119D5E0021DC07 /* CCEditBoxImplIOS.mm */; }; + 15384EFE16119D5E0021DC07 /* EditBoxImplIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 15384EBF16119D5E0021DC07 /* EditBoxImplIOS.mm */; }; + 15384EFF16119D5E0021DC07 /* CCScrollView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EC116119D5E0021DC07 /* CCScrollView.cpp */; }; + 15384F0016119D5E0021DC07 /* CCSorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EC316119D5E0021DC07 /* CCSorting.cpp */; }; + 15384F0116119D5E0021DC07 /* CCTableView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EC516119D5E0021DC07 /* CCTableView.cpp */; }; + 15384F0216119D5E0021DC07 /* CCTableViewCell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EC716119D5E0021DC07 /* CCTableViewCell.cpp */; }; 15426FC315B5742200712A7F /* libcocos2dx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15426AF115B5733200712A7F /* libcocos2dx.a */; }; 15426FE615B5743C00712A7F /* CDAudioManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 15426FD015B5743C00712A7F /* CDAudioManager.m */; }; 15426FE715B5743C00712A7F /* CDOpenALSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = 15426FD315B5743C00712A7F /* CDOpenALSupport.m */; }; @@ -28,13 +80,6 @@ 15628F7815F0F5E5000CF24B /* tank1.png in Resources */ = {isa = PBXBuildFile; fileRef = 15628F6915F0F5E5000CF24B /* tank1.png */; }; 15628F7915F0F5E5000CF24B /* TileMaps in Resources */ = {isa = PBXBuildFile; fileRef = 15628F6A15F0F5E5000CF24B /* TileMaps */; }; 15628FA915F1057E000CF24B /* animations in Resources */ = {isa = PBXBuildFile; fileRef = 15628FA815F1057E000CF24B /* animations */; }; - 2628296215EC6C1B002C4240 /* ScriptingCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628295315EC6C1B002C4240 /* ScriptingCore.cpp */; }; - 2628296315EC6C1B002C4240 /* js_manual_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628295515EC6C1B002C4240 /* js_manual_conversions.cpp */; }; - 2628296415EC6C1B002C4240 /* js_bindings_chipmunk_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628295815EC6C1B002C4240 /* js_bindings_chipmunk_manual.cpp */; }; - 2628296515EC6C1B002C4240 /* js_bindings_chipmunk_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628295A15EC6C1B002C4240 /* js_bindings_chipmunk_functions.cpp */; }; - 2628296615EC6C1B002C4240 /* cocos2dx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628295C15EC6C1B002C4240 /* cocos2dx.cpp */; }; - 2628296715EC6C1B002C4240 /* cocos2d_specifics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628295E15EC6C1B002C4240 /* cocos2d_specifics.cpp */; }; - 2628296815EC6C1B002C4240 /* CCPhysicsSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628296015EC6C1B002C4240 /* CCPhysicsSprite.cpp */; }; 262829CC15EC7196002C4240 /* .gitignore in Resources */ = {isa = PBXBuildFile; fileRef = 2628297D15EC7196002C4240 /* .gitignore */; }; 262829CD15EC7196002C4240 /* Android.mk in Resources */ = {isa = PBXBuildFile; fileRef = 2628297E15EC7196002C4240 /* Android.mk */; }; 262829CE15EC7196002C4240 /* chipmunk-docs.html in Resources */ = {isa = PBXBuildFile; fileRef = 2628297F15EC7196002C4240 /* chipmunk-docs.html */; }; @@ -117,6 +162,121 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 15384E3E16119CC30021DC07 /* CCPhysicsSprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsSprite.cpp; sourceTree = ""; }; + 15384E3F16119CC30021DC07 /* CCPhysicsSprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsSprite.h; sourceTree = ""; }; + 15384E4016119CC30021DC07 /* cocos2d_specifics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocos2d_specifics.cpp; sourceTree = ""; }; + 15384E4116119CC30021DC07 /* cocos2d_specifics.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cocos2d_specifics.hpp; sourceTree = ""; }; + 15384E4216119CC30021DC07 /* cocosjs_manual_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocosjs_manual_conversions.cpp; sourceTree = ""; }; + 15384E4316119CC30021DC07 /* cocosjs_manual_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cocosjs_manual_conversions.h; sourceTree = ""; }; + 15384E4516119CC30021DC07 /* cocos2dx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocos2dx.cpp; sourceTree = ""; }; + 15384E4616119CC30021DC07 /* cocos2dx.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cocos2dx.hpp; sourceTree = ""; }; + 15384E4916119CC30021DC07 /* js_bindings_ccbreader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_ccbreader.cpp; sourceTree = ""; }; + 15384E4A16119CC30021DC07 /* js_bindings_ccbreader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_ccbreader.h; sourceTree = ""; }; + 15384E4B16119CC30021DC07 /* js_bindings_chipmunk_functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_functions.cpp; sourceTree = ""; }; + 15384E4C16119CC30021DC07 /* js_bindings_chipmunk_functions.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = js_bindings_chipmunk_functions.hpp; sourceTree = ""; }; + 15384E4D16119CC30021DC07 /* js_bindings_chipmunk_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_manual.cpp; sourceTree = ""; }; + 15384E4E16119CC30021DC07 /* js_bindings_chipmunk_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = js_bindings_chipmunk_manual.hpp; sourceTree = ""; }; + 15384E4F16119CC30021DC07 /* js_bindings_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_config.h; sourceTree = ""; }; + 15384E5016119CC30021DC07 /* js_manual_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_manual_conversions.cpp; sourceTree = ""; }; + 15384E5116119CC30021DC07 /* js_manual_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_manual_conversions.h; sourceTree = ""; }; + 15384E5216119CC30021DC07 /* ScriptingCore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptingCore.cpp; sourceTree = ""; }; + 15384E5316119CC30021DC07 /* ScriptingCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptingCore.h; sourceTree = ""; }; + 15384E5416119CC30021DC07 /* spidermonkey_specifics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spidermonkey_specifics.h; sourceTree = ""; }; + 15384E5516119CC30021DC07 /* uthash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uthash.h; sourceTree = ""; }; + 15384E6516119D5E0021DC07 /* CCBAnimationManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBAnimationManager.cpp; sourceTree = ""; }; + 15384E6616119D5E0021DC07 /* CCBAnimationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBAnimationManager.h; sourceTree = ""; }; + 15384E6716119D5E0021DC07 /* CCBFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBFileLoader.cpp; sourceTree = ""; }; + 15384E6816119D5E0021DC07 /* CCBFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBFileLoader.h; sourceTree = ""; }; + 15384E6916119D5E0021DC07 /* CCBKeyframe.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBKeyframe.cpp; sourceTree = ""; }; + 15384E6A16119D5E0021DC07 /* CCBKeyframe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBKeyframe.h; sourceTree = ""; }; + 15384E6B16119D5E0021DC07 /* CCBMemberVariableAssigner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBMemberVariableAssigner.h; sourceTree = ""; }; + 15384E6C16119D5E0021DC07 /* CCBReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBReader.cpp; sourceTree = ""; }; + 15384E6D16119D5E0021DC07 /* CCBReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBReader.h; sourceTree = ""; }; + 15384E6E16119D5E0021DC07 /* CCBSelectorResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBSelectorResolver.h; sourceTree = ""; }; + 15384E6F16119D5E0021DC07 /* CCBSequence.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBSequence.cpp; sourceTree = ""; }; + 15384E7016119D5E0021DC07 /* CCBSequence.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBSequence.h; sourceTree = ""; }; + 15384E7116119D5E0021DC07 /* CCBSequenceProperty.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBSequenceProperty.cpp; sourceTree = ""; }; + 15384E7216119D5E0021DC07 /* CCBSequenceProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBSequenceProperty.h; sourceTree = ""; }; + 15384E7316119D5E0021DC07 /* CCBValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBValue.cpp; sourceTree = ""; }; + 15384E7416119D5E0021DC07 /* CCBValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBValue.h; sourceTree = ""; }; + 15384E7516119D5E0021DC07 /* CCControlButtonLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlButtonLoader.cpp; sourceTree = ""; }; + 15384E7616119D5E0021DC07 /* CCControlButtonLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlButtonLoader.h; sourceTree = ""; }; + 15384E7716119D5E0021DC07 /* CCControlLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlLoader.cpp; sourceTree = ""; }; + 15384E7816119D5E0021DC07 /* CCControlLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlLoader.h; sourceTree = ""; }; + 15384E7916119D5E0021DC07 /* CCData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCData.cpp; sourceTree = ""; }; + 15384E7A16119D5E0021DC07 /* CCData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCData.h; sourceTree = ""; }; + 15384E7B16119D5E0021DC07 /* CCLabelBMFontLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLabelBMFontLoader.cpp; sourceTree = ""; }; + 15384E7C16119D5E0021DC07 /* CCLabelBMFontLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLabelBMFontLoader.h; sourceTree = ""; }; + 15384E7D16119D5E0021DC07 /* CCLabelTTFLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLabelTTFLoader.cpp; sourceTree = ""; }; + 15384E7E16119D5E0021DC07 /* CCLabelTTFLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLabelTTFLoader.h; sourceTree = ""; }; + 15384E7F16119D5E0021DC07 /* CCLayerColorLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLayerColorLoader.cpp; sourceTree = ""; }; + 15384E8016119D5E0021DC07 /* CCLayerColorLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLayerColorLoader.h; sourceTree = ""; }; + 15384E8116119D5E0021DC07 /* CCLayerGradientLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLayerGradientLoader.cpp; sourceTree = ""; }; + 15384E8216119D5E0021DC07 /* CCLayerGradientLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLayerGradientLoader.h; sourceTree = ""; }; + 15384E8316119D5E0021DC07 /* CCLayerLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLayerLoader.cpp; sourceTree = ""; }; + 15384E8416119D5E0021DC07 /* CCLayerLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLayerLoader.h; sourceTree = ""; }; + 15384E8516119D5E0021DC07 /* CCMenuItemImageLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMenuItemImageLoader.cpp; sourceTree = ""; }; + 15384E8616119D5E0021DC07 /* CCMenuItemImageLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMenuItemImageLoader.h; sourceTree = ""; }; + 15384E8716119D5E0021DC07 /* CCMenuItemLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMenuItemLoader.cpp; sourceTree = ""; }; + 15384E8816119D5E0021DC07 /* CCMenuItemLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMenuItemLoader.h; sourceTree = ""; }; + 15384E8916119D5E0021DC07 /* CCMenuLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMenuLoader.h; sourceTree = ""; }; + 15384E8A16119D5E0021DC07 /* CCNode+CCBRelativePositioning.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "CCNode+CCBRelativePositioning.cpp"; sourceTree = ""; }; + 15384E8B16119D5E0021DC07 /* CCNode+CCBRelativePositioning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CCNode+CCBRelativePositioning.h"; sourceTree = ""; }; + 15384E8C16119D5E0021DC07 /* CCNodeLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCNodeLoader.cpp; sourceTree = ""; }; + 15384E8D16119D5E0021DC07 /* CCNodeLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeLoader.h; sourceTree = ""; }; + 15384E8E16119D5E0021DC07 /* CCNodeLoaderLibrary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCNodeLoaderLibrary.cpp; sourceTree = ""; }; + 15384E8F16119D5E0021DC07 /* CCNodeLoaderLibrary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeLoaderLibrary.h; sourceTree = ""; }; + 15384E9016119D5E0021DC07 /* CCNodeLoaderListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeLoaderListener.h; sourceTree = ""; }; + 15384E9116119D5E0021DC07 /* CCParticleSystemQuadLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCParticleSystemQuadLoader.cpp; sourceTree = ""; }; + 15384E9216119D5E0021DC07 /* CCParticleSystemQuadLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCParticleSystemQuadLoader.h; sourceTree = ""; }; + 15384E9316119D5E0021DC07 /* CCScale9SpriteLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScale9SpriteLoader.cpp; sourceTree = ""; }; + 15384E9416119D5E0021DC07 /* CCScale9SpriteLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScale9SpriteLoader.h; sourceTree = ""; }; + 15384E9516119D5E0021DC07 /* CCScrollViewLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScrollViewLoader.cpp; sourceTree = ""; }; + 15384E9616119D5E0021DC07 /* CCScrollViewLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScrollViewLoader.h; sourceTree = ""; }; + 15384E9716119D5E0021DC07 /* CCSpriteLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSpriteLoader.cpp; sourceTree = ""; }; + 15384E9816119D5E0021DC07 /* CCSpriteLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSpriteLoader.h; sourceTree = ""; }; + 15384E9916119D5E0021DC07 /* cocos-ext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "cocos-ext.h"; sourceTree = ""; }; + 15384E9A16119D5E0021DC07 /* ExtensionMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtensionMacros.h; sourceTree = ""; }; + 15384E9D16119D5E0021DC07 /* CCControl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControl.cpp; sourceTree = ""; }; + 15384E9E16119D5E0021DC07 /* CCControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControl.h; sourceTree = ""; }; + 15384E9F16119D5E0021DC07 /* CCControlButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlButton.cpp; sourceTree = ""; }; + 15384EA016119D5E0021DC07 /* CCControlButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlButton.h; sourceTree = ""; }; + 15384EA116119D5E0021DC07 /* CCControlColourPicker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlColourPicker.cpp; sourceTree = ""; }; + 15384EA216119D5E0021DC07 /* CCControlColourPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlColourPicker.h; sourceTree = ""; }; + 15384EA316119D5E0021DC07 /* CCControlExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlExtensions.h; sourceTree = ""; }; + 15384EA416119D5E0021DC07 /* CCControlHuePicker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlHuePicker.cpp; sourceTree = ""; }; + 15384EA516119D5E0021DC07 /* CCControlHuePicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlHuePicker.h; sourceTree = ""; }; + 15384EA616119D5E0021DC07 /* CCControlSaturationBrightnessPicker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSaturationBrightnessPicker.cpp; sourceTree = ""; }; + 15384EA716119D5E0021DC07 /* CCControlSaturationBrightnessPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlSaturationBrightnessPicker.h; sourceTree = ""; }; + 15384EA816119D5E0021DC07 /* CCControlSlider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSlider.cpp; sourceTree = ""; }; + 15384EA916119D5E0021DC07 /* CCControlSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlSlider.h; sourceTree = ""; }; + 15384EAA16119D5E0021DC07 /* CCControlSwitch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSwitch.cpp; sourceTree = ""; }; + 15384EAB16119D5E0021DC07 /* CCControlSwitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlSwitch.h; sourceTree = ""; }; + 15384EAC16119D5E0021DC07 /* CCControlUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlUtils.cpp; sourceTree = ""; }; + 15384EAD16119D5E0021DC07 /* CCControlUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlUtils.h; sourceTree = ""; }; + 15384EAE16119D5E0021DC07 /* CCInvocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCInvocation.cpp; sourceTree = ""; }; + 15384EAF16119D5E0021DC07 /* CCInvocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCInvocation.h; sourceTree = ""; }; + 15384EB016119D5E0021DC07 /* CCMenuPassive.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMenuPassive.cpp; sourceTree = ""; }; + 15384EB116119D5E0021DC07 /* CCMenuPassive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMenuPassive.h; sourceTree = ""; }; + 15384EB216119D5E0021DC07 /* CCScale9Sprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScale9Sprite.cpp; sourceTree = ""; }; + 15384EB316119D5E0021DC07 /* CCScale9Sprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScale9Sprite.h; sourceTree = ""; }; + 15384EB416119D5E0021DC07 /* CCSpacer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSpacer.cpp; sourceTree = ""; }; + 15384EB516119D5E0021DC07 /* CCSpacer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSpacer.h; sourceTree = ""; }; + 15384EB716119D5E0021DC07 /* CCEditBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCEditBox.cpp; sourceTree = ""; }; + 15384EB816119D5E0021DC07 /* CCEditBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEditBox.h; sourceTree = ""; }; + 15384EB916119D5E0021DC07 /* CCEditBoxImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImpl.h; sourceTree = ""; }; + 15384EBC16119D5E0021DC07 /* CCEditBoxImplIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImplIOS.h; sourceTree = ""; }; + 15384EBD16119D5E0021DC07 /* CCEditBoxImplIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CCEditBoxImplIOS.mm; sourceTree = ""; }; + 15384EBE16119D5E0021DC07 /* EditBoxImplIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditBoxImplIOS.h; sourceTree = ""; }; + 15384EBF16119D5E0021DC07 /* EditBoxImplIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EditBoxImplIOS.mm; sourceTree = ""; }; + 15384EC116119D5E0021DC07 /* CCScrollView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScrollView.cpp; sourceTree = ""; }; + 15384EC216119D5E0021DC07 /* CCScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScrollView.h; sourceTree = ""; }; + 15384EC316119D5E0021DC07 /* CCSorting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSorting.cpp; sourceTree = ""; }; + 15384EC416119D5E0021DC07 /* CCSorting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSorting.h; sourceTree = ""; }; + 15384EC516119D5E0021DC07 /* CCTableView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTableView.cpp; sourceTree = ""; }; + 15384EC616119D5E0021DC07 /* CCTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTableView.h; sourceTree = ""; }; + 15384EC716119D5E0021DC07 /* CCTableViewCell.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTableViewCell.cpp; sourceTree = ""; }; + 15384EC816119D5E0021DC07 /* CCTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTableViewCell.h; sourceTree = ""; }; 15426AE915B5733200712A7F /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = ""; }; 15426FCC15B5743C00712A7F /* Export.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Export.h; sourceTree = ""; }; 15426FCD15B5743C00712A7F /* SimpleAudioEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleAudioEngine.h; sourceTree = ""; }; @@ -145,23 +305,6 @@ 15628F6915F0F5E5000CF24B /* tank1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = tank1.png; path = ../Resources/tank1.png; sourceTree = ""; }; 15628F6A15F0F5E5000CF24B /* TileMaps */ = {isa = PBXFileReference; lastKnownFileType = folder; name = TileMaps; path = ../Resources/TileMaps; sourceTree = ""; }; 15628FA815F1057E000CF24B /* animations */ = {isa = PBXFileReference; lastKnownFileType = folder; name = animations; path = ../Resources/animations; sourceTree = ""; }; - 2628295015EC6C1B002C4240 /* uthash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uthash.h; sourceTree = ""; }; - 2628295115EC6C1B002C4240 /* spidermonkey_specifics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spidermonkey_specifics.h; sourceTree = ""; }; - 2628295215EC6C1B002C4240 /* ScriptingCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptingCore.h; sourceTree = ""; }; - 2628295315EC6C1B002C4240 /* ScriptingCore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptingCore.cpp; sourceTree = ""; }; - 2628295415EC6C1B002C4240 /* js_manual_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_manual_conversions.h; sourceTree = ""; }; - 2628295515EC6C1B002C4240 /* js_manual_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_manual_conversions.cpp; sourceTree = ""; }; - 2628295615EC6C1B002C4240 /* js_bindings_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_config.h; sourceTree = ""; }; - 2628295715EC6C1B002C4240 /* js_bindings_chipmunk_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = js_bindings_chipmunk_manual.hpp; sourceTree = ""; }; - 2628295815EC6C1B002C4240 /* js_bindings_chipmunk_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_manual.cpp; sourceTree = ""; }; - 2628295915EC6C1B002C4240 /* js_bindings_chipmunk_functions.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = js_bindings_chipmunk_functions.hpp; sourceTree = ""; }; - 2628295A15EC6C1B002C4240 /* js_bindings_chipmunk_functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_functions.cpp; sourceTree = ""; }; - 2628295B15EC6C1B002C4240 /* cocos2dx.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cocos2dx.hpp; sourceTree = ""; }; - 2628295C15EC6C1B002C4240 /* cocos2dx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocos2dx.cpp; sourceTree = ""; }; - 2628295D15EC6C1B002C4240 /* cocos2d_specifics.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cocos2d_specifics.hpp; sourceTree = ""; }; - 2628295E15EC6C1B002C4240 /* cocos2d_specifics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocos2d_specifics.cpp; sourceTree = ""; }; - 2628295F15EC6C1B002C4240 /* CCPhysicsSprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsSprite.h; sourceTree = ""; }; - 2628296015EC6C1B002C4240 /* CCPhysicsSprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsSprite.cpp; sourceTree = ""; }; 2628297D15EC7196002C4240 /* .gitignore */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .gitignore; sourceTree = ""; }; 2628297E15EC7196002C4240 /* Android.mk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Android.mk; sourceTree = ""; }; 2628297F15EC7196002C4240 /* chipmunk-docs.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "chipmunk-docs.html"; sourceTree = ""; }; @@ -280,6 +423,185 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 15384E3C16119CC30021DC07 /* bindings */ = { + isa = PBXGroup; + children = ( + 15384E3E16119CC30021DC07 /* CCPhysicsSprite.cpp */, + 15384E3F16119CC30021DC07 /* CCPhysicsSprite.h */, + 15384E4016119CC30021DC07 /* cocos2d_specifics.cpp */, + 15384E4116119CC30021DC07 /* cocos2d_specifics.hpp */, + 15384E4216119CC30021DC07 /* cocosjs_manual_conversions.cpp */, + 15384E4316119CC30021DC07 /* cocosjs_manual_conversions.h */, + 15384E4416119CC30021DC07 /* generated */, + 15384E4916119CC30021DC07 /* js_bindings_ccbreader.cpp */, + 15384E4A16119CC30021DC07 /* js_bindings_ccbreader.h */, + 15384E4B16119CC30021DC07 /* js_bindings_chipmunk_functions.cpp */, + 15384E4C16119CC30021DC07 /* js_bindings_chipmunk_functions.hpp */, + 15384E4D16119CC30021DC07 /* js_bindings_chipmunk_manual.cpp */, + 15384E4E16119CC30021DC07 /* js_bindings_chipmunk_manual.hpp */, + 15384E4F16119CC30021DC07 /* js_bindings_config.h */, + 15384E5016119CC30021DC07 /* js_manual_conversions.cpp */, + 15384E5116119CC30021DC07 /* js_manual_conversions.h */, + 15384E5216119CC30021DC07 /* ScriptingCore.cpp */, + 15384E5316119CC30021DC07 /* ScriptingCore.h */, + 15384E5416119CC30021DC07 /* spidermonkey_specifics.h */, + 15384E5516119CC30021DC07 /* uthash.h */, + ); + name = bindings; + path = ../../../scripting/javascript/bindings; + sourceTree = ""; + }; + 15384E4416119CC30021DC07 /* generated */ = { + isa = PBXGroup; + children = ( + 15384E4516119CC30021DC07 /* cocos2dx.cpp */, + 15384E4616119CC30021DC07 /* cocos2dx.hpp */, + ); + path = generated; + sourceTree = ""; + }; + 15384E6216119D5E0021DC07 /* extensions */ = { + isa = PBXGroup; + children = ( + 15384E6416119D5E0021DC07 /* CCBReader */, + 15384E9916119D5E0021DC07 /* cocos-ext.h */, + 15384E9A16119D5E0021DC07 /* ExtensionMacros.h */, + 15384E9B16119D5E0021DC07 /* GUI */, + ); + name = extensions; + path = ../../../extensions; + sourceTree = ""; + }; + 15384E6416119D5E0021DC07 /* CCBReader */ = { + isa = PBXGroup; + children = ( + 15384E6516119D5E0021DC07 /* CCBAnimationManager.cpp */, + 15384E6616119D5E0021DC07 /* CCBAnimationManager.h */, + 15384E6716119D5E0021DC07 /* CCBFileLoader.cpp */, + 15384E6816119D5E0021DC07 /* CCBFileLoader.h */, + 15384E6916119D5E0021DC07 /* CCBKeyframe.cpp */, + 15384E6A16119D5E0021DC07 /* CCBKeyframe.h */, + 15384E6B16119D5E0021DC07 /* CCBMemberVariableAssigner.h */, + 15384E6C16119D5E0021DC07 /* CCBReader.cpp */, + 15384E6D16119D5E0021DC07 /* CCBReader.h */, + 15384E6E16119D5E0021DC07 /* CCBSelectorResolver.h */, + 15384E6F16119D5E0021DC07 /* CCBSequence.cpp */, + 15384E7016119D5E0021DC07 /* CCBSequence.h */, + 15384E7116119D5E0021DC07 /* CCBSequenceProperty.cpp */, + 15384E7216119D5E0021DC07 /* CCBSequenceProperty.h */, + 15384E7316119D5E0021DC07 /* CCBValue.cpp */, + 15384E7416119D5E0021DC07 /* CCBValue.h */, + 15384E7516119D5E0021DC07 /* CCControlButtonLoader.cpp */, + 15384E7616119D5E0021DC07 /* CCControlButtonLoader.h */, + 15384E7716119D5E0021DC07 /* CCControlLoader.cpp */, + 15384E7816119D5E0021DC07 /* CCControlLoader.h */, + 15384E7916119D5E0021DC07 /* CCData.cpp */, + 15384E7A16119D5E0021DC07 /* CCData.h */, + 15384E7B16119D5E0021DC07 /* CCLabelBMFontLoader.cpp */, + 15384E7C16119D5E0021DC07 /* CCLabelBMFontLoader.h */, + 15384E7D16119D5E0021DC07 /* CCLabelTTFLoader.cpp */, + 15384E7E16119D5E0021DC07 /* CCLabelTTFLoader.h */, + 15384E7F16119D5E0021DC07 /* CCLayerColorLoader.cpp */, + 15384E8016119D5E0021DC07 /* CCLayerColorLoader.h */, + 15384E8116119D5E0021DC07 /* CCLayerGradientLoader.cpp */, + 15384E8216119D5E0021DC07 /* CCLayerGradientLoader.h */, + 15384E8316119D5E0021DC07 /* CCLayerLoader.cpp */, + 15384E8416119D5E0021DC07 /* CCLayerLoader.h */, + 15384E8516119D5E0021DC07 /* CCMenuItemImageLoader.cpp */, + 15384E8616119D5E0021DC07 /* CCMenuItemImageLoader.h */, + 15384E8716119D5E0021DC07 /* CCMenuItemLoader.cpp */, + 15384E8816119D5E0021DC07 /* CCMenuItemLoader.h */, + 15384E8916119D5E0021DC07 /* CCMenuLoader.h */, + 15384E8A16119D5E0021DC07 /* CCNode+CCBRelativePositioning.cpp */, + 15384E8B16119D5E0021DC07 /* CCNode+CCBRelativePositioning.h */, + 15384E8C16119D5E0021DC07 /* CCNodeLoader.cpp */, + 15384E8D16119D5E0021DC07 /* CCNodeLoader.h */, + 15384E8E16119D5E0021DC07 /* CCNodeLoaderLibrary.cpp */, + 15384E8F16119D5E0021DC07 /* CCNodeLoaderLibrary.h */, + 15384E9016119D5E0021DC07 /* CCNodeLoaderListener.h */, + 15384E9116119D5E0021DC07 /* CCParticleSystemQuadLoader.cpp */, + 15384E9216119D5E0021DC07 /* CCParticleSystemQuadLoader.h */, + 15384E9316119D5E0021DC07 /* CCScale9SpriteLoader.cpp */, + 15384E9416119D5E0021DC07 /* CCScale9SpriteLoader.h */, + 15384E9516119D5E0021DC07 /* CCScrollViewLoader.cpp */, + 15384E9616119D5E0021DC07 /* CCScrollViewLoader.h */, + 15384E9716119D5E0021DC07 /* CCSpriteLoader.cpp */, + 15384E9816119D5E0021DC07 /* CCSpriteLoader.h */, + ); + path = CCBReader; + sourceTree = ""; + }; + 15384E9B16119D5E0021DC07 /* GUI */ = { + isa = PBXGroup; + children = ( + 15384E9C16119D5E0021DC07 /* CCControlExtension */, + 15384EB616119D5E0021DC07 /* CCEditBox */, + 15384EC016119D5E0021DC07 /* CCScrollView */, + ); + path = GUI; + sourceTree = ""; + }; + 15384E9C16119D5E0021DC07 /* CCControlExtension */ = { + isa = PBXGroup; + children = ( + 15384E9D16119D5E0021DC07 /* CCControl.cpp */, + 15384E9E16119D5E0021DC07 /* CCControl.h */, + 15384E9F16119D5E0021DC07 /* CCControlButton.cpp */, + 15384EA016119D5E0021DC07 /* CCControlButton.h */, + 15384EA116119D5E0021DC07 /* CCControlColourPicker.cpp */, + 15384EA216119D5E0021DC07 /* CCControlColourPicker.h */, + 15384EA316119D5E0021DC07 /* CCControlExtensions.h */, + 15384EA416119D5E0021DC07 /* CCControlHuePicker.cpp */, + 15384EA516119D5E0021DC07 /* CCControlHuePicker.h */, + 15384EA616119D5E0021DC07 /* CCControlSaturationBrightnessPicker.cpp */, + 15384EA716119D5E0021DC07 /* CCControlSaturationBrightnessPicker.h */, + 15384EA816119D5E0021DC07 /* CCControlSlider.cpp */, + 15384EA916119D5E0021DC07 /* CCControlSlider.h */, + 15384EAA16119D5E0021DC07 /* CCControlSwitch.cpp */, + 15384EAB16119D5E0021DC07 /* CCControlSwitch.h */, + 15384EAC16119D5E0021DC07 /* CCControlUtils.cpp */, + 15384EAD16119D5E0021DC07 /* CCControlUtils.h */, + 15384EAE16119D5E0021DC07 /* CCInvocation.cpp */, + 15384EAF16119D5E0021DC07 /* CCInvocation.h */, + 15384EB016119D5E0021DC07 /* CCMenuPassive.cpp */, + 15384EB116119D5E0021DC07 /* CCMenuPassive.h */, + 15384EB216119D5E0021DC07 /* CCScale9Sprite.cpp */, + 15384EB316119D5E0021DC07 /* CCScale9Sprite.h */, + 15384EB416119D5E0021DC07 /* CCSpacer.cpp */, + 15384EB516119D5E0021DC07 /* CCSpacer.h */, + ); + path = CCControlExtension; + sourceTree = ""; + }; + 15384EB616119D5E0021DC07 /* CCEditBox */ = { + isa = PBXGroup; + children = ( + 15384EB716119D5E0021DC07 /* CCEditBox.cpp */, + 15384EB816119D5E0021DC07 /* CCEditBox.h */, + 15384EB916119D5E0021DC07 /* CCEditBoxImpl.h */, + 15384EBC16119D5E0021DC07 /* CCEditBoxImplIOS.h */, + 15384EBD16119D5E0021DC07 /* CCEditBoxImplIOS.mm */, + 15384EBE16119D5E0021DC07 /* EditBoxImplIOS.h */, + 15384EBF16119D5E0021DC07 /* EditBoxImplIOS.mm */, + ); + path = CCEditBox; + sourceTree = ""; + }; + 15384EC016119D5E0021DC07 /* CCScrollView */ = { + isa = PBXGroup; + children = ( + 15384EC116119D5E0021DC07 /* CCScrollView.cpp */, + 15384EC216119D5E0021DC07 /* CCScrollView.h */, + 15384EC316119D5E0021DC07 /* CCSorting.cpp */, + 15384EC416119D5E0021DC07 /* CCSorting.h */, + 15384EC516119D5E0021DC07 /* CCTableView.cpp */, + 15384EC616119D5E0021DC07 /* CCTableView.h */, + 15384EC716119D5E0021DC07 /* CCTableViewCell.cpp */, + 15384EC816119D5E0021DC07 /* CCTableViewCell.h */, + ); + path = CCScrollView; + sourceTree = ""; + }; 15426AEA15B5733200712A7F /* Products */ = { isa = PBXGroup; children = ( @@ -495,10 +817,11 @@ A92275321517C094001B78AA = { isa = PBXGroup; children = ( + 15384E6216119D5E0021DC07 /* extensions */, + 15384E3C16119CC30021DC07 /* bindings */, 15426AE915B5733200712A7F /* cocos2dx.xcodeproj */, 15628F5B15F0F5C2000CF24B /* Resources */, 2628297C15EC7196002C4240 /* chipmunk */, - F2837A9C15B9639100A5707B /* bindings */, D4545214156E28EF00887EB5 /* Classes */, 15426FC415B5743C00712A7F /* CocosDenshion */, A92275401517C094001B78AA /* Frameworks */, @@ -556,31 +879,6 @@ path = ../Classes; sourceTree = ""; }; - F2837A9C15B9639100A5707B /* bindings */ = { - isa = PBXGroup; - children = ( - 2628295015EC6C1B002C4240 /* uthash.h */, - 2628295115EC6C1B002C4240 /* spidermonkey_specifics.h */, - 2628295215EC6C1B002C4240 /* ScriptingCore.h */, - 2628295315EC6C1B002C4240 /* ScriptingCore.cpp */, - 2628295415EC6C1B002C4240 /* js_manual_conversions.h */, - 2628295515EC6C1B002C4240 /* js_manual_conversions.cpp */, - 2628295615EC6C1B002C4240 /* js_bindings_config.h */, - 2628295715EC6C1B002C4240 /* js_bindings_chipmunk_manual.hpp */, - 2628295815EC6C1B002C4240 /* js_bindings_chipmunk_manual.cpp */, - 2628295915EC6C1B002C4240 /* js_bindings_chipmunk_functions.hpp */, - 2628295A15EC6C1B002C4240 /* js_bindings_chipmunk_functions.cpp */, - 2628295B15EC6C1B002C4240 /* cocos2dx.hpp */, - 2628295C15EC6C1B002C4240 /* cocos2dx.cpp */, - 2628295D15EC6C1B002C4240 /* cocos2d_specifics.hpp */, - 2628295E15EC6C1B002C4240 /* cocos2d_specifics.cpp */, - 2628295F15EC6C1B002C4240 /* CCPhysicsSprite.h */, - 2628296015EC6C1B002C4240 /* CCPhysicsSprite.cpp */, - ); - name = bindings; - path = ../../../scripting/javascript/bindings; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -700,13 +998,6 @@ 15426FE815B5743C00712A7F /* CocosDenshion.m in Sources */, 15426FE915B5743C00712A7F /* SimpleAudioEngine.mm in Sources */, 15426FEA15B5743C00712A7F /* SimpleAudioEngine_objc.m in Sources */, - 2628296215EC6C1B002C4240 /* ScriptingCore.cpp in Sources */, - 2628296315EC6C1B002C4240 /* js_manual_conversions.cpp in Sources */, - 2628296415EC6C1B002C4240 /* js_bindings_chipmunk_manual.cpp in Sources */, - 2628296515EC6C1B002C4240 /* js_bindings_chipmunk_functions.cpp in Sources */, - 2628296615EC6C1B002C4240 /* cocos2dx.cpp in Sources */, - 2628296715EC6C1B002C4240 /* cocos2d_specifics.cpp in Sources */, - 2628296815EC6C1B002C4240 /* CCPhysicsSprite.cpp in Sources */, 262829D415EC7196002C4240 /* Makefile in Sources */, 262829DB15EC7196002C4240 /* chipmunk.c in Sources */, 262829DD15EC7196002C4240 /* cpConstraint.c in Sources */, @@ -737,6 +1028,58 @@ 262829F615EC7196002C4240 /* cpSpatialIndex.c in Sources */, 262829F715EC7196002C4240 /* cpSweep1D.c in Sources */, 262829F815EC7196002C4240 /* cpVect.c in Sources */, + 15384E5716119CC30021DC07 /* CCPhysicsSprite.cpp in Sources */, + 15384E5816119CC30021DC07 /* cocos2d_specifics.cpp in Sources */, + 15384E5916119CC30021DC07 /* cocosjs_manual_conversions.cpp in Sources */, + 15384E5A16119CC30021DC07 /* cocos2dx.cpp in Sources */, + 15384E5D16119CC30021DC07 /* js_bindings_ccbreader.cpp in Sources */, + 15384E5E16119CC30021DC07 /* js_bindings_chipmunk_functions.cpp in Sources */, + 15384E5F16119CC30021DC07 /* js_bindings_chipmunk_manual.cpp in Sources */, + 15384E6016119CC30021DC07 /* js_manual_conversions.cpp in Sources */, + 15384E6116119CC30021DC07 /* ScriptingCore.cpp in Sources */, + 15384ED716119D5E0021DC07 /* CCBAnimationManager.cpp in Sources */, + 15384ED816119D5E0021DC07 /* CCBFileLoader.cpp in Sources */, + 15384ED916119D5E0021DC07 /* CCBKeyframe.cpp in Sources */, + 15384EDA16119D5E0021DC07 /* CCBReader.cpp in Sources */, + 15384EDB16119D5E0021DC07 /* CCBSequence.cpp in Sources */, + 15384EDC16119D5E0021DC07 /* CCBSequenceProperty.cpp in Sources */, + 15384EDD16119D5E0021DC07 /* CCBValue.cpp in Sources */, + 15384EDE16119D5E0021DC07 /* CCControlButtonLoader.cpp in Sources */, + 15384EDF16119D5E0021DC07 /* CCControlLoader.cpp in Sources */, + 15384EE016119D5E0021DC07 /* CCData.cpp in Sources */, + 15384EE116119D5E0021DC07 /* CCLabelBMFontLoader.cpp in Sources */, + 15384EE216119D5E0021DC07 /* CCLabelTTFLoader.cpp in Sources */, + 15384EE316119D5E0021DC07 /* CCLayerColorLoader.cpp in Sources */, + 15384EE416119D5E0021DC07 /* CCLayerGradientLoader.cpp in Sources */, + 15384EE516119D5E0021DC07 /* CCLayerLoader.cpp in Sources */, + 15384EE616119D5E0021DC07 /* CCMenuItemImageLoader.cpp in Sources */, + 15384EE716119D5E0021DC07 /* CCMenuItemLoader.cpp in Sources */, + 15384EE816119D5E0021DC07 /* CCNode+CCBRelativePositioning.cpp in Sources */, + 15384EE916119D5E0021DC07 /* CCNodeLoader.cpp in Sources */, + 15384EEA16119D5E0021DC07 /* CCNodeLoaderLibrary.cpp in Sources */, + 15384EEB16119D5E0021DC07 /* CCParticleSystemQuadLoader.cpp in Sources */, + 15384EEC16119D5E0021DC07 /* CCScale9SpriteLoader.cpp in Sources */, + 15384EED16119D5E0021DC07 /* CCScrollViewLoader.cpp in Sources */, + 15384EEE16119D5E0021DC07 /* CCSpriteLoader.cpp in Sources */, + 15384EEF16119D5E0021DC07 /* CCControl.cpp in Sources */, + 15384EF016119D5E0021DC07 /* CCControlButton.cpp in Sources */, + 15384EF116119D5E0021DC07 /* CCControlColourPicker.cpp in Sources */, + 15384EF216119D5E0021DC07 /* CCControlHuePicker.cpp in Sources */, + 15384EF316119D5E0021DC07 /* CCControlSaturationBrightnessPicker.cpp in Sources */, + 15384EF416119D5E0021DC07 /* CCControlSlider.cpp in Sources */, + 15384EF516119D5E0021DC07 /* CCControlSwitch.cpp in Sources */, + 15384EF616119D5E0021DC07 /* CCControlUtils.cpp in Sources */, + 15384EF716119D5E0021DC07 /* CCInvocation.cpp in Sources */, + 15384EF816119D5E0021DC07 /* CCMenuPassive.cpp in Sources */, + 15384EF916119D5E0021DC07 /* CCScale9Sprite.cpp in Sources */, + 15384EFA16119D5E0021DC07 /* CCSpacer.cpp in Sources */, + 15384EFB16119D5E0021DC07 /* CCEditBox.cpp in Sources */, + 15384EFD16119D5E0021DC07 /* CCEditBoxImplIOS.mm in Sources */, + 15384EFE16119D5E0021DC07 /* EditBoxImplIOS.mm in Sources */, + 15384EFF16119D5E0021DC07 /* CCScrollView.cpp in Sources */, + 15384F0016119D5E0021DC07 /* CCSorting.cpp in Sources */, + 15384F0116119D5E0021DC07 /* CCTableView.cpp in Sources */, + 15384F0216119D5E0021DC07 /* CCTableViewCell.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -828,6 +1171,7 @@ "$(SRCROOT)/../../../cocos2dx/platform/ios", "$(SRCROOT)/../../../external/chipmunk/include/chipmunk", "$(SRCROOT)/../../../scripting/javascript/spidermonkey-ios/include", + "$(SRCROOT)/../../../scripting/javascript/bindings", ); INFOPLIST_FILE = Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1; @@ -866,6 +1210,7 @@ "$(SRCROOT)/../../../cocos2dx/platform/ios", "$(SRCROOT)/../../../external/chipmunk/include/chipmunk", "$(SRCROOT)/../../../scripting/javascript/spidermonkey-ios/include", + "$(SRCROOT)/../../../scripting/javascript/bindings", ); INFOPLIST_FILE = Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1; From a2b468f2b3bf43df0e320f7a55c8bba357b743e6 Mon Sep 17 00:00:00 2001 From: dualface Date: Tue, 25 Sep 2012 16:27:54 +0800 Subject: [PATCH 132/181] [Lua] fix CCActionInterval, CCFiniteTimeAction, CCAction declare --- .../LuaCocos2d.cpp.REMOVED.git-id | 2 +- tools/tolua++/CCAction.pkg | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 1bb2a5fbef..8c3e2590b3 100644 --- a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -dab2e1ed075027aac1e137daaa68542dfe2d7c63 \ No newline at end of file +bc9430117558083bc356dc1490ae82621c4db0f3 \ No newline at end of file diff --git a/tools/tolua++/CCAction.pkg b/tools/tolua++/CCAction.pkg index b52be8a8da..018a455bb2 100644 --- a/tools/tolua++/CCAction.pkg +++ b/tools/tolua++/CCAction.pkg @@ -16,25 +16,25 @@ class CCAction : public CCObject CCObject* copyWithZone(CCZone* pZone); }; -class CCActionInterval : public CCAction -{ - float getElapsed(void); - bool isDone(void); - void setAmplitudeRate(float amp); - float getAmplitudeRate(void); - CCObject* copyWithZone(CCZone* pZone); - CCActionInterval* reverse(void); - - CCActionInterval* create(float d); -}; - -class CCFiniteTimeAction : public CCActionInterval +class CCFiniteTimeAction : public CCAction { float getDuration(void); void setDuration(float duration); CCFiniteTimeAction* reverse(void); }; +class CCActionInterval : public CCFiniteTimeAction +{ + float getElapsed(void); + bool isDone(void); + void setAmplitudeRate(float amp); + float getAmplitudeRate(void); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + CCActionInterval* create(float d); +}; + // CCActionInterval class CCSpeed : public CCAction { From 8d104b824427bd4c11b0bfb271f04dc253e18e6a Mon Sep 17 00:00:00 2001 From: dualface Date: Tue, 25 Sep 2012 16:43:36 +0800 Subject: [PATCH 133/181] [Lua] add CCApplication:getTargetPaltform() --- .../cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id | 2 +- tools/tolua++/CCApplication.pkg | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 8c3e2590b3..8079a39171 100644 --- a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -bc9430117558083bc356dc1490ae82621c4db0f3 \ No newline at end of file +57601a5ee61c442f04b4d1bbfd2697330dfc63cb \ No newline at end of file diff --git a/tools/tolua++/CCApplication.pkg b/tools/tolua++/CCApplication.pkg index 35f5f5606e..669cea1698 100644 --- a/tools/tolua++/CCApplication.pkg +++ b/tools/tolua++/CCApplication.pkg @@ -10,8 +10,20 @@ typedef enum LanguageType kLanguageRussian } ccLanguageType; +enum TargetPlatform +{ + kTargetWindows, + kTargetLinux, + kTargetMacOS, + kTargetAndroid, + kTargetIphone, + kTargetIpad, + kTargetBlackBerry, +}; + class CCApplication { static CCApplication* sharedApplication(); ccLanguageType getCurrentLanguage(); + TargetPlatform getTargetPlatform(); }; From f7229f74d88076d7dae62a2f7a6b6c392dea8453 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 25 Sep 2012 16:57:51 +0800 Subject: [PATCH 134/181] issue #1483: Synchronizing CCControlExtension to latest version. --- cocos2dx/proj.linux/Makefile | 18 +- extensions/Android.mk | 4 +- .../GUI/CCControlExtension/CCControl.cpp | 124 +++-- extensions/GUI/CCControlExtension/CCControl.h | 111 +++-- .../CCControlExtension/CCControlButton.cpp | 295 +++++++---- .../GUI/CCControlExtension/CCControlButton.h | 56 ++- .../CCControlColourPicker.cpp | 72 ++- .../CCControlColourPicker.h | 15 +- .../CCControlExtension/CCControlExtensions.h | 15 +- .../CCControlExtension/CCControlHuePicker.cpp | 59 ++- .../CCControlExtension/CCControlHuePicker.h | 8 +- .../CCControlPotentiometer.cpp | 266 ++++++++++ .../CCControlPotentiometer.h | 109 ++++ .../CCControlSaturationBrightnessPicker.cpp | 46 +- .../CCControlSaturationBrightnessPicker.h | 5 + .../CCControlExtension/CCControlSlider.cpp | 206 +++++--- .../GUI/CCControlExtension/CCControlSlider.h | 41 +- .../CCControlExtension/CCControlStepper.cpp | 347 +++++++++++++ .../GUI/CCControlExtension/CCControlStepper.h | 115 +++++ .../CCControlExtension/CCControlSwitch.cpp | 10 +- .../GUI/CCControlExtension/CCInvocation.cpp | 10 + .../GUI/CCControlExtension/CCInvocation.h | 1 + .../GUI/CCControlExtension/CCMenuPassive.cpp | 465 ------------------ .../GUI/CCControlExtension/CCMenuPassive.h | 92 ---- .../GUI/CCControlExtension/CCScale9Sprite.cpp | 415 +++++++++++----- .../GUI/CCControlExtension/CCScale9Sprite.h | 48 +- .../GUI/CCControlExtension/CCSpacer.cpp | 23 - extensions/GUI/CCControlExtension/CCSpacer.h | 29 -- extensions/proj.win32/libExtensions.vcproj | 32 +- extensions/proj.win32/libExtensions.vcxproj | 8 +- .../proj.win32/libExtensions.vcxproj.filters | 150 +++--- .../CCControlButtonTest.cpp | 16 +- .../CCControlColourPickerTest.cpp | 2 +- .../CCControlPotentiometerTest.cpp | 93 ++++ .../CCControlPotentiometerTest.h | 45 ++ .../CCControlSceneManager.cpp | 10 +- .../CCControlStepperTest.cpp | 96 ++++ .../CCControlStepperTest.h | 48 ++ samples/TestCpp/proj.win32/TestCpp.vcproj | 24 + samples/TestCpp/proj.win32/TestCpp.vcxproj | 4 + .../proj.win32/TestCpp.vcxproj.filters | 18 + 41 files changed, 2299 insertions(+), 1252 deletions(-) create mode 100644 extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp create mode 100644 extensions/GUI/CCControlExtension/CCControlPotentiometer.h create mode 100644 extensions/GUI/CCControlExtension/CCControlStepper.cpp create mode 100644 extensions/GUI/CCControlExtension/CCControlStepper.h delete mode 100644 extensions/GUI/CCControlExtension/CCMenuPassive.cpp delete mode 100644 extensions/GUI/CCControlExtension/CCMenuPassive.h delete mode 100644 extensions/GUI/CCControlExtension/CCSpacer.cpp delete mode 100644 extensions/GUI/CCControlExtension/CCSpacer.h create mode 100644 samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp create mode 100644 samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.h create mode 100644 samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp create mode 100644 samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.h diff --git a/cocos2dx/proj.linux/Makefile b/cocos2dx/proj.linux/Makefile index 1a5b8aa59d..9c2ac158e7 100644 --- a/cocos2dx/proj.linux/Makefile +++ b/cocos2dx/proj.linux/Makefile @@ -144,13 +144,13 @@ OBJECTS = ../actions/CCAction.o \ ../../extensions/CCBReader/CCLayerGradientLoader.o \ ../../extensions/CCBReader/CCSpriteLoader.o \ ../../extensions/CCBReader/CCLayerLoader.o \ - ../../extensions/CCBReader/CCBAnimationManager.o \ - ../../extensions/CCBReader/CCBKeyframe.o \ - ../../extensions/CCBReader/CCBSequence.o \ - ../../extensions/CCBReader/CCBSequenceProperty.o \ - ../../extensions/CCBReader/CCBValue.o \ - ../../extensions/CCBReader/CCData.o \ - ../../extensions/CCBReader/CCNode+CCBRelativePositioning.o \ + ../../extensions/CCBReader/CCBAnimationManager.o \ + ../../extensions/CCBReader/CCBKeyframe.o \ + ../../extensions/CCBReader/CCBSequence.o \ + ../../extensions/CCBReader/CCBSequenceProperty.o \ + ../../extensions/CCBReader/CCBValue.o \ + ../../extensions/CCBReader/CCData.o \ + ../../extensions/CCBReader/CCNode+CCBRelativePositioning.o \ ../../extensions/GUI/CCScrollView/CCScrollView.o \ ../../extensions/GUI/CCScrollView/CCSorting.o \ ../../extensions/GUI/CCScrollView/CCTableView.o \ @@ -164,9 +164,9 @@ OBJECTS = ../actions/CCAction.o \ ../../extensions/GUI/CCControlExtension/CCControlSwitch.o \ ../../extensions/GUI/CCControlExtension/CCControlUtils.o \ ../../extensions/GUI/CCControlExtension/CCInvocation.o \ - ../../extensions/GUI/CCControlExtension/CCMenuPassive.o \ ../../extensions/GUI/CCControlExtension/CCScale9Sprite.o \ - ../../extensions/GUI/CCControlExtension/CCSpacer.o \ + ../../extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp \ + ../../extensions/GUI/CCControlExtension/CCControlStepper.cpp \ ../../extensions/network/HttpClient.o \ ../kazmath/src/aabb.o \ ../kazmath/src/plane.o \ diff --git a/extensions/Android.mk b/extensions/Android.mk index e475e74556..f8dd0a463d 100644 --- a/extensions/Android.mk +++ b/extensions/Android.mk @@ -38,9 +38,9 @@ GUI/CCControlExtension/CCControlSlider.cpp \ GUI/CCControlExtension/CCControlSwitch.cpp \ GUI/CCControlExtension/CCControlUtils.cpp \ GUI/CCControlExtension/CCInvocation.cpp \ -GUI/CCControlExtension/CCMenuPassive.cpp \ GUI/CCControlExtension/CCScale9Sprite.cpp \ -GUI/CCControlExtension/CCSpacer.cpp \ +GUI/CCControlExtension/CCControlPotentiometer.cpp \ +GUI/CCControlExtension/CCControlStepper.cpp \ GUI/CCScrollView/CCScrollView.cpp \ GUI/CCScrollView/CCTableView.cpp \ GUI/CCScrollView/CCTableViewCell.cpp \ diff --git a/extensions/GUI/CCControlExtension/CCControl.cpp b/extensions/GUI/CCControlExtension/CCControl.cpp index d133567df2..3c4e76e5b6 100644 --- a/extensions/GUI/CCControlExtension/CCControl.cpp +++ b/extensions/GUI/CCControlExtension/CCControl.cpp @@ -35,6 +35,16 @@ NS_CC_EXT_BEGIN CCControl::CCControl() +: m_cOpacity(0) +, m_tColor(ccBLACK) +, m_bIsOpacityModifyRGB(false) +, m_nDefaultTouchPriority(0) +, m_eState(CCControlStateNormal) +, m_hasVisibleParents(false) +, m_bEnabled(false) +, m_bSelected(false) +, m_bHighlighted(false) +, m_pDispatchTable(NULL) { } @@ -46,76 +56,75 @@ bool CCControl::init() //this->setTouchEnabled(true); //m_bIsTouchEnabled=true; // Initialise instance variables - m_nState=CCControlStateNormal; - m_bEnabled=true; - m_bSelected=false; - m_bHighlighted=false; + m_eState=CCControlStateNormal; + setEnabled(true); + setSelected(false); + setHighlighted(false); // Set the touch dispatcher priority by default to 1 - m_nDefaultTouchPriority = 1; + setDefaultTouchPriority(1); this->setDefaultTouchPriority(m_nDefaultTouchPriority); // Initialise the tables - dispatchTable=new CCDictionary(); - //dispatchTable->autorelease(); - // dispatchTable_ = [[NSMutableDictionary alloc] initWithCapacity:1]; + m_pDispatchTable = new CCDictionary(); + return true; } else + { return false; + } } CCControl::~CCControl() { - CC_SAFE_RELEASE(dispatchTable); + CC_SAFE_RELEASE(m_pDispatchTable); } //Menu - Events void CCControl::registerWithTouchDispatcher() { - CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, kCCMenuHandlerPriority, true); + CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, m_nDefaultTouchPriority, true); } void CCControl::onEnter() { - //CCTouchDispatcher::sharedDispatcher()->addTargetedDelegate(this, m_nDefaultTouchPriority, true); CCLayer::onEnter(); } void CCControl::onExit() { - //CCTouchDispatcher::sharedDispatcher()->removeDelegate(this); CCLayer::onExit(); } void CCControl::sendActionsForControlEvents(CCControlEvent controlEvents) { // For each control events - for (int i = 0; i < CONTROL_EVENT_TOTAL_NUMBER; i++) + for (int i = 0; i < kControlEventTotalNumber; i++) { // If the given controlEvents bitmask contains the curent event if ((controlEvents & (1 << i))) { // Call invocations // - CCArray* invocationList=CCControl::dispatchListforControlEvent(1<dispatchListforControlEvent(1<invoke(this); - } + } } } } void CCControl::addTargetWithActionForControlEvents(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvents) { // For each control events - for (int i = 0; i < CONTROL_EVENT_TOTAL_NUMBER; i++) + for (int i = 0; i < kControlEventTotalNumber; i++) { // If the given controlEvents bitmask contains the curent event if ((controlEvents & (1 << i))) { - CCControl::addTargetWithActionForControlEvent(target, action, 1<addTargetWithActionForControlEvent(target, action, 1<autorelease(); + CCInvocation *invocation = CCInvocation::create(target, action, controlEvent); + // Add the invocation into the dispatch list for the given control event - CCArray* eventInvocationList = dispatchListforControlEvent(controlEvent); + CCArray* eventInvocationList = this->dispatchListforControlEvent(controlEvent); eventInvocationList->addObject(invocation); } void CCControl::removeTargetWithActionForControlEvents(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvents) { // For each control events - for (int i = 0; i < CONTROL_EVENT_TOTAL_NUMBER; i++) + for (int i = 0; i < kControlEventTotalNumber; i++) { // If the given controlEvents bitmask contains the curent event if ((controlEvents & (1 << i))) { - removeTargetWithActionForControlEvent(target, action, 1 << i); + this->removeTargetWithActionForControlEvent(target, action, 1 << i); } } } -/** - * Removes a target and action for a particular event from an internal dispatch - * table. - * - * @param target The target objectthat is, the object to which the action - * message is sent. Pass nil to remove all targets paired with action and the - * specified control events. - * @param action A selector identifying an action message. Pass NULL to remove - * all action messages paired with target. - * @param controlEvent A control event for which the action message is sent. - * See "CCControlEvent" for constants. - */ void CCControl::removeTargetWithActionForControlEvent(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent) { // Retrieve all invocations for the given control event // - CCArray *eventInvocationList=dispatchListforControlEvent(controlEvent); + CCArray *eventInvocationList = this->dispatchListforControlEvent(controlEvent); //remove all invocations if the target and action are null //TODO: should the invocations be deleted, or just removed from the array? Won't that cause issues if you add a single invocation for multiple events? @@ -192,13 +189,19 @@ void CCControl::removeTargetWithActionForControlEvent(CCObject* target, SEL_CCCo { CCInvocation *invocation = (CCInvocation*)pObj; bool shouldBeRemoved=true; - if (target) - shouldBeRemoved=(target==invocation->getTarget()); + if (target) + { + shouldBeRemoved=(target==invocation->getTarget()); + } if (action) + { shouldBeRemoved=(shouldBeRemoved && (action==invocation->getAction())); + } // Remove the corresponding invocation object if (shouldBeRemoved) + { eventInvocationList->removeObject(invocation, bDeleteObjects); + } } } } @@ -249,17 +252,17 @@ GLubyte CCControl::getOpacity() } -void CCControl::setOpacityModifyRGB(bool opacityModifyRGB) +void CCControl::setOpacityModifyRGB(bool bOpacityModifyRGB) { - m_bIsOpacityModifyRGB=opacityModifyRGB; - CCObject* child; + m_bIsOpacityModifyRGB=bOpacityModifyRGB; + CCObject* child; CCArray* children=getChildren(); CCARRAY_FOREACH(children, child) { CCRGBAProtocol* pNode = dynamic_cast(child); if (pNode) { - pNode->setOpacityModifyRGB(opacityModifyRGB); + pNode->setOpacityModifyRGB(bOpacityModifyRGB); } } } @@ -272,35 +275,47 @@ bool CCControl::isOpacityModifyRGB() CCPoint CCControl::getTouchLocation(CCTouch* touch) { - CCPoint touchLocation = touch->getLocation();; // Get the touch position - touchLocation = this->getParent()->convertToNodeSpace(touchLocation); // Convert to the node space of this class + CCPoint touchLocation = touch->getLocation(); // Get the touch position + touchLocation = this->convertToNodeSpace(touchLocation); // Convert to the node space of this class return touchLocation; } bool CCControl::isTouchInside(CCTouch* touch) { - CCPoint touchLocation=getTouchLocation(touch); + CCPoint touchLocation = touch->getLocation(); // Get the touch position + touchLocation = this->getParent()->convertToNodeSpace(touchLocation); CCRect bBox=boundingBox(); return bBox.containsPoint(touchLocation); } CCArray* CCControl::dispatchListforControlEvent(CCControlEvent controlEvent) { - CCArray* invocationList = (CCArray*)dispatchTable->objectForKey(controlEvent); + CCArray* invocationList = (CCArray*)m_pDispatchTable->objectForKey(controlEvent); // If the invocation list does not exist for the dispatch table, we create it if (invocationList == NULL) { invocationList = CCArray::createWithCapacity(1); - dispatchTable->setObject(invocationList, controlEvent); + m_pDispatchTable->setObject(invocationList, controlEvent); } return invocationList; } +void CCControl::needsLayout() +{ +} + void CCControl::setEnabled(bool bEnabled) { m_bEnabled = bEnabled; + if(m_bEnabled) { + m_eState = CCControlStateNormal; + } else { + m_eState = CCControlStateDisabled; + } + + this->needsLayout(); } bool CCControl::isEnabled() @@ -311,6 +326,7 @@ bool CCControl::isEnabled() void CCControl::setSelected(bool bSelected) { m_bSelected = bSelected; + this->needsLayout(); } bool CCControl::isSelected() @@ -321,6 +337,7 @@ bool CCControl::isSelected() void CCControl::setHighlighted(bool bHighlighted) { m_bHighlighted = bHighlighted; + this->needsLayout(); } bool CCControl::isHighlighted() @@ -328,4 +345,17 @@ bool CCControl::isHighlighted() return m_bHighlighted; } +bool CCControl::hasVisibleParents() +{ + CCNode* pParent = this->getParent(); + for( CCNode *c = pParent; c != NULL; c = c->getParent() ) + { + if( !c->isVisible() ) + { + return false; + } + } + return true; +} + NS_CC_EXT_END diff --git a/extensions/GUI/CCControlExtension/CCControl.h b/extensions/GUI/CCControlExtension/CCControl.h index f84b78635f..1de9fe42b7 100644 --- a/extensions/GUI/CCControlExtension/CCControl.h +++ b/extensions/GUI/CCControlExtension/CCControl.h @@ -31,7 +31,7 @@ #include "CCInvocation.h" #include "CCControlUtils.h" -#include "layers_scenes_transitions_nodes/CCLayer.h" +#include "cocos2d.h" NS_CC_EXT_BEGIN @@ -45,7 +45,7 @@ class CCInvocation; */ /** Number of kinds of control event. */ -#define CONTROL_EVENT_TOTAL_NUMBER 9 +#define kControlEventTotalNumber 9 /** Kinds of possible events for the control objects. */ enum @@ -65,25 +65,24 @@ typedef unsigned int CCControlEvent; /** The possible state for a control. */ enum { - CCControlStateNormal = 1 << 0, // The normal, or default state of a controlthat is, enabled but neither selected nor highlighted. + CCControlStateNormal = 1 << 0, // The normal, or default state of a controlthat is, enabled but neither selected nor highlighted. CCControlStateHighlighted = 1 << 1, // Highlighted state of a control. A control enters this state when a touch down, drag inside or drag enter is performed. You can retrieve and set this value through the highlighted property. CCControlStateDisabled = 1 << 2, // Disabled state of a control. This state indicates that the control is currently disabled. You can retrieve and set this value through the enabled property. - CCControlStateSelected = 1 << 3, // Selected state of a control. This state indicates that the control is currently selected. You can retrieve and set this value through the selected property. - CCControlStateInitial = 1 << 3 + CCControlStateSelected = 1 << 3 // Selected state of a control. This state indicates that the control is currently selected. You can retrieve and set this value through the selected property. }; typedef unsigned int CCControlState; -/* - * @class - * CCControl is inspired by the UIControl API class from the UIKit library of - * CocoaTouch. It provides a base class for control CCSprites such as CCButton - * or CCSlider that convey user intent to the application. - * - * The goal of CCControl is to define an interface and base implementation for - * preparing action messages and initially dispatching them to their targets when - * certain events occur. - * - * To use the CCControl you have to subclass it. +/* + * @class + * CCControl is inspired by the UIControl API class from the UIKit library of + * CocoaTouch. It provides a base class for control CCSprites such as CCButton + * or CCSlider that convey user intent to the application. + * + * The goal of CCControl is to define an interface and base implementation for + * preparing action messages and initially dispatching them to their targets when + * certain events occur. + * + * To use the CCControl you have to subclass it. */ class CCControl : public CCLayer, public CCRGBAProtocol { @@ -93,12 +92,16 @@ class CCControl : public CCLayer, public CCRGBAProtocol CC_PROPERTY_PASS_BY_REF(ccColor3B, m_tColor, Color); bool m_bIsOpacityModifyRGB; bool isOpacityModifyRGB(); - void setOpacityModifyRGB(bool isOpacityModifyRGB); + void setOpacityModifyRGB(bool bOpacityModifyRGB); /** Changes the priority of the button. The lower the number, the higher the priority. */ CC_SYNTHESIZE(int, m_nDefaultTouchPriority, DefaultTouchPriority); /** The current control state constant. */ - CC_SYNTHESIZE_READONLY(CCControlState, m_nState, State); + CC_SYNTHESIZE_READONLY(CCControlState, m_eState, State); + + /** True if all of the controls parents are visible */ +protected: + bool m_hasVisibleParents; public: /** Tells whether the control is enabled. */ @@ -110,16 +113,23 @@ public: /** A Boolean value that determines whether the control is highlighted. */ virtual void setHighlighted(bool bHighlighted); virtual bool isHighlighted(); + bool hasVisibleParents(); + /** + * Updates the control layout using its current internal state. + */ + virtual void needsLayout(); protected: bool m_bEnabled; bool m_bSelected; bool m_bHighlighted; - // CCControlState, CCArray - CCDictionary* dispatchTable; - - + /** + * Table of connection between the CCControlEvents and their associated + * target-actions pairs. For each CCButtonEvents a list of NSInvocation + * (which contains the target-action pair) is linked. + */ + CCDictionary* m_pDispatchTable; //cjh need to be retained public: CCControl(); @@ -146,7 +156,7 @@ public: * parameters, in that order. * When you call this method, target is not retained. * - * @param target The target objectthat is, the object to which the action + * @param target The target object that is, the object to which the action * message is sent. It cannot be nil. The target is not retained. * @param action A selector identifying an action message. It cannot be NULL. * @param controlEvents A bitmask specifying the control events for which the @@ -175,32 +185,32 @@ public: */ virtual CCPoint getTouchLocation(CCTouch* touch); - + /** * Returns a boolean value that indicates whether a touch is inside the bounds * of the receiver. The given touch must be relative to the world. * * @param touch A CCTouch object that represents a touch. * - * @return YES whether a touch is inside the receivers rect. + * @return YES whether a touch is inside the receivers rect. */ virtual bool isTouchInside(CCTouch * touch); protected: /** - * Returns an CCInvocation object able to construct messages using a given - * target-action pair. (The invocation may optionnaly include the sender and - * the event as parameters, in that order) - * - * @param target The target object. - * @param action A selector identifying an action message. - * @param controlEvent A control events for which the action message is sent. - * See "CCControlEvent" for constants. - * - * @return an CCInvocation object able to construct messages using a given - * target-action pair. - */ + * Returns an CCInvocation object able to construct messages using a given + * target-action pair. (The invocation may optionnaly include the sender and + * the event as parameters, in that order) + * + * @param target The target object. + * @param action A selector identifying an action message. + * @param controlEvent A control events for which the action message is sent. + * See "CCControlEvent" for constants. + * + * @return an CCInvocation object able to construct messages using a given + * target-action pair. + */ CCInvocation* invocationWithTargetAndActionForControlEvent(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent); @@ -216,8 +226,33 @@ protected: */ // CCArray* dispatchListforControlEvent(CCControlEvent controlEvent); -public: + /** + * Adds a target and action for a particular event to an internal dispatch + * table. + * The action message may optionnaly include the sender and the event as + * parameters, in that order. + * When you call this method, target is not retained. + * + * @param target The target objectthat is, the object to which the action + * message is sent. It cannot be nil. The target is not retained. + * @param action A selector identifying an action message. It cannot be NULL. + * @param controlEvent A control event for which the action message is sent. + * See "CCControlEvent" for constants. + */ void addTargetWithActionForControlEvent(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent); + + /** + * Removes a target and action for a particular event from an internal dispatch + * table. + * + * @param target The target objectthat is, the object to which the action + * message is sent. Pass nil to remove all targets paired with action and the + * specified control events. + * @param action A selector identifying an action message. Pass NULL to remove + * all action messages paired with target. + * @param controlEvent A control event for which the action message is sent. + * See "CCControlEvent" for constants. + */ void removeTargetWithActionForControlEvent(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent); CREATE_FUNC(CCControl); diff --git a/extensions/GUI/CCControlExtension/CCControlButton.cpp b/extensions/GUI/CCControlExtension/CCControlButton.cpp index 2494b61a85..37b40efe20 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.cpp +++ b/extensions/GUI/CCControlExtension/CCControlButton.cpp @@ -41,12 +41,32 @@ enum kZoomActionTag = 0xCCCB0001, }; +CCControlButton::CCControlButton() +: m_currentTitle(NULL) +, m_currentTitleColor(ccWHITE) +, m_doesAdjustBackgroundImage(false) +, m_titleLabel(NULL) +, m_backgroundSprite(NULL) +, m_zoomOnTouchDown(false) +, m_isPushed(false) +, m_bParentInited(false) +, m_titleDispatchTable(NULL) +, m_titleColorDispatchTable(NULL) +, m_titleLabelDispatchTable(NULL) +, m_backgroundSpriteDispatchTable(NULL) +, m_marginH(CCControlButtonMarginLR) +, m_marginV(CCControlButtonMarginTB) +{ + +} + CCControlButton::~CCControlButton() { CC_SAFE_RELEASE(m_backgroundSpriteDispatchTable); CC_SAFE_RELEASE(m_titleLabelDispatchTable); CC_SAFE_RELEASE(m_titleColorDispatchTable); CC_SAFE_RELEASE(m_titleDispatchTable); + CC_SAFE_RELEASE(m_backgroundSprite); } //initialisers @@ -56,50 +76,47 @@ bool CCControlButton::init() return this->initWithLabelAndBackgroundSprite(CCLabelTTF::create("", "Helvetica", 12), CCScale9Sprite::create()); } - bool CCControlButton::initWithLabelAndBackgroundSprite(CCNode* node, CCScale9Sprite* backgroundSprite) { if (CCControl::init()) { - assert(node != NULL); + CCAssert(node != NULL, "Label must not be nil."); CCLabelProtocol* label = dynamic_cast(node); CCRGBAProtocol* rgbaLabel = dynamic_cast(node); - assert(label != NULL || rgbaLabel!=NULL || backgroundSprite != NULL); + CCAssert(backgroundSprite != NULL, "Background sprite must not be nil."); + CCAssert(label != NULL || rgbaLabel!=NULL || backgroundSprite != NULL, ""); + m_bParentInited = true; + + // Initialize the button state tables + this->setTitleDispatchTable(CCDictionary::create()); + this->setTitleColorDispatchTable(CCDictionary::create()); + this->setTitleLabelDispatchTable(CCDictionary::create()); + this->setBackgroundSpriteDispatchTable(CCDictionary::create()); + setTouchEnabled(true); - pushed=false; + m_isPushed = false; m_zoomOnTouchDown = true; - m_nState=CCControlStateInitial; + m_currentTitle=NULL; // Adjust the background image by default - m_adjustBackgroundImage=true; - + setAdjustBackgroundImage(true); + setPreferredSize(CCSizeZero); // Zooming button by default m_zoomOnTouchDown = true; - + // Set the default anchor point ignoreAnchorPointForPosition(false); setAnchorPoint(ccp(0.5f, 0.5f)); // Set the nodes - m_titleLabel = node; - m_backgroundSprite = backgroundSprite; - - - // Initialize the button state tables - m_titleDispatchTable=new CCDictionary(); - //m_titleDispatchTable->autorelease(); - m_titleColorDispatchTable=new CCDictionary(); - //m_titleColorDispatchTable->autorelease(); - m_titleLabelDispatchTable=new CCDictionary(); - //m_titleLabelDispatchTable->autorelease(); - m_backgroundSpriteDispatchTable=new CCDictionary(); - //m_backgroundSpriteDispatchTable->autorelease(); + setTitleLabel(node); + setBackgroundSprite(backgroundSprite); // Set the default color and opacity - setColor(ccc3(255, 255, 255)); - setOpacity(255); + setColor(ccc3(255.0f, 255.0f, 255.0f)); + setOpacity(255.0f); setOpacityModifyRGB(true); // Initialize the dispatch table @@ -111,13 +128,7 @@ bool CCControlButton::initWithLabelAndBackgroundSprite(CCNode* node, CCScale9Spr setTitleLabelForState(node, CCControlStateNormal); setBackgroundSpriteForState(backgroundSprite, CCControlStateNormal); - m_nState=CCControlStateNormal; - - //default margins - m_marginH=24; - m_marginV=12; - - this->m_labelAnchorPoint = CCPoint(0.5f, 0.5f); + setLabelAnchorPoint(ccp(0.5f, 0.5f)); // Layout update needsLayout(); @@ -126,7 +137,9 @@ bool CCControlButton::initWithLabelAndBackgroundSprite(CCNode* node, CCScale9Spr } //couldn't init the CCControl else + { return false; + } } CCControlButton* CCControlButton::buttonWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite) @@ -233,20 +246,20 @@ void CCControlButton::setPreferredSize(CCSize size) { if(size.width == 0 && size.height == 0) { - m_adjustBackgroundImage = true; + m_doesAdjustBackgroundImage = true; } else { - m_adjustBackgroundImage = false; + m_doesAdjustBackgroundImage = false; CCDictElement * item = NULL; CCDICT_FOREACH(m_backgroundSpriteDispatchTable, item) { CCScale9Sprite* sprite = (CCScale9Sprite*)item->getObject(); sprite->setPreferredSize(size); } - - m_preferredSize = size; } + + m_preferredSize = size; needsLayout(); } @@ -257,13 +270,13 @@ CCSize CCControlButton::getPreferredSize() void CCControlButton::setAdjustBackgroundImage(bool adjustBackgroundImage) { - m_adjustBackgroundImage=adjustBackgroundImage; + m_doesAdjustBackgroundImage=adjustBackgroundImage; needsLayout(); } -bool CCControlButton::getAdjustBackgroundImage() +bool CCControlButton::doesAdjustBackgroundImage() { - return m_adjustBackgroundImage; + return m_doesAdjustBackgroundImage; } CCPoint CCControlButton::getLabelAnchorPoint() @@ -274,18 +287,24 @@ CCPoint CCControlButton::getLabelAnchorPoint() void CCControlButton::setLabelAnchorPoint(CCPoint labelAnchorPoint) { this->m_labelAnchorPoint = labelAnchorPoint; - - this->m_titleLabel->setAnchorPoint(labelAnchorPoint); + if (m_titleLabel != NULL) + { + this->m_titleLabel->setAnchorPoint(labelAnchorPoint); + } } CCString* CCControlButton::getTitleForState(CCControlState state) { - CCString* title=(CCString*)m_titleDispatchTable->objectForKey(state); - if (title) + if (m_titleDispatchTable != NULL) { - return title; + CCString* title=(CCString*)m_titleDispatchTable->objectForKey(state); + if (title) + { + return title; + } + return (CCString*)m_titleDispatchTable->objectForKey(CCControlStateNormal); } - return (CCString*)m_titleDispatchTable->objectForKey(CCControlStateNormal); + return CCString::create(""); } void CCControlButton::setTitleForState(CCString* title, CCControlState state) @@ -307,15 +326,24 @@ void CCControlButton::setTitleForState(CCString* title, CCControlState state) const ccColor3B CCControlButton::getTitleColorForState(CCControlState state) { - ccColor3B returnColor; - CCColor3bObject* colorObject=(CCColor3bObject*)m_titleColorDispatchTable->objectForKey(state); - if (colorObject) + ccColor3B returnColor = ccWHITE; + do { - returnColor= colorObject->value; - return returnColor; - } - colorObject=(CCColor3bObject*)m_titleColorDispatchTable->objectForKey(CCControlStateNormal); - returnColor=colorObject->value; + CC_BREAK_IF(NULL == m_titleColorDispatchTable); + CCColor3bObject* colorObject=(CCColor3bObject*)m_titleColorDispatchTable->objectForKey(state); + if (colorObject) + { + returnColor= colorObject->value; + break; + } + + colorObject=(CCColor3bObject*)m_titleColorDispatchTable->objectForKey(CCControlStateNormal); + if (colorObject) + { + returnColor=colorObject->value; + } + } while (0); + return returnColor; } @@ -368,7 +396,10 @@ void CCControlButton::setTitleLabelForState(CCNode* titleLabel, CCControlState s void CCControlButton::setTitleTTFForState(const char * fntFile, CCControlState state) { CCString * title = this->getTitleForState(state); - if (!title) title = new CCString(""); + if (!title) + { + title = CCString::create(""); + } this->setTitleLabelForState(CCLabelTTF::create(title->getCString(), fntFile, 12), state); } @@ -416,7 +447,10 @@ float CCControlButton::getTitleTTFSizeForState(CCControlState state) void CCControlButton::setTitleBMFontForState(const char * fntFile, CCControlState state) { CCString * title = this->getTitleForState(state); - if (!title) title = new CCString(""); + if (!title) + { + title = CCString::create(""); + } this->setTitleLabelForState(CCLabelBMFont::create(title->getCString(), fntFile), state); } @@ -448,10 +482,12 @@ CCScale9Sprite* CCControlButton::getBackgroundSpriteForState(CCControlState stat void CCControlButton::setBackgroundSpriteForState(CCScale9Sprite* sprite, CCControlState state) { - CCScale9Sprite* previousSprite = (CCScale9Sprite*)m_backgroundSpriteDispatchTable->objectForKey(state); - if (previousSprite) + CCSize oldPreferredSize = m_preferredSize; + + CCScale9Sprite* previousBackgroundSprite = (CCScale9Sprite*)m_backgroundSpriteDispatchTable->objectForKey(state); + if (previousBackgroundSprite) { - removeChild(previousSprite, true); + removeChild(previousBackgroundSprite, true); m_backgroundSpriteDispatchTable->removeObjectForKey(state); } @@ -462,6 +498,12 @@ void CCControlButton::setBackgroundSpriteForState(CCScale9Sprite* sprite, CCCont if (this->m_preferredSize.width != 0 || this->m_preferredSize.height != 0) { + if (oldPreferredSize.equals(m_preferredSize)) + { + // Force update of preferred size + sprite->setPreferredSize(CCSizeMake(oldPreferredSize.width+1, oldPreferredSize.height+1)); + } + sprite->setPreferredSize(this->m_preferredSize); } @@ -481,70 +523,113 @@ void CCControlButton::setBackgroundSpriteFrameForState(CCSpriteFrame * spriteFra void CCControlButton::needsLayout() { + if (!m_bParentInited) { + return; + } // Hide the background and the label - m_titleLabel->setVisible(false); - m_backgroundSprite->setVisible(false); - + if (m_titleLabel != NULL) { + m_titleLabel->setVisible(false); + } + if (m_backgroundSprite) { + m_backgroundSprite->setVisible(false); + } // Update anchor of all labels this->setLabelAnchorPoint(this->m_labelAnchorPoint); // Update the label to match with the current state - //CC_SAFE_RELEASE(m_currentTitle) - - m_currentTitle=getTitleForState(m_nState); - m_currentTitleColor=getTitleColorForState(m_nState); + CC_SAFE_RELEASE(m_currentTitle); + m_currentTitle = getTitleForState(m_eState); + CC_SAFE_RETAIN(m_currentTitle); + + m_currentTitleColor=getTitleColorForState(m_eState); + + this->setTitleLabel(getTitleLabelForState(m_eState)); - m_titleLabel=getTitleLabelForState(m_nState); - CCLabelProtocol* label = dynamic_cast(m_titleLabel); - if (label) + if (label && m_currentTitle) + { label->setString(m_currentTitle->getCString()); + } + CCRGBAProtocol* rgbaLabel = dynamic_cast(m_titleLabel); if (rgbaLabel) + { rgbaLabel->setColor(m_currentTitleColor); - m_titleLabel->setPosition(ccp (getContentSize().width / 2, getContentSize().height / 2)); - + } + if (m_titleLabel != NULL) + { + m_titleLabel->setPosition(ccp (getContentSize().width / 2, getContentSize().height / 2)); + } // Update the background sprite - m_backgroundSprite=getBackgroundSpriteForState(m_nState); - m_backgroundSprite->setPosition(ccp (getContentSize().width / 2, getContentSize().height / 2)); - + this->setBackgroundSprite(this->getBackgroundSpriteForState(m_eState)); + if (m_backgroundSprite != NULL) + { + m_backgroundSprite->setPosition(ccp (getContentSize().width / 2, getContentSize().height / 2)); + } + // Get the title label size - CCSize titleLabelSize =m_titleLabel->boundingBox().size; + CCSize titleLabelSize; + if (m_titleLabel != NULL) + { + titleLabelSize = m_titleLabel->boundingBox().size; + } // Adjust the background image if necessary - if (m_adjustBackgroundImage) + if (m_doesAdjustBackgroundImage) { // Add the margins - m_backgroundSprite->setContentSize(CCSizeMake(titleLabelSize.width + m_marginH * 2, titleLabelSize.height + m_marginV * 2)); + if (m_backgroundSprite != NULL) + { + m_backgroundSprite->setContentSize(CCSizeMake(titleLabelSize.width + m_marginH * 2, titleLabelSize.height + m_marginV * 2)); + } } else { //TODO: should this also have margins if one of the preferred sizes is relaxed? - CCSize preferredSize = m_backgroundSprite->getPreferredSize(); - if (preferredSize.width <= 0) + if (m_backgroundSprite != NULL) { - preferredSize.width = titleLabelSize.width; + CCSize preferredSize = m_backgroundSprite->getPreferredSize(); + if (preferredSize.width <= 0) + { + preferredSize.width = titleLabelSize.width; + } + if (preferredSize.height <= 0) + { + preferredSize.height = titleLabelSize.height; + } + + m_backgroundSprite->setContentSize(preferredSize); } - if (preferredSize.height <= 0) - { - preferredSize.height = titleLabelSize.height; - } - - m_backgroundSprite->setContentSize(preferredSize); } // Set the content size - - CCRect maxRect = CCControlUtils::CCRectUnion(m_titleLabel->boundingBox(), m_backgroundSprite->boundingBox()); + CCRect rectTitle; + if (m_titleLabel != NULL) + { + rectTitle = m_titleLabel->boundingBox(); + } + CCRect rectBackground; + if (m_backgroundSprite != NULL) + { + rectBackground = m_backgroundSprite->boundingBox(); + } + + CCRect maxRect = CCControlUtils::CCRectUnion(rectTitle, rectBackground); setContentSize(CCSizeMake(maxRect.size.width, maxRect.size.height)); - m_titleLabel->setPosition(ccp(getContentSize().width/2, getContentSize().height/2)); - m_backgroundSprite->setPosition(ccp(getContentSize().width/2, getContentSize().height/2)); - - // Make visible the background and the label - m_titleLabel->setVisible(true); - m_backgroundSprite->setVisible(true); + if (m_titleLabel != NULL) + { + m_titleLabel->setPosition(ccp(getContentSize().width/2, getContentSize().height/2)); + // Make visible the background and the label + m_titleLabel->setVisible(true); + } + + if (m_backgroundSprite != NULL) + { + m_backgroundSprite->setPosition(ccp(getContentSize().width/2, getContentSize().height/2)); + m_backgroundSprite->setVisible(true); + } } @@ -556,8 +641,8 @@ bool CCControlButton::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) return false; } - m_nState=CCControlStateHighlighted; - pushed=true; + m_eState=CCControlStateHighlighted; + m_isPushed=true; this->setHighlighted(true); sendActionsForControlEvents(CCControlEventTouchDown); return true; @@ -565,9 +650,9 @@ bool CCControlButton::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) void CCControlButton::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent) { - if (!m_bEnabled || !pushed || m_bSelected) + if (!isEnabled() || !isPushed() || isSelected()) { - if (m_bHighlighted) + if (isHighlighted()) { setHighlighted(false); } @@ -575,32 +660,32 @@ void CCControlButton::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent) } bool isTouchMoveInside = isTouchInside(pTouch); - if (isTouchMoveInside && !m_bHighlighted) + if (isTouchMoveInside && !isHighlighted()) { - m_nState = CCControlStateHighlighted; + m_eState = CCControlStateHighlighted; setHighlighted(true); sendActionsForControlEvents(CCControlEventTouchDragEnter); } - else if (isTouchMoveInside && m_bHighlighted) + else if (isTouchMoveInside && isHighlighted()) { sendActionsForControlEvents(CCControlEventTouchDragInside); } - else if (!isTouchMoveInside && m_bHighlighted) + else if (!isTouchMoveInside && isHighlighted()) { - m_nState = CCControlStateNormal; + m_eState = CCControlStateNormal; setHighlighted(false); sendActionsForControlEvents(CCControlEventTouchDragExit); } - else if (!isTouchMoveInside && !m_bHighlighted) + else if (!isTouchMoveInside && !isHighlighted()) { sendActionsForControlEvents(CCControlEventTouchDragOutside); } } void CCControlButton::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent) { - m_nState = CCControlStateNormal; - pushed = false; + m_eState = CCControlStateNormal; + m_isPushed = false; setHighlighted(false); @@ -643,8 +728,8 @@ GLubyte CCControlButton::getOpacity() void CCControlButton::ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent) { - m_nState = CCControlStateNormal; - pushed = false; + m_eState = CCControlStateNormal; + m_isPushed = false; setHighlighted(false); sendActionsForControlEvents(CCControlEventTouchCancel); } diff --git a/extensions/GUI/CCControlExtension/CCControlButton.h b/extensions/GUI/CCControlExtension/CCControlButton.h index 8ebcec09ae..ea5c3b3877 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.h +++ b/extensions/GUI/CCControlExtension/CCControlButton.h @@ -35,6 +35,12 @@ NS_CC_EXT_BEGIN +/* Define the button margin for Left/Right edge */ +#define CCControlButtonMarginLR 8 // px +/* Define the button margin for Top/Bottom edge */ +#define CCControlButtonMarginTB 2 // px + + /** * @addtogroup GUI * @{ @@ -46,6 +52,7 @@ NS_CC_EXT_BEGIN class CCControlButton : public CCControl { public: + CCControlButton(); virtual ~CCControlButton(); virtual void needsLayout(void); @@ -56,42 +63,51 @@ protected: // CCRGBAProtocol //bool m_bIsOpacityModifyRGB; + /** The current title that is displayed on the button. */ + CC_SYNTHESIZE_READONLY(CCString*, m_currentTitle, CurrentTitle); + + /** The current color used to display the title. */ + CC_SYNTHESIZE_READONLY_PASS_BY_REF(ccColor3B, m_currentTitleColor, CurrentTitleColor); + /** Adjust the background image. YES by default. If the property is set to NO, the background will use the prefered size of the background image. */ - CC_PROPERTY(bool, m_adjustBackgroundImage, AdjustBackgroundImage); + bool doesAdjustBackgroundImage(); + void setAdjustBackgroundImage(bool adjustBackgroundImage); + bool m_doesAdjustBackgroundImage; - /** Adjust the button zooming on touchdown. Default value is YES. */ - CC_PROPERTY(bool, m_zoomOnTouchDown, ZoomOnTouchDown); + /** The current title label. */ + CC_SYNTHESIZE_RETAIN(CCNode*, m_titleLabel, TitleLabel); + + /** The current background sprite. */ + CC_SYNTHESIZE_RETAIN(CCScale9Sprite*, m_backgroundSprite, BackgroundSprite); /** The prefered size of the button, if label is larger it will be expanded. */ CC_PROPERTY(CCSize, m_preferredSize, PreferredSize); + /** Adjust the button zooming on touchdown. Default value is YES. */ + CC_PROPERTY(bool, m_zoomOnTouchDown, ZoomOnTouchDown); + CC_PROPERTY(CCPoint, m_labelAnchorPoint, LabelAnchorPoint); - /** The current title that is displayed on the button. */ - CC_SYNTHESIZE_READONLY(CCString*, m_currentTitle, CurrentTitle); - /** The current color used to display the title. */ - CC_SYNTHESIZE_READONLY_PASS_BY_REF(ccColor3B, m_currentTitleColor, CurrentTitleColor); - /** The current title label. */ - //CC_PROPERTY(CCNode*, m_titleLabel, TitleLabel); - CCNode* m_titleLabel; - /** The current background sprite. */ - //CC_PROPERTY(CCScale9Sprite*, m_backgroundSprite, BackgroundSprite); - CCScale9Sprite* m_backgroundSprite; - /* Override setter to affect a background sprite too */ - CC_PROPERTY(GLubyte, m_cOpacity, Opacity); + virtual GLubyte getOpacity(void); + virtual void setOpacity(GLubyte var); /** Flag to know if the button is currently pushed. */ - CC_SYNTHESIZE_READONLY(bool, pushed, IsPushed); +protected: + bool m_isPushed; + bool m_bParentInited; +public: + bool isPushed() { return m_isPushed; } + // - CCDictionary* m_titleDispatchTable; + CC_SYNTHESIZE_RETAIN(CCDictionary*, m_titleDispatchTable, TitleDispatchTable); // - CCDictionary* m_titleColorDispatchTable; + CC_SYNTHESIZE_RETAIN(CCDictionary*, m_titleColorDispatchTable, TitleColorDispatchTable); // - CCDictionary* m_titleLabelDispatchTable; + CC_SYNTHESIZE_RETAIN(CCDictionary*, m_titleLabelDispatchTable, TitleLabelDispatchTable); // - CCDictionary* m_backgroundSpriteDispatchTable; + CC_SYNTHESIZE_RETAIN(CCDictionary*, m_backgroundSpriteDispatchTable, BackgroundSpriteDispatchTable); /* Define the button margin for Top/Bottom edge */ CC_SYNTHESIZE_READONLY(int, m_marginV, VerticalMargin); diff --git a/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp b/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp index ec6cbd4303..b4381b4c50 100644 --- a/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp +++ b/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp @@ -35,6 +35,36 @@ NS_CC_EXT_BEGIN +CCControlColourPicker::CCControlColourPicker() +: m_colourPicker(NULL) +, m_huePicker(NULL) +, m_background(NULL) +{ + +} + +CCControlColourPicker::~CCControlColourPicker() +{ + if (m_background) + { + m_background->removeFromParentAndCleanup(true); + } + + if (m_huePicker) + { + m_huePicker->removeFromParentAndCleanup(true); + } + + if (m_colourPicker) + { + m_colourPicker->removeFromParentAndCleanup(true); + } + + m_background = NULL; + m_huePicker = NULL; + m_colourPicker = NULL; +} + bool CCControlColourPicker::init() { if (CCControl::init()) @@ -48,10 +78,10 @@ bool CCControlColourPicker::init() addChild(spriteSheet); // MIPMAP - ccTexParams params = {GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT}; +// ccTexParams params = {GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT}; spriteSheet->getTexture()->setAliasTexParameters(); - spriteSheet->getTexture()->setTexParameters(¶ms); - spriteSheet->getTexture()->generateMipmap(); +// spriteSheet->getTexture()->setTexParameters(¶ms); +// spriteSheet->getTexture()->generateMipmap(); // Init default color m_hsv.h = 0; @@ -63,12 +93,14 @@ bool CCControlColourPicker::init() CCPoint backgroundPointZero = ccpSub(m_background->getPosition(), ccp (m_background->getContentSize().width / 2, m_background->getContentSize().height / 2)); - // Setup panels . currently hard-coded... + // Setup panels float hueShift = 8; float colourShift = 28; - m_huePicker=CCControlHuePicker::create(spriteSheet, ccp(backgroundPointZero.x + hueShift, backgroundPointZero.y + hueShift)); - m_colourPicker=CCControlSaturationBrightnessPicker::create(spriteSheet, ccp(backgroundPointZero.x + colourShift, backgroundPointZero.y + colourShift)); + m_huePicker = new CCControlHuePicker(); + m_huePicker->initWithTargetAndPos(spriteSheet, ccp(backgroundPointZero.x + hueShift, backgroundPointZero.y + hueShift)); + m_colourPicker = new CCControlSaturationBrightnessPicker(); + m_colourPicker->initWithTargetAndPos(spriteSheet, ccp(backgroundPointZero.x + colourShift, backgroundPointZero.y + colourShift)); // Setup events m_huePicker->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlColourPicker::hueSliderValueChanged), CCControlEventValueChanged); @@ -101,20 +133,34 @@ CCControlColourPicker* CCControlColourPicker::create() } -void CCControlColourPicker::setColorValue(const ccColor3B& colorValue) +void CCControlColourPicker::setColor(const ccColor3B& color) { - m_colorValue = colorValue; + m_tColor = color; RGBA rgba; - rgba.r = colorValue.r / 255.0f; - rgba.g = colorValue.g / 255.0f; - rgba.b = colorValue.b / 255.0f; + rgba.r = color.r / 255.0f; + rgba.g = color.g / 255.0f; + rgba.b = color.b / 255.0f; rgba.a = 1.0f; m_hsv=CCControlUtils::HSVfromRGB(rgba); updateHueAndControlPicker(); } +void CCControlColourPicker::setEnabled(bool enabled) +{ + CCControl::setEnabled(enabled); + if (m_huePicker != NULL) + { + m_huePicker->setEnabled(enabled); + } + if (m_colourPicker) + { + m_colourPicker->setEnabled(enabled); + } +} + + //need two events to prevent an infinite loop! (can't update huePicker when the huePicker triggers the callback due to CCControlEventValueChanged) void CCControlColourPicker::updateControlPicker() { @@ -136,7 +182,7 @@ void CCControlColourPicker::hueSliderValueChanged(CCObject * sender, CCControlEv // Update the value RGBA rgb = CCControlUtils::RGBfromHSV(m_hsv); - m_colorValue= ccc3((GLubyte)(rgb.r * 255.0f), (GLubyte)(rgb.g * 255.0f), (GLubyte)(rgb.b * 255.0f)); + m_tColor= ccc3((GLubyte)(rgb.r * 255.0f), (GLubyte)(rgb.g * 255.0f), (GLubyte)(rgb.b * 255.0f)); // Send CCControl callback sendActionsForControlEvents(CCControlEventValueChanged); @@ -151,7 +197,7 @@ void CCControlColourPicker::colourSliderValueChanged(CCObject * sender, CCContro // Update the value RGBA rgb = CCControlUtils::RGBfromHSV(m_hsv); - m_colorValue=ccc3((GLubyte)(rgb.r * 255.0f), (GLubyte)(rgb.g * 255.0f), (GLubyte)(rgb.b * 255.0f)); + m_tColor=ccc3((GLubyte)(rgb.r * 255.0f), (GLubyte)(rgb.g * 255.0f), (GLubyte)(rgb.b * 255.0f)); // Send CCControl callback sendActionsForControlEvents(CCControlEventValueChanged); diff --git a/extensions/GUI/CCControlExtension/CCControlColourPicker.h b/extensions/GUI/CCControlExtension/CCControlColourPicker.h index 6f22b853bf..e8748d3977 100644 --- a/extensions/GUI/CCControlExtension/CCControlColourPicker.h +++ b/extensions/GUI/CCControlExtension/CCControlColourPicker.h @@ -48,15 +48,16 @@ NS_CC_EXT_BEGIN class CCControlColourPicker: public CCControl { - CC_SYNTHESIZE_READONLY_PASS_BY_REF(ccColor3B, m_colorValue, ColorValue); - virtual void setColorValue(const ccColor3B& colorValue); - +public: + CCControlColourPicker(); + virtual ~CCControlColourPicker(); + virtual void setColor(const ccColor3B& colorValue); + virtual void setEnabled(bool bEnabled); protected: HSV m_hsv; - CCControlSaturationBrightnessPicker* m_colourPicker; - CCControlHuePicker* m_huePicker; - - CC_SYNTHESIZE_READONLY(CCSprite*, m_background, Background); + CC_SYNTHESIZE_RETAIN(CCControlSaturationBrightnessPicker*, m_colourPicker, colourPicker) + CC_SYNTHESIZE_RETAIN(CCControlHuePicker*, m_huePicker, HuePicker) + CC_SYNTHESIZE_RETAIN(CCSprite*, m_background, Background) public: //@deprecated: This interface will be deprecated sooner or later. diff --git a/extensions/GUI/CCControlExtension/CCControlExtensions.h b/extensions/GUI/CCControlExtension/CCControlExtensions.h index f5766aac09..6b82369171 100644 --- a/extensions/GUI/CCControlExtension/CCControlExtensions.h +++ b/extensions/GUI/CCControlExtension/CCControlExtensions.h @@ -1,14 +1,13 @@ #ifndef __CCCONTROL_EXTENSIONS_H__ #define __CCCONTROL_EXTENSIONS_H__ -#include "CCControl.h" -#include "CCControlButton.h" -#include "CCControlColourPicker.h" -#include "CCControlHuePicker.h" -#include "CCControlSaturationBrightnessPicker.h" -#include "CCControlSlider.h" +#include "CCScale9Sprite.h" +#include "CCControl.h" +#include "CCControlButton.h" +#include "CCControlColourPicker.h" +#include "CCControlPotentiometer.h" +#include "CCControlSlider.h" +#include "CCControlStepper.h" #include "CCControlSwitch.h" -#include "CCMenuPassive.h" -#include "CCSpacer.h" #endif \ No newline at end of file diff --git a/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp b/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp index ddefa0b3ef..40c3e1417e 100644 --- a/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp +++ b/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp @@ -33,11 +33,22 @@ NS_CC_EXT_BEGIN -CCControlHuePicker::~CCControlHuePicker() +CCControlHuePicker::CCControlHuePicker() +: m_hue(0.0f) +, m_huePercentage(0.0f) +, m_background(NULL) +, m_slider(NULL) { } +CCControlHuePicker::~CCControlHuePicker() +{ + removeAllChildrenWithCleanup(true); + CC_SAFE_RELEASE(m_background); + CC_SAFE_RELEASE(m_slider); +} + CCControlHuePicker* CCControlHuePicker::pickerWithTargetAndPos(CCNode* target, CCPoint pos) { return CCControlHuePicker::create(target, pos); @@ -58,8 +69,8 @@ bool CCControlHuePicker::initWithTargetAndPos(CCNode* target, CCPoint pos) { setTouchEnabled(true); // Add background and slider sprites - m_background=CCControlUtils::addSpriteToTargetWithPosAndAnchor("huePickerBackground.png", target, pos, ccp(0.0f, 0.0f)); - m_slider=CCControlUtils::addSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, ccp(0.5f, 0.5f)); + this->setBackground(CCControlUtils::addSpriteToTargetWithPosAndAnchor("huePickerBackground.png", target, pos, ccp(0.0f, 0.0f))); + this->setSlider(CCControlUtils::addSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, ccp(0.5f, 0.5f))); m_slider->setPosition(ccp(pos.x, pos.y + m_background->boundingBox().size.height * 0.5f)); m_startPos=pos; @@ -70,13 +81,18 @@ bool CCControlHuePicker::initWithTargetAndPos(CCNode* target, CCPoint pos) return true; } else + { return false; + } } void CCControlHuePicker::setHue(float hueValue) { m_hue=hueValue; - setHuePercentage(m_hue/360.0f); + // Set the position of the slider to the correct hue + // We need to divide it by 360 as its taken as an angle in degrees + float huePercentage = hueValue / 360.0f; + setHuePercentage(huePercentage); } void CCControlHuePicker::setHuePercentage(float hueValueInPercent) @@ -105,6 +121,15 @@ void CCControlHuePicker::setHuePercentage(float hueValueInPercent) } +void CCControlHuePicker::setEnabled(bool enabled) +{ + CCControl::setEnabled(enabled); + if (m_slider != NULL) + { + m_slider->setOpacity(enabled ? 255 : 128); + } +} + void CCControlHuePicker::updateSliderPosition(CCPoint location) { @@ -132,17 +157,25 @@ void CCControlHuePicker::updateSliderPosition(CCPoint location) bool CCControlHuePicker::checkSliderPosition(CCPoint location) { - // check that the touch location is within the bounding rectangle before sending updates - if (m_background->boundingBox().containsPoint(location)) - { - updateSliderPosition(location); - return true; - } + // compute the distance between the current location and the center + double distance = sqrt(pow (location.x + 10, 2) + pow(location.y, 2)); + + // check that the touch location is within the circle + if (160 > distance && distance > 118) + { + updateSliderPosition(location); + return true; + } return false; } bool CCControlHuePicker::ccTouchBegan(CCTouch* touch, CCEvent* event) { + if (!isEnabled()) + { + return false; + } + // Get the touch location CCPoint touchLocation=getTouchLocation(touch); @@ -157,10 +190,10 @@ void CCControlHuePicker::ccTouchMoved(CCTouch* touch, CCEvent* event) CCPoint touchLocation=getTouchLocation(touch); //small modification: this allows changing of the colour, even if the touch leaves the bounding area - updateSliderPosition(touchLocation); - sendActionsForControlEvents(CCControlEventValueChanged); +// updateSliderPosition(touchLocation); +// sendActionsForControlEvents(CCControlEventValueChanged); // Check the touch position on the slider - //checkSliderPosition(touchLocation); + checkSliderPosition(touchLocation); } NS_CC_EXT_END diff --git a/extensions/GUI/CCControlExtension/CCControlHuePicker.h b/extensions/GUI/CCControlExtension/CCControlHuePicker.h index 7ba0600e81..eb30667715 100644 --- a/extensions/GUI/CCControlExtension/CCControlHuePicker.h +++ b/extensions/GUI/CCControlExtension/CCControlHuePicker.h @@ -54,16 +54,18 @@ class CCControlHuePicker : public CCControl //not sure if these need to be there actually. I suppose someone might want to access the sprite? - CC_SYNTHESIZE_READONLY(CCSprite*, m_background, Background); - CC_SYNTHESIZE_READONLY(CCSprite*, m_slider, Slider); + CC_SYNTHESIZE_RETAIN(CCSprite*, m_background, Background); + CC_SYNTHESIZE_RETAIN(CCSprite*, m_slider, Slider); CC_SYNTHESIZE_READONLY(CCPoint, m_startPos, StartPos); -public: +public: + CCControlHuePicker(); virtual ~CCControlHuePicker(); virtual bool initWithTargetAndPos(CCNode* target, CCPoint pos); //@deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCControlHuePicker* pickerWithTargetAndPos(CCNode* target, CCPoint pos); static CCControlHuePicker* create(CCNode* target, CCPoint pos); + virtual void setEnabled(bool enabled); protected: void updateSliderPosition(CCPoint location); bool checkSliderPosition(CCPoint location); diff --git a/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp b/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp new file mode 100644 index 0000000000..3de9af6b5c --- /dev/null +++ b/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp @@ -0,0 +1,266 @@ +/* + * CCControlPotentiometer.m + * + * Copyright 2012 Yannick Loriot. All rights reserved. + * http://yannickloriot.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#include "CCControlPotentiometer.h" +#include "cocos2d.h" + +NS_CC_EXT_BEGIN + +CCControlPotentiometer::CCControlPotentiometer() +: m_fValue(0.0f) +, m_fMinimumValue(0.0f) +, m_fMaximumValue(0.0f) +, m_pThumbSprite(NULL) +, m_pProgressTimer(NULL) +{ + +} + +CCControlPotentiometer::~CCControlPotentiometer() +{ + CC_SAFE_RELEASE(m_pThumbSprite); + CC_SAFE_RELEASE(m_pProgressTimer); +} + +CCControlPotentiometer* CCControlPotentiometer::create(const char* backgroundFile, const char* progressFile, const char* thumbFile) +{ + CCControlPotentiometer* pRet = new CCControlPotentiometer(); + if (pRet != NULL) + { + // Prepare track for potentiometer + CCSprite *backgroundSprite = CCSprite::create(backgroundFile); + + // Prepare thumb for potentiometer + CCSprite *thumbSprite = CCSprite::create(thumbFile); + + // Prepare progress for potentiometer + CCProgressTimer *progressTimer = CCProgressTimer::create(CCSprite::create(progressFile)); + //progressTimer.type = kCCProgressTimerTypeRadialCW; + if (pRet->initWithTrackSprite_ProgressTimer_ThumbSprite(backgroundSprite, progressTimer, thumbSprite)) + { + pRet->autorelease(); + } + else + { + CC_SAFE_DELETE(pRet); + } + } + return pRet; +} + +bool CCControlPotentiometer::initWithTrackSprite_ProgressTimer_ThumbSprite(CCSprite* trackSprite, CCProgressTimer* progressTimer, CCSprite* thumbSprite) +{ + if (CCControl::init()) + { + setTouchEnabled(true); + + setProgressTimer(progressTimer); + setThumbSprite(thumbSprite); + thumbSprite->setPosition(progressTimer->getPosition()); + + addChild(thumbSprite, 2); + addChild(progressTimer, 1); + addChild(trackSprite); + + setContentSize(trackSprite->getContentSize()); + + // Init default values + m_fMinimumValue = 0.0f; + m_fMaximumValue = 1.0f; + setValue(m_fMinimumValue); + return true; + } + return false; +} + +void CCControlPotentiometer::setEnabled(bool enabled) +{ + CCControl::setEnabled(enabled); + if (m_pThumbSprite != NULL) + { + m_pThumbSprite->setOpacity((enabled) ? 255 : 128); + } +} + +void CCControlPotentiometer::setValue(float value) +{ + // set new value with sentinel + if (value < m_fMinimumValue) + { + value = m_fMinimumValue; + } + + if (value > m_fMaximumValue) + { + value = m_fMaximumValue; + } + + m_fValue = value; + + // Update thumb and progress position for new value + float percent = (value - m_fMinimumValue) / (m_fMaximumValue - m_fMinimumValue); + m_pProgressTimer->setPercentage(percent * 100.0f); + m_pThumbSprite->setRotation(percent * 360.0f); + + sendActionsForControlEvents(CCControlEventValueChanged); +} + +float CCControlPotentiometer::getValue() +{ + return m_fValue; +} + +void CCControlPotentiometer::setMinimumValue(float minimumValue) +{ + m_fMinimumValue = minimumValue; + + if (m_fMinimumValue >= m_fMaximumValue) + { + m_fMaximumValue = m_fMinimumValue + 1.0f; + } + + setValue(m_fMaximumValue); +} + +float CCControlPotentiometer::getMinimumValue() +{ + return m_fMinimumValue; +} + +void CCControlPotentiometer::setMaximumValue(float maximumValue) +{ + m_fMaximumValue = maximumValue; + + if (m_fMaximumValue <= m_fMinimumValue) + { + m_fMinimumValue = m_fMaximumValue - 1.0f; + } + + setValue(m_fMinimumValue); +} + +float CCControlPotentiometer::getMaximumValue() +{ + return m_fMaximumValue; +} + +bool CCControlPotentiometer::isTouchInside(CCTouch * touch) +{ + CCPoint touchLocation = this->getTouchLocation(touch); + + float distance = this->distanceBetweenPointAndPoint(m_pProgressTimer->getPosition(), touchLocation); + + return distance < MIN(getContentSize().width / 2, getContentSize().height / 2); +} + +bool CCControlPotentiometer::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) +{ + if (!this->isTouchInside(pTouch) + || !this->isEnabled()) + { + return false; + } + + m_tPreviousLocation = this->getTouchLocation(pTouch); + + this->potentiometerBegan(m_tPreviousLocation); + + return true; +} + +void CCControlPotentiometer::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent) +{ + CCPoint location = this->getTouchLocation(pTouch); + + this->potentiometerMoved(location); +} + +void CCControlPotentiometer::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent) +{ + this->potentiometerEnded(CCPointZero); +} + +float CCControlPotentiometer::distanceBetweenPointAndPoint(CCPoint point1, CCPoint point2) +{ + float dx = point1.x - point2.x; + float dy = point1.y - point2.y; + return sqrt(dx*dx + dy*dy); +} + +float CCControlPotentiometer::angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint( + CCPoint beginLineA, + CCPoint endLineA, + CCPoint beginLineB, + CCPoint endLineB) +{ + float a = endLineA.x - beginLineA.x; + float b = endLineA.y - beginLineA.y; + float c = endLineB.x - beginLineB.x; + float d = endLineB.y - beginLineB.y; + + float atanA = atan2(a, b); + float atanB = atan2(c, d); + + // convert radiants to degrees + return (atanA - atanB) * 180 / M_PI; +} + +void CCControlPotentiometer::potentiometerBegan(CCPoint location) +{ + setSelected(true); + getThumbSprite()->setColor(ccGRAY); +} + +void CCControlPotentiometer::potentiometerMoved(CCPoint location) +{ + float angle = this->angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint( + m_pProgressTimer->getPosition(), + location, + m_pProgressTimer->getPosition(), + m_tPreviousLocation); + + // fix value, if the 12 o'clock position is between location and previousLocation + if (angle > 180) + { + angle -= 360; + } + else if (angle < -180) + { + angle += 360; + } + + setValue(m_fValue + angle / 360.0f * (m_fMaximumValue - m_fMinimumValue)); + + m_tPreviousLocation = location; +} + +void CCControlPotentiometer::potentiometerEnded(CCPoint location) +{ + getThumbSprite()->setColor(ccWHITE); + setSelected(false); +} + +NS_CC_EXT_END diff --git a/extensions/GUI/CCControlExtension/CCControlPotentiometer.h b/extensions/GUI/CCControlExtension/CCControlPotentiometer.h new file mode 100644 index 0000000000..728cce127d --- /dev/null +++ b/extensions/GUI/CCControlExtension/CCControlPotentiometer.h @@ -0,0 +1,109 @@ +/* + * CCControlPotentiometer.h + * + * Copyright 2012 Yannick Loriot. All rights reserved. + * http://yannickloriot.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ +#ifndef __CCCONTROLPOTENTIOMETER_H__ +#define __CCCONTROLPOTENTIOMETER_H__ + +#include "CCControl.h" + +NS_CC_EXT_BEGIN + +/** + * @addtogroup GUI + * @{ + * @addtogroup control_extension + * @{ + */ + +/** @class CCControlPotentiometer Potentiometer control for Cocos2D. */ +class CCControlPotentiometer : public CCControl +{ +public: + CCControlPotentiometer(); + virtual ~CCControlPotentiometer(); + /** + * Creates potentiometer with a track filename and a progress filename. + */ + static CCControlPotentiometer* create(const char* backgroundFile, const char* progressFile, const char* thumbFile); + + /** + * Initializes a potentiometer with a track sprite and a progress bar. + * + * @param trackSprite CCSprite, that is used as a background. + * @param progressSprite CCProgressTimer, that is used as a progress bar. + */ + bool initWithTrackSprite_ProgressTimer_ThumbSprite(CCSprite* trackSprite, CCProgressTimer* progressTimer, CCSprite* thumbSprite); + void setValue(float value); + float getValue(); + + void setMinimumValue(float minimumValue); + float getMinimumValue(); + + void setMaximumValue(float maximumValue); + float getMaximumValue(); + + void setEnabled(bool enabled); + + virtual bool isTouchInside(CCTouch * touch); + + virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent); + virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent); + virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent); + +protected: + CC_SYNTHESIZE_RETAIN(CCSprite*, m_pThumbSprite, ThumbSprite) + CC_SYNTHESIZE_RETAIN(CCProgressTimer*, m_pProgressTimer, ProgressTimer) + CC_SYNTHESIZE(CCPoint, m_tPreviousLocation, PreviousLocation) + /** Contains the receiver’s current value. */ + float m_fValue; + /** Contains the minimum value of the receiver. + * The default value of this property is 0.0. */ + float m_fMinimumValue; + /** Contains the maximum value of the receiver. + * The default value of this property is 1.0. */ + float m_fMaximumValue; + /** Factorize the event dispath into these methods. */ + void potentiometerBegan(CCPoint location); + void potentiometerMoved(CCPoint location); + void potentiometerEnded(CCPoint location); + + /** Returns the distance between the point1 and point2. */ + float distanceBetweenPointAndPoint(CCPoint point1, CCPoint point2); + /** Returns the angle in degree between line1 and line2. */ + float angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint( + CCPoint beginLineA, + CCPoint endLineA, + CCPoint beginLineB, + CCPoint endLineB); + +}; + +// end of GUI group +/// @} +/// @} + +NS_CC_EXT_END + +#endif /* __CCCONTROLPOTENTIOMETER_H__ */ diff --git a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp index 2586f89b96..3e3d42034c 100644 --- a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp @@ -33,10 +33,28 @@ NS_CC_EXT_BEGIN -CCControlSaturationBrightnessPicker::~CCControlSaturationBrightnessPicker() +CCControlSaturationBrightnessPicker::CCControlSaturationBrightnessPicker() +: m_saturation(0.0f) +, m_brightness(0.0f) +, m_background(NULL) +, m_overlay(NULL) +, m_shadow(NULL) +, m_slider(NULL) +, boxPos(0) +, boxSize(0) { } + +CCControlSaturationBrightnessPicker::~CCControlSaturationBrightnessPicker() +{ + removeAllChildrenWithCleanup(true); + + m_background = NULL; + m_overlay = NULL; + m_shadow = NULL; + m_slider = NULL; +} bool CCControlSaturationBrightnessPicker::initWithTargetAndPos(CCNode* target, CCPoint pos) { @@ -51,11 +69,13 @@ bool CCControlSaturationBrightnessPicker::initWithTargetAndPos(CCNode* target, C m_startPos=pos; // starting position of the colour picker boxPos = 35; // starting position of the virtual box area for picking a colour - boxSize = 150; // the size (width and height) of the virtual box for picking a colour from + boxSize = m_background->getContentSize().width / 2;; // the size (width and height) of the virtual box for picking a colour from return true; } else + { return false; + } } CCControlSaturationBrightnessPicker* CCControlSaturationBrightnessPicker::pickerWithTargetAndPos(CCNode* target, CCPoint pos) @@ -71,7 +91,14 @@ CCControlSaturationBrightnessPicker* CCControlSaturationBrightnessPicker::create return pRet; } - +void CCControlSaturationBrightnessPicker::setEnabled(bool enabled) +{ + CCControl::setEnabled(enabled); + if (m_slider != NULL) + { + m_slider->setOpacity(enabled ? 255 : 128); + } +} void CCControlSaturationBrightnessPicker::updateWithHSV(HSV hsv) { @@ -149,7 +176,7 @@ bool CCControlSaturationBrightnessPicker::checkSliderPosition(CCPoint location) float dist = sqrtf(dx*dx+dy*dy); // check that the touch location is within the bounding rectangle before sending updates - if (dist <= m_background->boundingBox().size.width*.5) + if (dist <= m_background->boundingBox().size.width*0.5f) { updateSliderPosition(location); sendActionsForControlEvents(CCControlEventValueChanged); @@ -161,6 +188,11 @@ bool CCControlSaturationBrightnessPicker::checkSliderPosition(CCPoint location) bool CCControlSaturationBrightnessPicker::ccTouchBegan(CCTouch* touch, CCEvent* event) { + if (!isEnabled()) + { + return false; + } + // Get the touch location CCPoint touchLocation=getTouchLocation(touch); @@ -175,10 +207,10 @@ void CCControlSaturationBrightnessPicker::ccTouchMoved(CCTouch* touch, CCEvent* CCPoint touchLocation=getTouchLocation(touch); //small modification: this allows changing of the colour, even if the touch leaves the bounding area - updateSliderPosition(touchLocation); - sendActionsForControlEvents(CCControlEventValueChanged); +// updateSliderPosition(touchLocation); +// sendActionsForControlEvents(CCControlEventValueChanged); // Check the touch position on the slider - //checkSliderPosition(touchLocation); + checkSliderPosition(touchLocation); } NS_CC_EXT_END diff --git a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h index ece5856f38..038e3512e4 100644 --- a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h +++ b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h @@ -46,7 +46,9 @@ NS_CC_EXT_BEGIN class CCControlSaturationBrightnessPicker : public CCControl { + /** Contains the receivers current saturation value. */ CC_SYNTHESIZE_READONLY(float, m_saturation, Saturation); + /** Contains the receivers current brightness value. */ CC_SYNTHESIZE_READONLY(float, m_brightness, Brightness); //not sure if these need to be there actually. I suppose someone might want to access the sprite? @@ -61,12 +63,15 @@ protected: int boxSize; public: + CCControlSaturationBrightnessPicker(); virtual ~CCControlSaturationBrightnessPicker(); virtual bool initWithTargetAndPos(CCNode* target, CCPoint pos); //@deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCControlSaturationBrightnessPicker* pickerWithTargetAndPos(CCNode* target, CCPoint pos); static CCControlSaturationBrightnessPicker* create(CCNode* target, CCPoint pos); + + virtual void setEnabled(bool enabled); virtual void updateWithHSV(HSV hsv); virtual void updateDraggerWithHSV(HSV hsv); diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.cpp b/extensions/GUI/CCControlExtension/CCControlSlider.cpp index 18a7bc28c4..dc17712299 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSlider.cpp @@ -33,11 +33,26 @@ NS_CC_EXT_BEGIN -CCControlSlider::~CCControlSlider() +CCControlSlider::CCControlSlider() +: m_value(0.0f) +, m_minimumValue(0.0f) +, m_maximumValue(0.0f) +, m_minimumAllowedValue(0.0f) +, m_maximumAllowedValue(0.0f) +, m_thumbSprite(NULL) +, m_progressSprite(NULL) +, m_backgroundSprite(NULL) { } +CCControlSlider::~CCControlSlider() +{ + CC_SAFE_RELEASE(m_thumbSprite); + CC_SAFE_RELEASE(m_progressSprite); + CC_SAFE_RELEASE(m_backgroundSprite); +} + CCControlSlider* CCControlSlider::sliderWithFiles(const char* bgFile, const char* progressFile, const char* thumbFile) { return CCControlSlider::create(bgFile, progressFile, thumbFile); @@ -52,62 +67,62 @@ CCControlSlider* CCControlSlider::create(const char* bgFile, const char* progres CCSprite *progressSprite = CCSprite::create(progressFile); // Prepare thumb (menuItem) for slider - CCSprite *thumbNormal = CCSprite::create(thumbFile); - CCSprite *thumbSelected = CCSprite::create(thumbFile); - thumbSelected->setColor(ccGRAY); + CCSprite *thumbSprite = CCSprite::create(thumbFile); - CCMenuItemSprite* thumbMenuItem =CCMenuItemSprite::create(thumbNormal, thumbSelected); - - return CCControlSlider::create(backgroundSprite, progressSprite, thumbMenuItem); + return CCControlSlider::create(backgroundSprite, progressSprite, thumbSprite); } -CCControlSlider* CCControlSlider::sliderWithSprites(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCMenuItem* thumbItem) +CCControlSlider* CCControlSlider::sliderWithSprites(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCSprite* thumbSprite) { - return CCControlSlider::create(backgroundSprite, pogressSprite, thumbItem); + return CCControlSlider::create(backgroundSprite, pogressSprite, thumbSprite); } -CCControlSlider* CCControlSlider::create(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCMenuItem* thumbItem) +CCControlSlider* CCControlSlider::create(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCSprite* thumbSprite) { CCControlSlider *pRet = new CCControlSlider(); - pRet->initWithSprites(backgroundSprite, pogressSprite, thumbItem); + pRet->initWithSprites(backgroundSprite, pogressSprite, thumbSprite); pRet->autorelease(); return pRet; } - bool CCControlSlider::initWithSprites(CCSprite * backgroundSprite, CCSprite* progessSprite, CCMenuItem* thumbItem) + bool CCControlSlider::initWithSprites(CCSprite * backgroundSprite, CCSprite* progressSprite, CCSprite* thumbSprite) { if (CCControl::init()) { + CCAssert(backgroundSprite, "Background sprite must be not nil"); + CCAssert(progressSprite, "Progress sprite must be not nil"); + CCAssert(thumbSprite, "Thumb sprite must be not nil"); + ignoreAnchorPointForPosition(false); setTouchEnabled(true); - m_backgroundSprite=backgroundSprite; - m_progressSprite=progessSprite; - m_thumbItem=thumbItem; + this->setBackgroundSprite(backgroundSprite); + this->setProgressSprite(progressSprite); + this->setThumbSprite(thumbSprite); // Defines the content size - CCRect maxRect = CCControlUtils::CCRectUnion(backgroundSprite->boundingBox(), thumbItem->boundingBox()); - CCSize size=CCSizeMake(maxRect.size.width+2*SLIDER_MARGIN_H, maxRect.size.height+2*SLIDER_MARGIN_V); - setContentSize(size); - //setContentSize(CCSizeMake(backgroundSprite->getContentSize().width, thumbItem->getContentSize().height)); + CCRect maxRect = CCControlUtils::CCRectUnion(backgroundSprite->boundingBox(), thumbSprite->boundingBox()); + + setContentSize(CCSizeMake(maxRect.size.width, maxRect.size.height)); + // Add the slider background m_backgroundSprite->setAnchorPoint(ccp(0.5f, 0.5f)); - m_backgroundSprite->setPosition(ccp(size.width / 2, size.height / 2)); + m_backgroundSprite->setPosition(ccp(this->getContentSize().width / 2, this->getContentSize().height / 2)); addChild(m_backgroundSprite); // Add the progress bar m_progressSprite->setAnchorPoint(ccp(0.0f, 0.5f)); - m_progressSprite->setPosition(ccp(0.0f+SLIDER_MARGIN_H, size.height / 2)); + m_progressSprite->setPosition(ccp(0.0f, this->getContentSize().height / 2)); addChild(m_progressSprite); // Add the slider thumb - m_thumbItem->setPosition(ccp(0+SLIDER_MARGIN_H, size.height / 2)); - addChild(m_thumbItem); + m_thumbSprite->setPosition(ccp(0.0f, this->getContentSize().height / 2)); + addChild(m_thumbSprite); // Init default values m_minimumValue = 0.0f; m_maximumValue = 1.0f; - m_snappingInterval=-1.0f; + setValue(m_minimumValue); return true; } @@ -118,32 +133,33 @@ CCControlSlider* CCControlSlider::create(CCSprite * backgroundSprite, CCSprite* } +void CCControlSlider::setEnabled(bool enabled) +{ + CCControl::setEnabled(enabled); + if (m_thumbSprite != NULL) + { + m_thumbSprite->setOpacity((enabled) ? 255 : 128); + } +} + void CCControlSlider::setValue(float value) { - //clamp between the two bounds - value=MAX(value, m_minimumValue); - value=MIN(value, m_maximumValue); - - //if we're snapping - if (m_snappingInterval>=0) - { - //int nTotal=(int)(ceil(m_maximumValue-m_minimumValue)/m_snappingInterval); - //floor (n + 0.5f) == round(n) - value=floor(0.5f + value/m_snappingInterval)*m_snappingInterval; - } - m_value=value; - - // Update thumb position for new value - float percent = (m_value - m_minimumValue) / (m_maximumValue - m_minimumValue); - CCPoint pos= m_thumbItem->getPosition(); - pos.x = percent * m_backgroundSprite->getContentSize().width+SLIDER_MARGIN_H; - m_thumbItem->setPosition(pos); - - // Stretches content proportional to newLevel - CCRect textureRect = m_progressSprite->getTextureRect(); - textureRect = CCRectMake(textureRect.origin.x, textureRect.origin.y, percent * m_backgroundSprite->getContentSize().width, textureRect.size.height); - m_progressSprite->setTextureRect(textureRect, m_progressSprite->isTextureRectRotated(), textureRect.size); - sendActionsForControlEvents(CCControlEventValueChanged); + // set new value with sentinel + if (value < m_minimumValue) + { + value = m_minimumValue; + } + + if (value > m_maximumValue) + { + value = m_maximumValue; + } + + m_value = value; + + this->needsLayout(); + + this->sendActionsForControlEvents(CCControlEventValueChanged); } void CCControlSlider::setMinimumValue(float minimumValue) @@ -151,61 +167,96 @@ CCControlSlider* CCControlSlider::create(CCSprite * backgroundSprite, CCSprite* m_minimumValue=minimumValue; m_minimumAllowedValue = minimumValue; if (m_minimumValue >= m_maximumValue) + { m_maximumValue = m_minimumValue + 1.0f; + } setValue(m_value); } - void CCControlSlider::setMaximumValue(float maximumValue) + void CCControlSlider::setMaximumValue(float maximumValue) { m_maximumValue=maximumValue; m_maximumAllowedValue = maximumValue; - if (m_maximumValue <= m_minimumValue) + if (m_maximumValue <= m_minimumValue) + { m_minimumValue = m_maximumValue - 1.0f; + } setValue(m_value); } + +bool CCControlSlider::isTouchInside(CCTouch * touch) +{ + CCPoint touchLocation = touch->getLocation(); + touchLocation = this->getParent()->convertToNodeSpace(touchLocation); + + CCRect rect = this->boundingBox(); + rect.size.width += m_thumbSprite->getContentSize().width; + rect.origin.x -= m_thumbSprite->getContentSize().width / 2; + + return rect.containsPoint(touchLocation); +} + +CCPoint CCControlSlider::locationFromTouch(CCTouch* touch) +{ + CCPoint touchLocation = touch->getLocation(); // Get the touch position + touchLocation = this->convertToNodeSpace(touchLocation); // Convert to the node space of this class + + if (touchLocation.x < 0) + { + touchLocation.x = 0; + } else if (touchLocation.x > m_backgroundSprite->getContentSize().width) + { + touchLocation.x = m_backgroundSprite->getContentSize().width; + } + + return touchLocation; +} - //this is the same as CCControl::getTouchLocation, but it returns the position relative to the position of this control - CCPoint CCControlSlider::getTouchLocationInControl(CCTouch* touch) + +bool CCControlSlider::ccTouchBegan(CCTouch* touch, CCEvent* pEvent) { - CCPoint touchLocation = touch->getLocation();; // Get the touch position - touchLocation = convertToNodeSpace(touchLocation); // Convert to the node space of this class - - if (touchLocation.x < 0) - { - touchLocation.x = 0; - } - else if (touchLocation.x > m_backgroundSprite->getContentSize().width+SLIDER_MARGIN_H) - { - touchLocation.x = m_backgroundSprite->getContentSize().width+SLIDER_MARGIN_H; - } - return touchLocation; -} - - bool CCControlSlider::ccTouchBegan(CCTouch* touch, CCEvent* pEvent) - { - if (!isTouchInside(touch)) + if (!isTouchInside(touch) || !isEnabled()) return false; - CCPoint location = getTouchLocationInControl(touch); + CCPoint location = locationFromTouch(touch); sliderBegan(location); return true; } void CCControlSlider::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent) { - CCPoint location = getTouchLocationInControl(pTouch); + CCPoint location = locationFromTouch(pTouch); sliderMoved(location); } void CCControlSlider::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent) { - CCPoint location = getTouchLocationInControl(pTouch); sliderEnded(CCPointZero); } +void CCControlSlider::needsLayout() +{ + if (NULL == m_thumbSprite || NULL == m_backgroundSprite || NULL == m_progressSprite) + { + return; + } + // Update thumb position for new value + float percent = (m_value - m_minimumValue) / (m_maximumValue - m_minimumValue); + + CCPoint pos = m_thumbSprite->getPosition(); + pos.x = percent * m_backgroundSprite->getContentSize().width; + m_thumbSprite->setPosition(pos); + + // Stretches content proportional to newLevel + CCRect textureRect = m_progressSprite->getTextureRect(); + textureRect = CCRectMake(textureRect.origin.x, textureRect.origin.y, pos.x, textureRect.size.height); + m_progressSprite->setTextureRect(textureRect, m_progressSprite->isTextureRectRotated(), textureRect.size); +} + void CCControlSlider::sliderBegan(CCPoint location) { - m_thumbItem->selected(); + this->setSelected(true); + this->getThumbSprite()->setColor(ccGRAY); setValue(valueForLocation(location)); } @@ -216,16 +267,17 @@ void CCControlSlider::sliderMoved(CCPoint location) void CCControlSlider::sliderEnded(CCPoint location) { - if (m_thumbItem->isSelected()) + if (this->isSelected()) { - m_thumbItem->unselected(); - setValue(valueForLocation(m_thumbItem->getPosition())); + setValue(valueForLocation(m_thumbSprite->getPosition())); } + this->getThumbSprite()->setColor(ccWHITE); + this->setSelected(false); } float CCControlSlider::valueForLocation(CCPoint location) { - float percent = (location.x-SLIDER_MARGIN_H)/ m_backgroundSprite->getContentSize().width; + float percent = location.x/ m_backgroundSprite->getContentSize().width; return MAX(MIN(m_minimumValue + percent * (m_maximumValue - m_minimumValue), m_maximumAllowedValue), m_minimumAllowedValue); } diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.h b/extensions/GUI/CCControlExtension/CCControlSlider.h index 407c2b41ec..cebf5d580e 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.h +++ b/extensions/GUI/CCControlExtension/CCControlSlider.h @@ -31,11 +31,6 @@ #include "CCControl.h" #include "CCInvocation.h" -#include "sprite_nodes/CCSprite.h" -#include "menu_nodes/CCMenuItem.h" - -#define SLIDER_MARGIN_H 24 -#define SLIDER_MARGIN_V 8 NS_CC_EXT_BEGIN @@ -49,27 +44,31 @@ NS_CC_EXT_BEGIN class CCControlSlider: public CCControl { //maunally put in the setters + /** Contains the receivers current value. */ CC_SYNTHESIZE_READONLY(float, m_value, Value); virtual void setValue(float val); + /** Contains the minimum value of the receiver. + * The default value of this property is 0.0. */ CC_SYNTHESIZE_READONLY(float, m_minimumValue, MinimumValue); virtual void setMinimumValue(float val); + /** Contains the maximum value of the receiver. + * The default value of this property is 1.0. */ CC_SYNTHESIZE_READONLY(float, m_maximumValue, MaximumValue); virtual void setMaximumValue(float val); - + virtual void setEnabled(bool enabled); + virtual bool isTouchInside(CCTouch * touch); + CCPoint locationFromTouch(CCTouch* touch); + CC_SYNTHESIZE(float, m_minimumAllowedValue, MinimumAllowedValue); CC_SYNTHESIZE(float, m_maximumAllowedValue, MaximumAllowedValue); - - - //interval to snap to - CC_SYNTHESIZE(float, m_snappingInterval, SnappingInterval); // maybe this should be read-only - CC_SYNTHESIZE_READONLY(CCMenuItem*, m_thumbItem, ThumbItem); - CC_SYNTHESIZE_READONLY(CCSprite*, m_progressSprite, ProgressSprite); - CC_SYNTHESIZE_READONLY(CCSprite*, m_backgroundSprite, BackgroundSprite); + CC_SYNTHESIZE_RETAIN(CCSprite*, m_thumbSprite, ThumbSprite); + CC_SYNTHESIZE_RETAIN(CCSprite*, m_progressSprite, ProgressSprite); + CC_SYNTHESIZE_RETAIN(CCSprite*, m_backgroundSprite, BackgroundSprite); public: - + CCControlSlider(); virtual ~CCControlSlider(); /** @@ -78,9 +77,9 @@ public: * * @param backgroundSprite CCSprite, that is used as a background. * @param progressSprite CCSprite, that is used as a progress bar. - * @param thumbItem CCMenuItem, that is used as a thumb. + * @param thumbItem CCSprite, that is used as a thumb. */ - virtual bool initWithSprites(CCSprite * backgroundSprite, CCSprite* progessSprite, CCMenuItem* thumbItem); + virtual bool initWithSprites(CCSprite * backgroundSprite, CCSprite* progressSprite, CCSprite* thumbSprite); /** @@ -96,7 +95,7 @@ public: *@deprecated: This interface will be deprecated sooner or later. * @see initWithBackgroundSprite:progressSprite:thumbMenuItem: */ - CC_DEPRECATED_ATTRIBUTE static CCControlSlider* sliderWithSprites(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCMenuItem* thumbItem); + CC_DEPRECATED_ATTRIBUTE static CCControlSlider* sliderWithSprites(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCSprite* thumbSprite); /** @@ -111,22 +110,18 @@ public: * * @see initWithBackgroundSprite:progressSprite:thumbMenuItem: */ - static CCControlSlider* create(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCMenuItem* thumbItem); - + static CCControlSlider* create(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCSprite* thumbSprite); + virtual void needsLayout(); protected: void sliderBegan(CCPoint location); void sliderMoved(CCPoint location); void sliderEnded(CCPoint location); - virtual CCPoint getTouchLocationInControl(CCTouch* touch); - virtual bool ccTouchBegan(CCTouch* touch, CCEvent* pEvent); virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent); virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent); - - /** Returns the value for the given location. */ float valueForLocation(CCPoint location); }; diff --git a/extensions/GUI/CCControlExtension/CCControlStepper.cpp b/extensions/GUI/CCControlExtension/CCControlStepper.cpp new file mode 100644 index 0000000000..bcc0828799 --- /dev/null +++ b/extensions/GUI/CCControlExtension/CCControlStepper.cpp @@ -0,0 +1,347 @@ +/* + * CCControlStepper.m + * + * Copyright 2012 Yannick Loriot. All rights reserved. + * http://yannickloriot.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT falseT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND falseNINFRINGEMENT. IN false EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#include "CCControlStepper.h" + +NS_CC_EXT_BEGIN + +#define CCControlStepperLabelColorEnabled ccc3(55, 55, 55) +#define CCControlStepperLabelColorDisabled ccc3(147, 147, 147) + +#define CCControlStepperLabelFont "CourierNewPSMT" + + +#define kAutorepeatDeltaTime 0.15f +#define kAutorepeatIncreaseTimeIncrement 12 + +CCControlStepper::CCControlStepper() +: m_dValue(0.0) +, m_bContinuous(false) +, m_bAutorepeat(false) +, m_bWraps(false) +, m_dMinimumValue(0.0) +, m_dMaximumValue(0.0) +, m_dStepValue(0.0) +, m_pMinusSprite(NULL) +, m_pPlusSprite(NULL) +, m_pMinusLabel(NULL) +, m_pPlusLabel(NULL) +, m_bTouchInsideFlag(false) +, m_eTouchedPart(kCCControlStepperPartNone) +, m_nAutorepeatCount(0) +{ + +} + +CCControlStepper::~CCControlStepper() +{ + unscheduleAllSelectors(); + + CC_SAFE_RELEASE(m_pMinusSprite); + CC_SAFE_RELEASE(m_pPlusSprite); + CC_SAFE_RELEASE(m_pMinusLabel); + CC_SAFE_RELEASE(m_pPlusLabel); +} + +bool CCControlStepper::initWithMinusSpriteAndPlusSprite(CCSprite *minusSprite, CCSprite *plusSprite) +{ + if (CCControl::init()) + { + CCAssert(minusSprite, "Minus sprite must be not nil"); + CCAssert(plusSprite, "Plus sprite must be not nil"); + + setTouchEnabled(true); + + // Set the default values + m_bAutorepeat = true; + m_bContinuous = true; + m_dMinimumValue = 0; + m_dMaximumValue = 100; + m_dValue = 0; + m_dStepValue = 1; + m_bWraps = false; + this->ignoreAnchorPointForPosition( false ); + + // Add the minus components + this->setMinusSprite(minusSprite); + m_pMinusSprite->setPosition( ccp(minusSprite->getContentSize().width / 2, minusSprite->getContentSize().height / 2) ); + this->addChild(m_pMinusSprite); + + this->setMinusLabel( CCLabelTTF::create("-", CCControlStepperLabelFont, 40)); + m_pMinusLabel->setColor(CCControlStepperLabelColorDisabled); + m_pMinusLabel->setPosition(CCPointMake(m_pMinusSprite->getContentSize().width / 2, m_pMinusSprite->getContentSize().height / 2) ); + m_pMinusSprite->addChild(m_pMinusLabel); + + // Add the plus components + this->setPlusSprite( plusSprite ); + m_pPlusSprite->setPosition( ccp(minusSprite->getContentSize().width + plusSprite->getContentSize().width / 2, + minusSprite->getContentSize().height / 2) ); + this->addChild(m_pPlusSprite); + + this->setPlusLabel( CCLabelTTF::create("+", CCControlStepperLabelFont, 40 )); + m_pPlusLabel->setColor( CCControlStepperLabelColorEnabled ); + m_pPlusLabel->setPosition( CCPointMake(m_pPlusSprite->getContentSize().width / 2, m_pPlusSprite->getContentSize().height / 2) ); + m_pPlusSprite->addChild(m_pPlusLabel); + + // Defines the content size + CCRect maxRect = CCControlUtils::CCRectUnion(m_pMinusSprite->boundingBox(), m_pPlusSprite->boundingBox()); + this->setContentSize( CCSizeMake(m_pMinusSprite->getContentSize().width + m_pPlusSprite->getContentSize().height, maxRect.size.height) ); + return true; + } + return false; +} + +CCControlStepper* CCControlStepper::create(CCSprite *minusSprite, CCSprite *plusSprite) +{ + CCControlStepper* pRet = new CCControlStepper(); + if (pRet != NULL && pRet->initWithMinusSpriteAndPlusSprite(minusSprite, plusSprite)) + { + pRet->autorelease(); + } + else + { + CC_SAFE_DELETE(pRet); + } + return pRet; +} + +//#pragma mark Properties + +void CCControlStepper::setWraps(bool wraps) +{ + m_bWraps = wraps; + + if (m_bWraps) + { + m_pMinusLabel->setColor( CCControlStepperLabelColorEnabled ); + m_pPlusLabel->setColor(CCControlStepperLabelColorEnabled ); + } + + this->setValue( m_dValue ); +} + +void CCControlStepper::setMinimumValue(double minimumValue) +{ + if (minimumValue >= m_dMaximumValue) + { + CCAssert(0, "Must be numerically less than maximumValue."); + } + + m_dMinimumValue = minimumValue; + this->setValue( m_dValue ); +} + +void CCControlStepper::setMaximumValue(double maximumValue) +{ + if (maximumValue <= m_dMinimumValue) + { + CCAssert(0, "Must be numerically greater than minimumValue."); + } + + m_dMaximumValue = maximumValue; + this->setValue(m_dValue); +} + +void CCControlStepper::setValue(double value) +{ + this->setValueWithSendingEvent(value, true); +} + +double CCControlStepper::getValue() +{ + return m_dValue; +} + +void CCControlStepper::setStepValue(double stepValue) +{ + if (stepValue <= 0) + { + CCAssert(0,"Must be numerically greater than 0."); + } + + m_dStepValue = stepValue; +} + +bool CCControlStepper::isContinuous() +{ + return m_bContinuous; +} +//#pragma mark - +//#pragma mark CCControlStepper Public Methods + +void CCControlStepper::setValueWithSendingEvent(double value, bool send) +{ + if (value < m_dMinimumValue) + { + value = m_bWraps ? m_dMaximumValue : m_dMinimumValue; + } else if (value > m_dMaximumValue) + { + value = m_bWraps ? m_dMinimumValue : m_dMaximumValue; + } + + m_dValue = value; + + if (!m_bWraps) + { + m_pMinusLabel->setColor((value == m_dMinimumValue) ? CCControlStepperLabelColorDisabled : CCControlStepperLabelColorEnabled); + m_pPlusLabel->setColor((value == m_dMaximumValue) ? CCControlStepperLabelColorDisabled : CCControlStepperLabelColorEnabled); + } + + if (send) + { + this->sendActionsForControlEvents(CCControlEventValueChanged); + } +} + +void CCControlStepper::startAutorepeat() +{ + m_nAutorepeatCount = -1; + + this->schedule(schedule_selector(CCControlStepper::update), kAutorepeatDeltaTime, kCCRepeatForever, kAutorepeatDeltaTime * 3); +} + +/** Stop the autorepeat. */ +void CCControlStepper::stopAutorepeat() +{ + this->unschedule(schedule_selector(CCControlStepper::update)); +} + +void CCControlStepper::update(float dt) +{ + m_nAutorepeatCount++; + + if ((m_nAutorepeatCount < kAutorepeatIncreaseTimeIncrement) && (m_nAutorepeatCount % 3) != 0) + return; + + if (m_eTouchedPart == kCCControlStepperPartMinus) + { + this->setValueWithSendingEvent(m_dValue - m_dStepValue, m_bContinuous); + } else if (m_eTouchedPart == kCCControlStepperPartPlus) + { + this->setValueWithSendingEvent(m_dValue + m_dStepValue, m_bContinuous); + } +} + +//#pragma mark CCControlStepper Private Methods + +void CCControlStepper::updateLayoutUsingTouchLocation(CCPoint location) +{ + if (location.x < m_pMinusSprite->getContentSize().width + && m_dValue > m_dMinimumValue) + { + m_eTouchedPart = kCCControlStepperPartMinus; + + m_pMinusSprite->setColor(ccGRAY); + m_pPlusSprite->setColor(ccWHITE); + } else if (location.x >= m_pMinusSprite->getContentSize().width + && m_dValue < m_dMaximumValue) + { + m_eTouchedPart = kCCControlStepperPartPlus; + + m_pMinusSprite->setColor(ccWHITE); + m_pPlusSprite->setColor(ccGRAY); + } else + { + m_eTouchedPart = kCCControlStepperPartNone; + + m_pMinusSprite->setColor(ccWHITE); + m_pPlusSprite->setColor(ccWHITE); + } +} + + +bool CCControlStepper::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) +{ + if (!this->isTouchInside(pTouch) + || !this->isEnabled()) + { + return false; + } + + CCPoint location = this->getTouchLocation(pTouch); + this->updateLayoutUsingTouchLocation(location); + + m_bTouchInsideFlag = true; + + if (m_bAutorepeat) + { + this->startAutorepeat(); + } + + return true; +} + +void CCControlStepper::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent) +{ + if (this->isTouchInside(pTouch)) + { + CCPoint location = this->getTouchLocation(pTouch); + this->updateLayoutUsingTouchLocation(location); + + if (!m_bTouchInsideFlag) + { + m_bTouchInsideFlag = true; + + if (m_bAutorepeat) + { + this->startAutorepeat(); + } + } + } else + { + m_bTouchInsideFlag = false; + + m_eTouchedPart = kCCControlStepperPartNone; + + m_pMinusSprite->setColor(ccWHITE); + m_pPlusSprite->setColor(ccWHITE); + + if (m_bAutorepeat) + { + this->stopAutorepeat(); + } + } +} + +void CCControlStepper::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent) +{ + m_pMinusSprite->setColor(ccWHITE); + m_pPlusSprite->setColor(ccWHITE); + + if (m_bAutorepeat) + { + this->stopAutorepeat(); + } + + if (this->isTouchInside(pTouch)) + { + CCPoint location = this->getTouchLocation(pTouch); + + this->setValue(m_dValue + ((location.x < m_pMinusSprite->getContentSize().width) ? (0.0-m_dStepValue) : m_dStepValue)); + } +} + +NS_CC_EXT_END diff --git a/extensions/GUI/CCControlExtension/CCControlStepper.h b/extensions/GUI/CCControlExtension/CCControlStepper.h new file mode 100644 index 0000000000..51fab80cbc --- /dev/null +++ b/extensions/GUI/CCControlExtension/CCControlStepper.h @@ -0,0 +1,115 @@ +/* + * CCControlStepper.h + * + * Copyright 2012 Yannick Loriot. All rights reserved. + * http://yannickloriot.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#ifndef __CCCONTROLSTEPPER_H__ +#define __CCCONTROLSTEPPER_H__ + +#include "CCControl.h" + +NS_CC_EXT_BEGIN + +/** + * @addtogroup GUI + * @{ + * @addtogroup control_extension + * @{ + */ + +typedef enum +{ + kCCControlStepperPartMinus, + kCCControlStepperPartPlus, + kCCControlStepperPartNone, +} CCControlStepperPart; + +class CCControlStepper : public CCControl +{ +public: + CCControlStepper(); + virtual ~CCControlStepper(); + + bool initWithMinusSpriteAndPlusSprite(CCSprite *minusSprite, CCSprite *plusSprite); + static CCControlStepper* create(CCSprite *minusSprite, CCSprite *plusSprite); + virtual void setWraps(bool wraps); + virtual void setMinimumValue(double minimumValue); + virtual void setMaximumValue(double maximumValue); + virtual void setValue(double value); + virtual double getValue(); + virtual void setStepValue(double stepValue); + virtual void setValueWithSendingEvent(double value, bool send); + virtual bool isContinuous(); + void update(float dt); + + //events + virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent); + virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent); + virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent); + +protected: + // Weak links to children + CC_SYNTHESIZE_RETAIN(CCSprite*, m_pMinusSprite, MinusSprite) + CC_SYNTHESIZE_RETAIN(CCSprite*, m_pPlusSprite, PlusSprite) + CC_SYNTHESIZE_RETAIN(CCLabelTTF*, m_pMinusLabel, MinusLabel) + CC_SYNTHESIZE_RETAIN(CCLabelTTF*, m_pPlusLabel, PlusLabel) + + /** Update the layout of the stepper with the given touch location. */ + void updateLayoutUsingTouchLocation(CCPoint location); + + /** Set the numeric value of the stepper. If send is true, the CCControlEventValueChanged is sent. */ + void setValue(double value, bool send); + + /** Start the autorepeat increment/decrement. */ + void startAutorepeat(); + + /** Stop the autorepeat. */ + void stopAutorepeat(); + + /** The numeric value of the stepper. */ + double m_dValue; + /** The continuous vs. noncontinuous state of the stepper. */ + bool m_bContinuous; + /** The automatic vs. nonautomatic repeat state of the stepper. */ + bool m_bAutorepeat; + /** The wrap vs. no-wrap state of the stepper. */ + bool m_bWraps; + /** The lowest possible numeric value for the stepper. */ + double m_dMinimumValue; + /** The highest possible numeric value for the stepper. */ + double m_dMaximumValue; + /** The step, or increment, value for the stepper. */ + double m_dStepValue; + bool m_bTouchInsideFlag; + CCControlStepperPart m_eTouchedPart; + int m_nAutorepeatCount; +}; + +// end of GUI group +/// @} +/// @} + +NS_CC_EXT_END + +#endif /* __CCCONTROLSTEPPER_H__ */ diff --git a/extensions/GUI/CCControlExtension/CCControlSwitch.cpp b/extensions/GUI/CCControlExtension/CCControlSwitch.cpp index 4bb3d0842c..36cc11210e 100644 --- a/extensions/GUI/CCControlExtension/CCControlSwitch.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSwitch.cpp @@ -259,6 +259,10 @@ float CCControlSwitchSprite::offSideWidth() // CCControlSwitch CCControlSwitch::CCControlSwitch() +: m_pSwitchSprite(NULL) +, m_fInitialTouchXPosition(0.0f) +, m_bMoved(false) +, m_bOn(false) { } @@ -367,8 +371,10 @@ void CCControlSwitch::setOn(bool isOn, bool animated) void CCControlSwitch::setEnabled(bool enabled) { m_bEnabled = enabled; - - m_pSwitchSprite->setOpacity((enabled) ? 255 : 128); + if (m_pSwitchSprite != NULL) + { + m_pSwitchSprite->setOpacity((enabled) ? 255 : 128); + } } CCPoint CCControlSwitch::locationFromTouch(CCTouch* pTouch) diff --git a/extensions/GUI/CCControlExtension/CCInvocation.cpp b/extensions/GUI/CCControlExtension/CCInvocation.cpp index 96ee02bc79..ec1a7a6457 100644 --- a/extensions/GUI/CCControlExtension/CCInvocation.cpp +++ b/extensions/GUI/CCControlExtension/CCInvocation.cpp @@ -2,6 +2,16 @@ NS_CC_EXT_BEGIN +CCInvocation* CCInvocation::create(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent) +{ + CCInvocation* pRet = new CCInvocation(target, action, controlEvent); + if (pRet != NULL) + { + pRet->autorelease(); + } + return pRet; +} + CCInvocation::CCInvocation(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent) { m_target=target; diff --git a/extensions/GUI/CCControlExtension/CCInvocation.h b/extensions/GUI/CCControlExtension/CCInvocation.h index 9aa88ad2d7..3094f18b15 100644 --- a/extensions/GUI/CCControlExtension/CCInvocation.h +++ b/extensions/GUI/CCControlExtension/CCInvocation.h @@ -30,6 +30,7 @@ class CCInvocation : public CCObject CC_SYNTHESIZE_READONLY(CCControlEvent, m_controlEvent, ControlEvent); public: + static CCInvocation* create(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent); CCInvocation(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent); void invoke(CCObject* sender); diff --git a/extensions/GUI/CCControlExtension/CCMenuPassive.cpp b/extensions/GUI/CCControlExtension/CCMenuPassive.cpp deleted file mode 100644 index 24592b9403..0000000000 --- a/extensions/GUI/CCControlExtension/CCMenuPassive.cpp +++ /dev/null @@ -1,465 +0,0 @@ -#include "CCMenuPassive.h" -#include "CCDirector.h" -#include "support/CCPointExtension.h" -#include "menu_nodes/CCMenuItem.h" -#include - -using namespace std; - -NS_CC_EXT_BEGIN - -enum -{ - kDefaultPadding = 5, -}; - -// -//CCMenu -// -CCMenuPassive* CCMenuPassive::node() -{ - return CCMenuPassive::create(); -} - -CCMenuPassive* CCMenuPassive::create() -{ - return create(NULL, NULL); -} - -CCMenuPassive * CCMenuPassive::menuWithItems(CCNode* item, ...) -{ - va_list args; - va_start(args,item); - CCMenuPassive *pRet = new CCMenuPassive(); - if (pRet && pRet->initWithItems(item, args)) - { - pRet->autorelease(); - va_end(args); - return pRet; - } - va_end(args); - CC_SAFE_DELETE(pRet); - return NULL; -} - -CCMenuPassive * CCMenuPassive::create(CCNode* item, ...) -{ - va_list args; - va_start(args,item); - CCMenuPassive *pRet = new CCMenuPassive(); - if (pRet && pRet->initWithItems(item, args)) - { - pRet->autorelease(); - va_end(args); - return pRet; - } - va_end(args); - CC_SAFE_DELETE(pRet); - return NULL; -} - -CCMenuPassive* CCMenuPassive::menuWithItem(CCNode* item) -{ - return CCMenuPassive::createWithItem(item); -} - -CCMenuPassive* CCMenuPassive::createWithItem(CCNode* item) -{ - return create(item, NULL); -} - -bool CCMenuPassive::initWithItems(CCNode* item, va_list args) -{ - if (CCLayer::init()) - { - //this->m_bIsTouchEnabled = false; - - // menu in the center of the screen - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - // Set the default anchor point - ignoreAnchorPointForPosition(true); - setAnchorPoint(ccp(0.5f, 0.5f)); - this->setContentSize(s); - - setPosition(ccp(s.width/2, s.height/2)); - - int z=0; - - if (item) - { - this->addChild(item, z); - CCMenuItem *i = va_arg(args, CCMenuItem*); - while (i) - { - z++; - this->addChild(i, z); - i = va_arg(args, CCMenuItem*); - } - } - - return true; - } - - return false; -} - - -//Menu - Alignment -void CCMenuPassive::alignItemsVertically() -{ - this->alignItemsVerticallyWithPadding(kDefaultPadding); -} - -void CCMenuPassive::alignItemsVerticallyWithPadding(float padding) -{ - float height = -padding; - if (m_pChildren && m_pChildren->count() > 0) - { - CCObject* pObject = NULL; - CCARRAY_FOREACH(m_pChildren, pObject) - { - CCNode* pChild = dynamic_cast(pObject); - if (pChild) - { - height += pChild->getContentSize().height * pChild->getScaleY() + padding; - } - } - } - float width=0; - float y = height / 2.0f; - if (m_pChildren && m_pChildren->count() > 0) - { - CCObject* pObject = NULL; - CCARRAY_FOREACH(m_pChildren, pObject) - { - CCNode* pChild = dynamic_cast(pObject); - if (pChild) - { - width=max(width, pChild->getContentSize().width); - pChild->setPosition(ccp(0, y - pChild->getContentSize().height * pChild->getScaleY() / 2.0f)); - y -= pChild->getContentSize().height * pChild->getScaleY() + padding; - } - } - } - setContentSize(CCSizeMake(width, height)); -} - -void CCMenuPassive::alignItemsHorizontally(void) -{ - this->alignItemsHorizontallyWithPadding(kDefaultPadding); -} - -void CCMenuPassive::alignItemsHorizontallyWithPadding(float padding) -{ - - float width = -padding; - if (m_pChildren && m_pChildren->count() > 0) - { - CCObject* pObject = NULL; - CCARRAY_FOREACH(m_pChildren, pObject) - { - CCNode* pChild = dynamic_cast(pObject); - if (pChild) - { - width += pChild->getContentSize().width * pChild->getScaleX() + padding; - } - } - } - - float height=0; - float x = -width / 2.0f; - if (m_pChildren && m_pChildren->count() > 0) - { - CCObject* pObject = NULL; - CCARRAY_FOREACH(m_pChildren, pObject) - { - CCNode* pChild = dynamic_cast(pObject); - if (pChild) - { - height=max(height, pChild->getContentSize().height); - pChild->setPosition(ccp(x + pChild->getContentSize().width * pChild->getScaleX() / 2.0f, 0)); - x += pChild->getContentSize().width * pChild->getScaleX() + padding; - } - } - } - setContentSize(CCSizeMake(width, height)); -} - -void CCMenuPassive::alignItemsInColumns(unsigned int columns, ...) -{ - va_list args; - va_start(args, columns); - - this->alignItemsInColumns(columns, args); - - va_end(args); -} - -void CCMenuPassive::alignItemsInColumns(unsigned int columns, va_list args) -{ - vector rows; - while (columns) - { - rows.push_back(columns); - columns = va_arg(args, unsigned int); - } - - int height = -5; - unsigned int row = 0; - unsigned int rowHeight = 0; - unsigned int columnsOccupied = 0; - unsigned int rowColumns; - - if (m_pChildren && m_pChildren->count() > 0) - { - CCObject* pObject = NULL; - CCARRAY_FOREACH(m_pChildren, pObject) - { - CCNode* pChild = dynamic_cast(pObject); - if (pChild) - { - CCAssert(row < rows.size(), ""); - - rowColumns = rows[row]; - // can not have zero columns on a row - CCAssert(rowColumns, ""); - - float tmp = pChild->getContentSize().height; - rowHeight = (unsigned int)((rowHeight >= tmp || isnan(tmp)) ? rowHeight : tmp); - - ++columnsOccupied; - if (columnsOccupied >= rowColumns) - { - height += rowHeight + 5; - - columnsOccupied = 0; - rowHeight = 0; - ++row; - } - } - } - } - - // check if too many rows/columns for available menu items - CCAssert(! columnsOccupied, ""); - - CCSize winSize = CCDirector::sharedDirector()->getWinSize(); - - row = 0; - rowHeight = 0; - rowColumns = 0; - float w = 0.0; - float x = 0.0; - float y = (float)(height / 2); - - if (m_pChildren && m_pChildren->count() > 0) - { - CCObject* pObject = NULL; - CCARRAY_FOREACH(m_pChildren, pObject) - { - CCNode* pChild = dynamic_cast(pObject); - if (pChild) - { - if (rowColumns == 0) - { - rowColumns = rows[row]; - w = winSize.width / (1 + rowColumns); - x = w; - } - - float tmp = pChild->getContentSize().height; - rowHeight = (unsigned int)((rowHeight >= tmp || isnan(tmp)) ? rowHeight : tmp); - - pChild->setPosition(ccp(x - winSize.width / 2, - y - pChild->getContentSize().height / 2)); - - x += w; - ++columnsOccupied; - - if (columnsOccupied >= rowColumns) - { - y -= rowHeight + 5; - - columnsOccupied = 0; - rowColumns = 0; - rowHeight = 0; - ++row; - } - } - } - } -} - -void CCMenuPassive::alignItemsInRows(unsigned int rows, ...) -{ - va_list args; - va_start(args, rows); - - this->alignItemsInRows(rows, args); - - va_end(args); -} - -void CCMenuPassive::alignItemsInRows(unsigned int rows, va_list args) -{ - vector columns; - while (rows) - { - columns.push_back(rows); - rows = va_arg(args, unsigned int); - } - - vector columnWidths; - vector columnHeights; - - int width = -10; - int columnHeight = -5; - unsigned int column = 0; - unsigned int columnWidth = 0; - unsigned int rowsOccupied = 0; - unsigned int columnRows; - - if (m_pChildren && m_pChildren->count() > 0) - { - CCObject* pObject = NULL; - CCARRAY_FOREACH(m_pChildren, pObject) - { - CCNode* pChild = dynamic_cast(pObject); - if (pChild) - { - // check if too many menu items for the amount of rows/columns - CCAssert(column < columns.size(), ""); - - columnRows = columns[column]; - // can't have zero rows on a column - CCAssert(columnRows, ""); - - // columnWidth = fmaxf(columnWidth, [item contentSize].width); - float tmp = pChild->getContentSize().width; - columnWidth = (unsigned int)((columnWidth >= tmp || isnan(tmp)) ? columnWidth : tmp); - - columnHeight += (int)(pChild->getContentSize().height + 5); - ++rowsOccupied; - - if (rowsOccupied >= columnRows) - { - columnWidths.push_back(columnWidth); - columnHeights.push_back(columnHeight); - width += columnWidth + 10; - - rowsOccupied = 0; - columnWidth = 0; - columnHeight = -5; - ++column; - } - } - } - } - - // check if too many rows/columns for available menu items. - CCAssert(! rowsOccupied, ""); - - CCSize winSize = CCDirector::sharedDirector()->getWinSize(); - - column = 0; - columnWidth = 0; - columnRows = 0; - float x = (float)(-width / 2); - float y = 0.0; - - if (m_pChildren && m_pChildren->count() > 0) - { - CCObject* pObject = NULL; - CCARRAY_FOREACH(m_pChildren, pObject) - { - CCNode* pChild = dynamic_cast(pObject); - if (pChild) - { - if (columnRows == 0) - { - columnRows = columns[column]; - y = (float) columnHeights[column]; - } - - // columnWidth = fmaxf(columnWidth, [item contentSize].width); - float tmp = pChild->getContentSize().width; - columnWidth = (unsigned int)((columnWidth >= tmp || isnan(tmp)) ? columnWidth : tmp); - - pChild->setPosition(ccp(x + columnWidths[column] / 2, - y - winSize.height / 2)); - - y -= pChild->getContentSize().height + 10; - ++rowsOccupied; - - if (rowsOccupied >= columnRows) - { - x += columnWidth + 5; - rowsOccupied = 0; - columnRows = 0; - columnWidth = 0; - ++column; - } - } - } - } -} - -// Opacity Protocol - -/** Override synthesized setOpacity to recurse items */ -void CCMenuPassive::setOpacity(GLubyte var) -{ - m_cOpacity = var; - - if (m_pChildren && m_pChildren->count() > 0) - { - CCObject* pObject = NULL; - CCARRAY_FOREACH(m_pChildren, pObject) - { - CCNode* pChild = dynamic_cast(pObject); - if (pChild) - { - CCRGBAProtocol *pRGBAProtocol = dynamic_cast(pChild); - if (pRGBAProtocol) - { - pRGBAProtocol->setOpacity(m_cOpacity); - } - } - } - } -} - -GLubyte CCMenuPassive::getOpacity(void) -{ - return m_cOpacity; -} - -void CCMenuPassive::setColor(const ccColor3B& var) -{ - m_tColor = var; - - if (m_pChildren && m_pChildren->count() > 0) - { - CCObject* pObject = NULL; - CCARRAY_FOREACH(m_pChildren, pObject) - { - CCNode* pChild = dynamic_cast(pObject); - if (pChild) - { - CCRGBAProtocol *pRGBAProtocol = dynamic_cast(pChild); - if (pRGBAProtocol) - { - pRGBAProtocol->setColor(m_tColor); - } - } - } - } -} - -const ccColor3B& CCMenuPassive::getColor(void) -{ - return m_tColor; -} - -NS_CC_EXT_END diff --git a/extensions/GUI/CCControlExtension/CCMenuPassive.h b/extensions/GUI/CCControlExtension/CCMenuPassive.h deleted file mode 100644 index c72591019f..0000000000 --- a/extensions/GUI/CCControlExtension/CCMenuPassive.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * - * A menu that does not send any events, it's simply a passive container (lets the contents do their own thing) of CCNodes - */ -#ifndef __CCMENU_PASSIVE_H__ -#define __CCMENU_PASSIVE_H__ - -#include "CCControl.h" - -NS_CC_EXT_BEGIN - -/** - * @addtogroup GUI - * @{ - * @addtogroup control_extension - * @{ - */ - -class CCMenuPassive : public CCLayer, public CCRGBAProtocol -{ - /** Color: conforms with CCRGBAProtocol protocol */ - CC_PROPERTY_PASS_BY_REF(ccColor3B, m_tColor, Color); - /** Opacity: conforms with CCRGBAProtocol protocol */ - CC_PROPERTY(GLubyte, m_cOpacity, Opacity); - -public: - /** creates an empty CCMenu - @deprecated: This interface will be deprecated sooner or later. - */ - CC_DEPRECATED_ATTRIBUTE static CCMenuPassive* node(); - - /** creates a CCMenu with it's items - @deprecated: This interface will be deprecated sooner or later. - */ - CC_DEPRECATED_ATTRIBUTE static CCMenuPassive* menuWithItems(CCNode* item, ...); - - /** creates a CCMenu with it's item, then use addChild() to add - * other items. It is used for script, it can't init with undetermined - * number of variables. - @deprecated: This interface will be deprecated sooner or later. - */ - CC_DEPRECATED_ATTRIBUTE static CCMenuPassive* menuWithItem(CCNode* item); - - /** creates an empty CCMenu */ - static CCMenuPassive* create(); - - /** creates a CCMenu with it's items */ - static CCMenuPassive* create(CCNode* item, ...); - - /** creates a CCMenu with it's item, then use addChild() to add - * other items. It is used for script, it can't init with undetermined - * number of variables. - */ - static CCMenuPassive* createWithItem(CCNode* item); - - /** initializes a CCMenu with it's items */ - bool initWithItems(CCNode* item, va_list args); - - /** align items vertically */ - void alignItemsVertically(); - /** align items vertically with padding - @since v0.7.2 - */ - void alignItemsVerticallyWithPadding(float padding); - - /** align items horizontally */ - void alignItemsHorizontally(); - /** align items horizontally with padding - @since v0.7.2 - */ - void alignItemsHorizontallyWithPadding(float padding); - - /** align items in rows of columns */ - void alignItemsInColumns(unsigned int columns, ...); - void alignItemsInColumns(unsigned int columns, va_list args); - - /** align items in columns of rows */ - void alignItemsInRows(unsigned int rows, ...); - void alignItemsInRows(unsigned int rows, va_list args); - - //RGBA protocol - virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} - virtual bool isOpacityModifyRGB(void) { return false;} -}; - -// end of GUI group -/// @} -/// @} - -NS_CC_EXT_END - -#endif \ No newline at end of file diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp index c7f68c2d93..545de4e20b 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp @@ -7,26 +7,58 @@ // #include "CCScale9Sprite.h" -#include "sprite_nodes/CCSpriteBatchNode.h" -#include "sprite_nodes/CCSpriteFrame.h" -#include "sprite_nodes/CCSpriteFrameCache.h" -#include "sprite_nodes/CCSprite.h" -#include "support/CCPointExtension.h" NS_CC_EXT_BEGIN +enum positions +{ + pCentre = 0, + pTop, + pLeft, + pRight, + pBottom, + pTopRight, + pTopLeft, + pBottomRight, + pBottomLeft +}; + CCScale9Sprite::CCScale9Sprite() : m_insetLeft(0) , m_insetTop(0) , m_insetRight(0) , m_insetBottom(0) +, m_cOpacity(0) +, m_bSpritesGenerated(false) +, m_bSpriteFrameRotated(false) +, m_positionsAreDirty(false) +, scale9Image(NULL) +, topLeft(NULL) +, top(NULL) +, topRight(NULL) +, left(NULL) +, centre(NULL) +, right(NULL) +, bottomLeft(NULL) +, bottom(NULL) +, bottomRight(NULL) +, m_bIsOpacityModifyRGB(false) { } CCScale9Sprite::~CCScale9Sprite() { - + CC_SAFE_RELEASE(topLeft); + CC_SAFE_RELEASE(top); + CC_SAFE_RELEASE(topRight); + CC_SAFE_RELEASE(left); + CC_SAFE_RELEASE(centre); + CC_SAFE_RELEASE(right); + CC_SAFE_RELEASE(bottomLeft); + CC_SAFE_RELEASE(bottom); + CC_SAFE_RELEASE(bottomRight); + CC_SAFE_RELEASE(scale9Image); } bool CCScale9Sprite::init() @@ -35,10 +67,15 @@ bool CCScale9Sprite::init() } bool CCScale9Sprite::initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, CCRect capInsets) +{ + return this->initWithBatchNode(batchnode, rect, false, capInsets); +} + +bool CCScale9Sprite::initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, bool rotated, CCRect capInsets) { if(batchnode) { - this->updateWithBatchNode(batchnode, rect, capInsets); + this->updateWithBatchNode(batchnode, rect, rotated, capInsets); this->setAnchorPoint(ccp(0.5f, 0.5f)); } this->m_positionsAreDirty = true; @@ -46,37 +83,30 @@ bool CCScale9Sprite::initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect return true; } -bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, CCRect capInsets) +bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, bool rotated, CCRect capInsets) { + GLubyte opacity = m_cOpacity; + ccColor3B color = m_tColor; + // Release old sprites this->removeAllChildrenWithCleanup(true); - // TODO Is this needed? - /* - if(this->topLeft != NULL) - { - CC_SAFE_RELEASE(this->topLeft); - CC_SAFE_RELEASE(this->top); - CC_SAFE_RELEASE(this->topRight); - CC_SAFE_RELEASE(this->left); - CC_SAFE_RELEASE(this->centre); - CC_SAFE_RELEASE(this->right); - CC_SAFE_RELEASE(this->bottomLeft); - CC_SAFE_RELEASE(this->bottom); - CC_SAFE_RELEASE(this->bottomRight); - } - */ + CC_SAFE_RELEASE(this->centre); + CC_SAFE_RELEASE(this->top); + CC_SAFE_RELEASE(this->topLeft); + CC_SAFE_RELEASE(this->topRight); + CC_SAFE_RELEASE(this->left); + CC_SAFE_RELEASE(this->right); + CC_SAFE_RELEASE(this->bottomLeft); + CC_SAFE_RELEASE(this->bottom); + CC_SAFE_RELEASE(this->bottomRight); + if(this->scale9Image != batchnode) { - // TODO Is this needed? - /* - if(this->scale9Image != NULL) - { - CC_SAFE_RELEASE(this->scale9Image); - } - */ - scale9Image = batchnode; // TODO No retain on purpose? + CC_SAFE_RELEASE(this->scale9Image); + scale9Image = batchnode; + CC_SAFE_RETAIN(scale9Image); } scale9Image->removeAllChildrenWithCleanup(true); @@ -98,99 +128,219 @@ bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect re m_preferredSize = m_originalSize; m_capInsetsInternal = capInsets; + // Get the image edges + float l = rect.origin.x; + float t = rect.origin.y; + float h = rect.size.height; + float w = rect.size.width; + // If there is no specified center region if ( m_capInsetsInternal.equals(CCRectZero) ) { // Apply the 3x3 grid format - m_capInsetsInternal = CCRectMake( - rect.origin.x + m_originalSize.width / 3, - rect.origin.y + m_originalSize.height / 3, - m_originalSize.width / 3, - m_originalSize.height / 3); + if (rotated) + { + m_capInsetsInternal = CCRectMake(l+h/3, t+w/3, w/3, h/3); + } + else + { + m_capInsetsInternal = CCRectMake(l+w/3, t+h/3, w/3, h/3); + } } - - // Get the image edges - float l = rect.origin.x; - float t = rect.origin.y; - float h = rect.size.height; - float w = rect.size.width; // // Set up the image // - - // Centre - centre = CCSprite::createWithTexture(scale9Image->getTexture(), m_capInsetsInternal); - scale9Image->addChild(centre, 0, pCentre); - - // Top - top = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsetsInternal.origin.x, - t, - m_capInsetsInternal.size.width, - m_capInsetsInternal.origin.y - t)); - scale9Image->addChild(top, 1, pTop); - - // Bottom - bottom = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( m_capInsetsInternal.origin.x, - m_capInsetsInternal.origin.y + m_capInsetsInternal.size.height, - m_capInsetsInternal.size.width, - h - (m_capInsetsInternal.origin.y - t + m_capInsetsInternal.size.height) )); - scale9Image->addChild(bottom, 1, pBottom); - - // Left - left = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( - l, - m_capInsetsInternal.origin.y, - m_capInsetsInternal.origin.x - l, - m_capInsetsInternal.size.height) ); - scale9Image->addChild(left, 1, pLeft); - - // Right - right = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( - m_capInsetsInternal.origin.x + m_capInsetsInternal.size.width, - m_capInsetsInternal.origin.y, - w - (m_capInsetsInternal.origin.x - l + m_capInsetsInternal.size.width), - m_capInsetsInternal.size.height)); - scale9Image->addChild(right, 1, pRight); - - // Top left - topLeft = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( - l, + if (rotated) + { + // Sprite frame is rotated + + // Centre + centre = new CCSprite(); + centre->initWithTexture(scale9Image->getTexture(), m_capInsetsInternal, true); + scale9Image->addChild(centre, 0, pCentre); + + // Bottom + bottom = new CCSprite(); + bottom->initWithTexture(scale9Image->getTexture(), CCRectMake(l, + m_capInsetsInternal.origin.y, + m_capInsetsInternal.size.width, + m_capInsetsInternal.origin.x - l), + rotated + ); + scale9Image->addChild(bottom, 1, pBottom); + + // Top + top = new CCSprite(); + top->initWithTexture(scale9Image->getTexture(),CCRectMake(m_capInsetsInternal.origin.x + m_capInsetsInternal.size.height, + m_capInsetsInternal.origin.y, + m_capInsetsInternal.size.width, + h - m_capInsetsInternal.size.height - (m_capInsetsInternal.origin.x - l)), + rotated + ); + scale9Image->addChild(top, 1, pTop); + + // Right + right = new CCSprite(); + right->initWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsetsInternal.origin.x, + m_capInsetsInternal.origin.y+m_capInsetsInternal.size.width, + w - (m_capInsetsInternal.origin.y-t)-m_capInsetsInternal.size.width, + m_capInsetsInternal.size.height), + rotated + ); + scale9Image->addChild(right, 1, pRight); + + // Left + left = new CCSprite(); + left->initWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsetsInternal.origin.x, + t, + m_capInsetsInternal.origin.y - t, + m_capInsetsInternal.size.height), + rotated + ); + scale9Image->addChild(left ,1, pLeft); + + // Top right + topRight = new CCSprite(); + topRight->initWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsetsInternal.origin.x + m_capInsetsInternal.size.height, + m_capInsetsInternal.origin.y + m_capInsetsInternal.size.width, + w - (m_capInsetsInternal.origin.y-t)-m_capInsetsInternal.size.width, + h - m_capInsetsInternal.size.height - (m_capInsetsInternal.origin.x - l)), + rotated + ); + scale9Image->addChild(topRight ,2 ,pTopRight); + + // Top left + topLeft = new CCSprite(); + topLeft->initWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsetsInternal.origin.x + m_capInsetsInternal.size.height, + t, + m_capInsetsInternal.origin.y - t, + h - m_capInsetsInternal.size.height - (m_capInsetsInternal.origin.x - l)), + rotated + ); + scale9Image->addChild(topLeft, 2, pTopLeft); + + // Bottom right + bottomRight = new CCSprite(); + bottomRight->initWithTexture(scale9Image->getTexture(),CCRectMake(l, + m_capInsetsInternal.origin.y + m_capInsetsInternal.size.width, + w - (m_capInsetsInternal.origin.y-t)-m_capInsetsInternal.size.width, + m_capInsetsInternal.origin.x - l), + rotated + ); + scale9Image->addChild(bottomRight, 2, pBottomRight); + + // Bottom left + bottomLeft = new CCSprite(); + bottomLeft->initWithTexture(scale9Image->getTexture(), CCRectMake(l, + t, + m_capInsetsInternal.origin.y - t, + m_capInsetsInternal.origin.x - l), + rotated + ); + scale9Image->addChild(bottomLeft, 2, pBottomLeft); + } + else + { + // Sprite frame is not rotated + // Centre + centre = new CCSprite(); + centre->initWithTexture(scale9Image->getTexture(), m_capInsetsInternal, rotated); + scale9Image->addChild(centre, 0, pCentre); + + // Top + top = new CCSprite(); + top->initWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsetsInternal.origin.x, t, - m_capInsetsInternal.origin.x - l, - m_capInsetsInternal.origin.y - t)); - - scale9Image->addChild(topLeft, 2, pTopLeft); - - // Top right - topRight = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( - m_capInsetsInternal.origin.x + m_capInsetsInternal.size.width, - t, - w - (m_capInsetsInternal.origin.x - l + m_capInsetsInternal.size.width), - m_capInsetsInternal.origin.y - t)); - - scale9Image->addChild(topRight, 2, pTopRight); - - // Bottom left - bottomLeft = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( - l, + m_capInsetsInternal.size.width, + m_capInsetsInternal.origin.y - t), + rotated + ); + scale9Image->addChild(top, 1, pTop); + + // Bottom + bottom = new CCSprite(); + bottom->initWithTexture(scale9Image->getTexture(), CCRectMake( m_capInsetsInternal.origin.x, m_capInsetsInternal.origin.y + m_capInsetsInternal.size.height, - m_capInsetsInternal.origin.x - l, - h - (m_capInsetsInternal.origin.y - t + m_capInsetsInternal.size.height)) ); - scale9Image->addChild(bottomLeft, 2, pBottomLeft); - - // Bottom right - bottomRight = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( - m_capInsetsInternal.origin.x + m_capInsetsInternal.size.width, - m_capInsetsInternal.origin.y + m_capInsetsInternal.size.height, - w - (m_capInsetsInternal.origin.x - l + m_capInsetsInternal.size.width), - h - (m_capInsetsInternal.origin.y - t + m_capInsetsInternal.size.height)) ); - scale9Image->addChild(bottomRight, 2, pBottomRight); - + m_capInsetsInternal.size.width, + h - (m_capInsetsInternal.origin.y - t + m_capInsetsInternal.size.height)), + rotated); + scale9Image->addChild(bottom, 1, pBottom); + + // Left + left = new CCSprite(); + left->initWithTexture(scale9Image->getTexture(), CCRectMake( + l, + m_capInsetsInternal.origin.y, + m_capInsetsInternal.origin.x - l, + m_capInsetsInternal.size.height), + rotated); + scale9Image->addChild(left, 1, pLeft); + + // Right + right = new CCSprite(); + right->initWithTexture(scale9Image->getTexture(), CCRectMake( + m_capInsetsInternal.origin.x + m_capInsetsInternal.size.width, + m_capInsetsInternal.origin.y, + w - (m_capInsetsInternal.origin.x - l + m_capInsetsInternal.size.width), + m_capInsetsInternal.size.height), + rotated); + scale9Image->addChild(right, 1, pRight); + + // Top left + topLeft = new CCSprite(); + topLeft->initWithTexture(scale9Image->getTexture(), CCRectMake( + l, + t, + m_capInsetsInternal.origin.x - l, + m_capInsetsInternal.origin.y - t), + rotated); + + scale9Image->addChild(topLeft, 2, pTopLeft); + + // Top right + topRight = new CCSprite(); + topRight->initWithTexture(scale9Image->getTexture(), CCRectMake( + m_capInsetsInternal.origin.x + m_capInsetsInternal.size.width, + t, + w - (m_capInsetsInternal.origin.x - l + m_capInsetsInternal.size.width), + m_capInsetsInternal.origin.y - t), + rotated); + + scale9Image->addChild(topRight, 2, pTopRight); + + // Bottom left + bottomLeft = new CCSprite(); + bottomLeft->initWithTexture(scale9Image->getTexture(), CCRectMake( + l, + m_capInsetsInternal.origin.y + m_capInsetsInternal.size.height, + m_capInsetsInternal.origin.x - l, + h - (m_capInsetsInternal.origin.y - t + m_capInsetsInternal.size.height)), + rotated); + scale9Image->addChild(bottomLeft, 2, pBottomLeft); + + // Bottom right + bottomRight = new CCSprite(); + bottomRight->initWithTexture(scale9Image->getTexture(), CCRectMake( + m_capInsetsInternal.origin.x + m_capInsetsInternal.size.width, + m_capInsetsInternal.origin.y + m_capInsetsInternal.size.height, + w - (m_capInsetsInternal.origin.x - l + m_capInsetsInternal.size.width), + h - (m_capInsetsInternal.origin.y - t + m_capInsetsInternal.size.height)), + rotated); + scale9Image->addChild(bottomRight, 2, pBottomRight); + } this->setContentSize(rect.size); this->addChild(scale9Image); + if (m_bSpritesGenerated) + { + // Restore color and opacity + this->setOpacity(opacity); + this->setColor(color); + } + m_bSpritesGenerated = true; + return true; } @@ -206,10 +356,13 @@ void CCScale9Sprite::updatePositions() float sizableWidth = size.width - topLeft->getContentSize().width - topRight->getContentSize().width; float sizableHeight = size.height - topLeft->getContentSize().height - bottomRight->getContentSize().height; + float horizontalScale = sizableWidth/centre->getContentSize().width; float verticalScale = sizableHeight/centre->getContentSize().height; + centre->setScaleX(horizontalScale); centre->setScaleY(verticalScale); + float rescaledWidth = centre->getContentSize().width * horizontalScale; float rescaledHeight = centre->getContentSize().height * verticalScale; @@ -274,6 +427,7 @@ CCScale9Sprite* CCScale9Sprite::create(const char* file, CCRect rect, CCRect ca bool CCScale9Sprite::initWithFile(const char* file, CCRect rect) { + CCAssert(file != NULL, "Invalid file for sprite"); bool pReturn = this->initWithFile(file, rect, CCRectZero); return pReturn; } @@ -348,7 +502,7 @@ bool CCScale9Sprite::initWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capI CCAssert(spriteFrame != NULL, "Sprite frame must be not nil"); CCSpriteBatchNode *batchnode = CCSpriteBatchNode::createWithTexture(spriteFrame->getTexture(), 9); - bool pReturn = this->initWithBatchNode(batchnode, spriteFrame->getRect(), capInsets); + bool pReturn = this->initWithBatchNode(batchnode, spriteFrame->getRect(), spriteFrame->isRotated(), capInsets); return pReturn; } @@ -370,6 +524,7 @@ CCScale9Sprite* CCScale9Sprite::createWithSpriteFrame(CCSpriteFrame* spriteFrame } bool CCScale9Sprite::initWithSpriteFrame(CCSpriteFrame* spriteFrame) { + CCAssert(spriteFrame != NULL, "Invalid spriteFrame for sprite"); bool pReturn = this->initWithSpriteFrame(spriteFrame, CCRectZero); return pReturn; } @@ -508,15 +663,6 @@ void CCScale9Sprite::setOpacity(GLubyte var) { pNode->setOpacity(m_cOpacity); } - //CCNode* pNode = (CCNode*) child; - //if (pNode) - //{ - // CCRGBAProtocol *pRGBAProtocol = (CCRGBAProtocol *)pNode; - // if (pRGBAProtocol) - // { - // pRGBAProtocol->setOpacity(m_cOpacity); - // } - //} } } } @@ -544,7 +690,7 @@ CCSize CCScale9Sprite::getPreferredSize() void CCScale9Sprite::setCapInsets(CCRect capInsets) { CCSize contentSize = this->m_tContentSize; - this->updateWithBatchNode(this->scale9Image, this->m_spriteRect, capInsets); + this->updateWithBatchNode(this->scale9Image, this->m_spriteRect, m_bSpriteFrameRotated, capInsets); this->setContentSize(contentSize); } @@ -562,10 +708,20 @@ void CCScale9Sprite::updateCapInset() } else { - insets = CCRectMake(this->m_insetLeft, - this->m_insetTop, - this->m_spriteRect.size.width-this->m_insetLeft-this->m_insetRight, - this->m_spriteRect.size.height-this->m_insetTop-this->m_insetBottom); + if (m_bSpriteFrameRotated) + { + insets = CCRectMake(m_spriteRect.origin.x + m_insetBottom, + m_spriteRect.origin.y + m_insetLeft, + m_spriteRect.size.width-m_insetRight-m_insetLeft, + m_spriteRect.size.height-m_insetTop-m_insetBottom); + } + else + { + insets = CCRectMake(m_spriteRect.origin.x + m_insetLeft, + m_spriteRect.origin.y + m_insetTop, + m_spriteRect.size.width-m_insetLeft-m_insetRight, + m_spriteRect.size.height-m_insetTop-m_insetBottom); + } } this->setCapInsets(insets); } @@ -583,15 +739,6 @@ void CCScale9Sprite::setOpacityModifyRGB(bool var) { pNode->setOpacityModifyRGB(m_bIsOpacityModifyRGB); } - //CCNode* pNode = (CCNode*) child; - //if (pNode) - //{ - // CCRGBAProtocol *pRGBAProtocol = (CCRGBAProtocol *)pNode; - // if (pRGBAProtocol) - // { - // pRGBAProtocol->setOpacityModifyRGB(m_bIsOpacityModifyRGB); - // } - //} } } } @@ -603,7 +750,7 @@ bool CCScale9Sprite::isOpacityModifyRGB() void CCScale9Sprite::setSpriteFrame(CCSpriteFrame * spriteFrame) { CCSpriteBatchNode * batchnode = CCSpriteBatchNode::createWithTexture(spriteFrame->getTexture(), 9); - this->updateWithBatchNode(batchnode, spriteFrame->getRect(), CCRectZero); + this->updateWithBatchNode(batchnode, spriteFrame->getRect(), spriteFrame->isRotated(), CCRectZero); // Reset insets this->m_insetLeft = 0; diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.h b/extensions/GUI/CCControlExtension/CCScale9Sprite.h index bbd1df86a4..324f56c001 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.h +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.h @@ -9,30 +9,11 @@ #ifndef __CCScale9Sprite_H__ #define __CCScale9Sprite_H__ -#include "base_nodes/CCNode.h" -#include "CCProtocols.h" +#include "cocos2d.h" #include "ExtensionMacros.h" - -namespace cocos2d { class CCSprite; } -namespace cocos2d { class CCSpriteBatchNode; } -namespace cocos2d { class CCSpriteFrame; } - NS_CC_EXT_BEGIN -enum positions -{ - pCentre = 0, - pTop, - pLeft, - pRight, - pBottom, - pTopRight, - pTopLeft, - pBottomRight, - pBottomLeft -}; - /** * @addtogroup GUI * @{ @@ -48,7 +29,7 @@ public: public: /** Original sprite's size. */ - CC_SYNTHESIZE(CCSize, m_originalSize, OriginalSize); + CC_SYNTHESIZE_READONLY(CCSize, m_originalSize, OriginalSize); /** Prefered sprite's size. By default the prefered size is the original size. */ //if the preferredSize component is given as -1, it is ignored @@ -58,19 +39,25 @@ public: * On a non-resizeable sprite, this property is set to CGRectZero; the sprite * does not use end caps and the entire sprite is subject to stretching. */ - + CC_PROPERTY(CCRect, m_capInsets, CapInsets); + /** Sets the left side inset */ + CC_PROPERTY(float, m_insetLeft, InsetLeft); + /** Sets the top side inset */ + CC_PROPERTY(float, m_insetTop, InsetTop); + /** Sets the right side inset */ + CC_PROPERTY(float, m_insetRight, InsetRight); + /** Sets the bottom side inset */ + CC_PROPERTY(float, m_insetBottom, InsetBottom); + /** Opacity: conforms to CCRGBAProtocol protocol */ CC_PROPERTY(GLubyte, m_cOpacity, Opacity) /** Color: conforms to CCRGBAProtocol protocol */ CC_PROPERTY_PASS_BY_REF(ccColor3B, m_tColor, Color) - CC_PROPERTY(CCRect, m_capInsets, CapInsets); - CC_PROPERTY(float, m_insetLeft, InsetLeft); - CC_PROPERTY(float, m_insetTop, InsetTop); - CC_PROPERTY(float, m_insetRight, InsetRight); - CC_PROPERTY(float, m_insetBottom, InsetBottom); - + protected: + bool m_bSpritesGenerated; CCRect m_spriteRect; + bool m_bSpriteFrameRotated; CCRect m_capInsetsInternal; bool m_positionsAreDirty; @@ -99,6 +86,7 @@ public: virtual bool init(); + virtual bool initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, bool rotated, CCRect capInsets); virtual bool initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, CCRect capInsets); /** * Initializes a 9-slice sprite with a texture file, a delimitation zone and @@ -153,7 +141,7 @@ public: * @see initWithFile:rect: @deprecated: This interface will be deprecated sooner or later. */ - static CCScale9Sprite* spriteWithFile(const char* file, CCRect rect); + CC_DEPRECATED_ATTRIBUTE static CCScale9Sprite* spriteWithFile(const char* file, CCRect rect); /** * Creates a 9-slice sprite with a texture file and a delimitation zone. The @@ -378,7 +366,7 @@ public: */ virtual bool isOpacityModifyRGB(void); - virtual bool updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, CCRect capInsets); + virtual bool updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, bool rotated, CCRect capInsets); virtual void setSpriteFrame(CCSpriteFrame * spriteFrame); }; diff --git a/extensions/GUI/CCControlExtension/CCSpacer.cpp b/extensions/GUI/CCControlExtension/CCSpacer.cpp deleted file mode 100644 index 931866dc26..0000000000 --- a/extensions/GUI/CCControlExtension/CCSpacer.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "CCSpacer.h" - -NS_CC_EXT_BEGIN - -CCSpacer* CCSpacer::verticalSpacer(float space) -{ - CCSpacer *pRet = new CCSpacer(); - pRet->init(); - pRet->setContentSize(CCSizeMake(0, space)); - pRet->autorelease(); - return pRet; -} - -CCSpacer* CCSpacer::horizontalSpacer(float space) -{ - CCSpacer *pRet = new CCSpacer(); - pRet->init(); - pRet->setContentSize(CCSizeMake(space, 0)); - pRet->autorelease(); - return pRet; -} - -NS_CC_EXT_END diff --git a/extensions/GUI/CCControlExtension/CCSpacer.h b/extensions/GUI/CCControlExtension/CCSpacer.h deleted file mode 100644 index c3dfbd0c34..0000000000 --- a/extensions/GUI/CCControlExtension/CCSpacer.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __CCSPACER_H__ -#define __CCSPACER_H__ - -#include "layers_scenes_transitions_nodes/CCLayer.h" -#include "ExtensionMacros.h" - -NS_CC_EXT_BEGIN - -/** - * @addtogroup GUI - * @{ - * @addtogroup control_extension - * @{ - */ - -class CCSpacer: public CCLayer -{ -public: - static CCSpacer* verticalSpacer(float space); - static CCSpacer* horizontalSpacer(float space); -}; - -// end of GUI group -/// @} -/// @} - -NS_CC_EXT_END - -#endif \ No newline at end of file diff --git a/extensions/proj.win32/libExtensions.vcproj b/extensions/proj.win32/libExtensions.vcproj index 8853c4df2e..7d4d7b5e48 100644 --- a/extensions/proj.win32/libExtensions.vcproj +++ b/extensions/proj.win32/libExtensions.vcproj @@ -401,6 +401,14 @@ RelativePath="..\GUI\CCControlExtension\CCControlHuePicker.h" > + + + + @@ -417,6 +425,14 @@ RelativePath="..\GUI\CCControlExtension\CCControlSlider.h" > + + + + @@ -441,14 +457,6 @@ RelativePath="..\GUI\CCControlExtension\CCInvocation.h" > - - - - @@ -457,14 +465,6 @@ RelativePath="..\GUI\CCControlExtension\CCScale9Sprite.h" > - - - - + + - - @@ -155,14 +155,14 @@ + + - - diff --git a/extensions/proj.win32/libExtensions.vcxproj.filters b/extensions/proj.win32/libExtensions.vcxproj.filters index 19f47f527d..5ca80b20d3 100644 --- a/extensions/proj.win32/libExtensions.vcxproj.filters +++ b/extensions/proj.win32/libExtensions.vcxproj.filters @@ -18,42 +18,6 @@ - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - GUI\CCScrollView @@ -141,47 +105,44 @@ CCBReader + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - GUI\CCScrollView @@ -289,5 +250,44 @@ CCBReader + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + \ No newline at end of file diff --git a/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp index 9c14505f42..896eb50acb 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp +++ b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp @@ -136,14 +136,14 @@ bool CCControlButtonTest_Event::init() addChild(background); // Sets up event handlers - controlButton->addTargetWithActionForControlEvent(this, cccontrol_selector(CCControlButtonTest_Event::touchDownAction), CCControlEventTouchDown); - controlButton->addTargetWithActionForControlEvent(this, cccontrol_selector(CCControlButtonTest_Event::touchDragInsideAction), CCControlEventTouchDragInside); - controlButton->addTargetWithActionForControlEvent(this, cccontrol_selector(CCControlButtonTest_Event::touchDragOutsideAction), CCControlEventTouchDragOutside); - controlButton->addTargetWithActionForControlEvent(this, cccontrol_selector(CCControlButtonTest_Event::touchDragEnterAction), CCControlEventTouchDragEnter); - controlButton->addTargetWithActionForControlEvent(this, cccontrol_selector(CCControlButtonTest_Event::touchDragExitAction), CCControlEventTouchDragExit); - controlButton->addTargetWithActionForControlEvent(this, cccontrol_selector(CCControlButtonTest_Event::touchUpInsideAction), CCControlEventTouchUpInside); - controlButton->addTargetWithActionForControlEvent(this, cccontrol_selector(CCControlButtonTest_Event::touchUpOutsideAction), CCControlEventTouchUpOutside); - controlButton->addTargetWithActionForControlEvent(this, cccontrol_selector(CCControlButtonTest_Event::touchCancelAction), CCControlEventTouchCancel); + controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlButtonTest_Event::touchDownAction), CCControlEventTouchDown); + controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlButtonTest_Event::touchDragInsideAction), CCControlEventTouchDragInside); + controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlButtonTest_Event::touchDragOutsideAction), CCControlEventTouchDragOutside); + controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlButtonTest_Event::touchDragEnterAction), CCControlEventTouchDragEnter); + controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlButtonTest_Event::touchDragExitAction), CCControlEventTouchDragExit); + controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlButtonTest_Event::touchUpInsideAction), CCControlEventTouchUpInside); + controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlButtonTest_Event::touchUpOutsideAction), CCControlEventTouchUpOutside); + controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlButtonTest_Event::touchCancelAction), CCControlEventTouchCancel); return true; } return false; diff --git a/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp index bc5976c027..3a8cac975f 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp +++ b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp @@ -92,7 +92,7 @@ CCControlColourPickerTest::~CCControlColourPickerTest() void CCControlColourPickerTest::colourValueChanged(CCObject *sender, CCControlEvent controlEvent) { CCControlColourPicker* pPicker = (CCControlColourPicker*)sender; - m_pColorLabel->setString(CCString::createWithFormat("#%02X%02X%02X",pPicker->getColorValue().r, pPicker->getColorValue().g, pPicker->getColorValue().b)->getCString()); + m_pColorLabel->setString(CCString::createWithFormat("#%02X%02X%02X",pPicker->getColor().r, pPicker->getColor().g, pPicker->getColor().b)->getCString()); } diff --git a/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp new file mode 100644 index 0000000000..e9df102d65 --- /dev/null +++ b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2012 cocos2d-x.org + * Copyright (c) 2012 Yannick Loriot + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#include "CCControlPotentiometerTest.h" + +CCControlPotentiometerTest::CCControlPotentiometerTest() +: m_pDisplayValueLabel(NULL) +{ + +} + +CCControlPotentiometerTest::~CCControlPotentiometerTest() +{ + CC_SAFE_RELEASE(m_pDisplayValueLabel); +} + +bool CCControlPotentiometerTest::init() +{ + if (CCControlScene::init()) + { + CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); + + CCNode *layer = CCNode::create(); + layer->setPosition(ccp (screenSize.width / 2, screenSize.height / 2)); + this->addChild(layer, 1); + + double layer_width = 0; + + // Add the black background for the text + CCScale9Sprite *background = CCScale9Sprite::create("extensions/buttonBackground.png"); + background->setContentSize(CCSizeMake(80, 50)); + background->setPosition(ccp(layer_width + background->getContentSize().width / 2.0f, 0)); + layer->addChild(background); + + layer_width += background->getContentSize().width; + + this->setDisplayValueLabel(CCLabelTTF::create("", "HelveticaNeue-Bold", 30)); + + m_pDisplayValueLabel->setPosition(background->getPosition()); + layer->addChild(m_pDisplayValueLabel); + + // Add the slider + CCControlPotentiometer *potentiometer = CCControlPotentiometer::create("extensions/potentiometerTrack.png" + ,"extensions/potentiometerProgress.png" + ,"extensions/potentiometerButton.png"); + potentiometer->setPosition(ccp (layer_width + 10 + potentiometer->getContentSize().width / 2, 0)); + + // When the value of the slider will change, the given selector will be call + potentiometer->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlPotentiometerTest::valueChanged), CCControlEventValueChanged); + + layer->addChild(potentiometer); + + layer_width += potentiometer->getContentSize().width; + + // Set the layer size + layer->setContentSize(CCSizeMake(layer_width, 0)); + layer->setAnchorPoint(ccp (0.5f, 0.5f)); + + // Update the value label + this->valueChanged(potentiometer, CCControlEventValueChanged); + return true; + } + return false; +} + +void CCControlPotentiometerTest::valueChanged(CCObject *sender, CCControlEvent controlEvent) +{ + CCControlPotentiometer* pControl = (CCControlPotentiometer*)sender; + // Change value of label. + m_pDisplayValueLabel->setString(CCString::createWithFormat("%.02f", pControl->getValue())->getCString()); +} + diff --git a/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.h b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.h new file mode 100644 index 0000000000..b76f327d15 --- /dev/null +++ b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2012 cocos2d-x.org + * Copyright (c) 2012 Yannick Loriot + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#ifndef __CCCONTROLPOTENTIOMETERTEST_H__ +#define __CCCONTROLPOTENTIOMETERTEST_H__ + +#include "../CCControlScene.h" + +class CCControlPotentiometerTest : public CCControlScene +{ +public: + CCControlPotentiometerTest(); + virtual ~CCControlPotentiometerTest(); + bool init(); + CC_SYNTHESIZE_RETAIN(CCLabelTTF*, m_pDisplayValueLabel, DisplayValueLabel) + + void valueChanged(CCObject *sender, CCControlEvent controlEvent); + + CONTROL_SCENE_CREATE_FUNC(CCControlPotentiometerTest) +}; + + +#endif /* __CCCONTROLPOTENTIOMETERTEST_H__ */ + diff --git a/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.cpp b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.cpp index 4fc19c49b8..a0c419359c 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.cpp +++ b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.cpp @@ -29,6 +29,8 @@ #include "CCControlColourPicker/CCControlColourPickerTest.h" #include "CCControlSliderTest/CCControlSliderTest.h" #include "CCControlSwitchTest/CCControlSwitchTest.h" +#include "CCControlPotentiometerTest/CCControlPotentiometerTest.h" +#include "CCControlStepperTest/CCControlStepperTest.h" USING_NS_CC; @@ -40,6 +42,8 @@ enum kCCControlButtonTest_HelloVariableSize, kCCControlButtonTest_Event, kCCControlButtonTest_Styling, + kCCControlPotentiometerTest, + kCCControlStepperTest, kCCControlTestMax }; @@ -49,7 +53,9 @@ static const char* s_testArray[] = { "ControlSwitchTest", "ControlButtonTest_HelloVariableSize", "ControlButtonTest_Event", - "ControlButtonTest_Styling" + "ControlButtonTest_Styling", + "ControlPotentiometerTest", + "CCControlStepperTest" }; static CCControlSceneManager *sharedInstance = NULL; @@ -102,6 +108,8 @@ CCScene *CCControlSceneManager::currentControlScene() case kCCControlButtonTest_HelloVariableSize:return CCControlButtonTest_HelloVariableSize::sceneWithTitle(s_testArray[m_nCurrentControlSceneId]); case kCCControlButtonTest_Event:return CCControlButtonTest_Event::sceneWithTitle(s_testArray[m_nCurrentControlSceneId]); case kCCControlButtonTest_Styling:return CCControlButtonTest_Styling::sceneWithTitle(s_testArray[m_nCurrentControlSceneId]); + case kCCControlPotentiometerTest:return CCControlPotentiometerTest::sceneWithTitle(s_testArray[m_nCurrentControlSceneId]); + case kCCControlStepperTest:return CCControlStepperTest::sceneWithTitle(s_testArray[m_nCurrentControlSceneId]); } return NULL; } diff --git a/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp new file mode 100644 index 0000000000..90b77c8327 --- /dev/null +++ b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2012 cocos2d-x.org + * Copyright (c) 2012 Yannick Loriot + * http://yannickloriot.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#include "CCControlStepperTest.h" + +CCControlStepperTest::CCControlStepperTest() +: m_pDisplayValueLabel(NULL) +{ + +} + +CCControlStepperTest::~CCControlStepperTest() +{ + CC_SAFE_RELEASE(m_pDisplayValueLabel); +} + +bool CCControlStepperTest::init() +{ + if (CCControlScene::init()) + { + CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); + + CCNode *layer = CCNode::create(); + layer->setPosition(ccp (screenSize.width / 2, screenSize.height / 2)); + this->addChild(layer, 1); + + double layer_width = 0; + + // Add the black background for the text + CCScale9Sprite *background = CCScale9Sprite::create("extensions/buttonBackground.png"); + background->setContentSize(CCSizeMake(100, 50)); + background->setPosition(ccp(layer_width + background->getContentSize().width / 2.0f, 0)); + layer->addChild(background); + + this->setDisplayValueLabel(CCLabelTTF::create("0", "HelveticaNeue-Bold", 30)); + + m_pDisplayValueLabel->setPosition(background->getPosition()); + layer->addChild(m_pDisplayValueLabel); + + layer_width += background->getContentSize().width; + + CCControlStepper *stepper = this->makeControlStepper(); + stepper->setPosition(ccp (layer_width + 10 + stepper->getContentSize().width / 2, 0)); + stepper->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlStepperTest::valueChanged), CCControlEventValueChanged); + layer->addChild(stepper); + + layer_width += stepper->getContentSize().width; + + // Set the layer size + layer->setContentSize(CCSizeMake(layer_width, 0)); + layer->setAnchorPoint(ccp (0.5f, 0.5f)); + + // Update the value label + this->valueChanged(stepper, CCControlEventValueChanged); + return true; + } + return false; +} + +CCControlStepper *CCControlStepperTest::makeControlStepper() +{ + CCSprite *minusSprite = CCSprite::create("extensions/stepper-minus.png"); + CCSprite *plusSprite = CCSprite::create("extensions/stepper-plus.png"); + + return CCControlStepper::create(minusSprite, plusSprite); +} + +void CCControlStepperTest::valueChanged(CCObject *sender, CCControlEvent controlEvent) +{ + CCControlStepper* pControl = (CCControlStepper*)sender; + // Change value of label. + m_pDisplayValueLabel->setString(CCString::createWithFormat("%0.02f", (float)pControl->getValue())->getCString()); +} + diff --git a/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.h b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.h new file mode 100644 index 0000000000..174917fa73 --- /dev/null +++ b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2012 cocos2d-x.org + * Copyright (c) 2012 Yannick Loriot + * http://yannickloriot.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#ifndef __CCCONTROLSTEPPERTEST_H__ +#define __CCCONTROLSTEPPERTEST_H__ + +#include "../CCControlScene.h" + +class CCControlStepperTest : public CCControlScene +{ +public: + CCControlStepperTest(); + virtual ~CCControlStepperTest(); + bool init(); + /** Creates and returns a new ControlStepper. */ + CCControlStepper* makeControlStepper(); + + /** Callback for the change value. */ + void valueChanged(CCObject *sender, CCControlEvent controlEvent); +protected: + CC_SYNTHESIZE_RETAIN(CCLabelTTF*, m_pDisplayValueLabel, DisplayValueLabel) + CONTROL_SCENE_CREATE_FUNC(CCControlStepperTest) +}; + +#endif /* __CCCONTROLSTEPPERTEST_H__ */ + diff --git a/samples/TestCpp/proj.win32/TestCpp.vcproj b/samples/TestCpp/proj.win32/TestCpp.vcproj index 0ccd95ae80..ee8c75b63b 100644 --- a/samples/TestCpp/proj.win32/TestCpp.vcproj +++ b/samples/TestCpp/proj.win32/TestCpp.vcproj @@ -874,6 +874,30 @@ > + + + + + + + + + + + + + + @@ -194,6 +196,8 @@ + + diff --git a/samples/TestCpp/proj.win32/TestCpp.vcxproj.filters b/samples/TestCpp/proj.win32/TestCpp.vcxproj.filters index ee747ea454..79976ce976 100644 --- a/samples/TestCpp/proj.win32/TestCpp.vcxproj.filters +++ b/samples/TestCpp/proj.win32/TestCpp.vcxproj.filters @@ -196,6 +196,12 @@ {e8752620-8414-4f43-a572-5fa82650f223} + + {08850f9d-e7e5-4bca-ae90-cf8df391479f} + + + {7e809230-9bb5-45bb-a26c-b5cdd1390914} + @@ -447,6 +453,12 @@ Classes\ExtensionsTest\AnimationsTest + + Classes\ExtensionsTest\ControlExtensionTest\CCControlPotentiometerTest + + + Classes\ExtensionsTest\ControlExtensionTest\CCControlStepperTest + @@ -875,5 +887,11 @@ Classes\ExtensionsTest\AnimationsTest + + Classes\ExtensionsTest\ControlExtensionTest\CCControlPotentiometerTest + + + Classes\ExtensionsTest\ControlExtensionTest\CCControlStepperTest + \ No newline at end of file From 83fe21b4f43abdf42515af4243d95fa3ed2ae42e Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 25 Sep 2012 17:03:29 +0800 Subject: [PATCH 135/181] issue #1483: Removed a comment. --- extensions/GUI/CCControlExtension/CCControl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/GUI/CCControlExtension/CCControl.h b/extensions/GUI/CCControlExtension/CCControl.h index 1de9fe42b7..1c340ee9aa 100644 --- a/extensions/GUI/CCControlExtension/CCControl.h +++ b/extensions/GUI/CCControlExtension/CCControl.h @@ -129,7 +129,7 @@ protected: * target-actions pairs. For each CCButtonEvents a list of NSInvocation * (which contains the target-action pair) is linked. */ - CCDictionary* m_pDispatchTable; //cjh need to be retained + CCDictionary* m_pDispatchTable; public: CCControl(); From 418816ea773be96494283d6cb4140dddd752d3ff Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 25 Sep 2012 17:06:59 +0800 Subject: [PATCH 136/181] add fps_image.png into TestCpp --- .../proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id index d3eb89e997..8a60780539 100644 --- a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -cbe8a4c43be345c2fcb9b0e46e02ef3a1fc21c80 \ No newline at end of file +ac587f51ddf162f82f3d28d80f9f3d2b4687ad41 \ No newline at end of file From d91d7c8317b3786e85b31066d3f1f81296f7f8e8 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 25 Sep 2012 17:26:09 +0800 Subject: [PATCH 137/181] issue #1483: Added LICENSE_CCControlExtension.txt, and added license information for headers of CCControlExtension. --- extensions/ExtensionMacros.h | 24 ++ .../GUI/CCControlExtension/CCControl.cpp | 41 +-- extensions/GUI/CCControlExtension/CCControl.h | 91 +++--- .../CCControlExtension/CCControlButton.cpp | 5 +- .../GUI/CCControlExtension/CCControlButton.h | 11 +- .../CCControlColourPicker.cpp | 41 +-- .../CCControlColourPicker.h | 3 +- .../CCControlExtension/CCControlExtensions.h | 34 ++- .../CCControlExtension/CCControlHuePicker.cpp | 43 +-- .../CCControlExtension/CCControlHuePicker.h | 3 +- .../CCControlPotentiometer.cpp | 3 +- .../CCControlPotentiometer.h | 3 +- .../CCControlSaturationBrightnessPicker.cpp | 21 +- .../CCControlSaturationBrightnessPicker.h | 3 +- .../CCControlExtension/CCControlSlider.cpp | 135 ++++----- .../GUI/CCControlExtension/CCControlSlider.h | 7 +- .../CCControlExtension/CCControlStepper.cpp | 3 +- .../GUI/CCControlExtension/CCControlStepper.h | 3 +- .../CCControlExtension/CCControlSwitch.cpp | 4 +- .../GUI/CCControlExtension/CCControlSwitch.h | 3 +- .../GUI/CCControlExtension/CCControlUtils.cpp | 24 ++ .../GUI/CCControlExtension/CCControlUtils.h | 4 +- .../GUI/CCControlExtension/CCInvocation.cpp | 26 ++ .../GUI/CCControlExtension/CCInvocation.h | 27 +- .../GUI/CCControlExtension/CCScale9Sprite.cpp | 279 ++++++++++-------- .../GUI/CCControlExtension/CCScale9Sprite.h | 33 ++- licenses/LICENSE_CCControlExtension.txt | 24 ++ 27 files changed, 552 insertions(+), 346 deletions(-) create mode 100644 licenses/LICENSE_CCControlExtension.txt diff --git a/extensions/ExtensionMacros.h b/extensions/ExtensionMacros.h index 7ba5d628b1..618a1f5012 100644 --- a/extensions/ExtensionMacros.h +++ b/extensions/ExtensionMacros.h @@ -1,3 +1,27 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #ifndef __EXTENSIONMARCROS_H__ #define __EXTENSIONMARCROS_H__ diff --git a/extensions/GUI/CCControlExtension/CCControl.cpp b/extensions/GUI/CCControlExtension/CCControl.cpp index 3c4e76e5b6..02ce349e0e 100644 --- a/extensions/GUI/CCControlExtension/CCControl.cpp +++ b/extensions/GUI/CCControlExtension/CCControl.cpp @@ -1,5 +1,6 @@ /* - * CCControl.m + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org * * Copyright 2011 Yannick Loriot. * http://yannickloriot.com @@ -302,19 +303,19 @@ CCArray* CCControl::dispatchListforControlEvent(CCControlEvent controlEvent) return invocationList; } -void CCControl::needsLayout() -{ +void CCControl::needsLayout() +{ } void CCControl::setEnabled(bool bEnabled) { m_bEnabled = bEnabled; - if(m_bEnabled) { - m_eState = CCControlStateNormal; - } else { - m_eState = CCControlStateDisabled; - } - + if(m_bEnabled) { + m_eState = CCControlStateNormal; + } else { + m_eState = CCControlStateDisabled; + } + this->needsLayout(); } @@ -345,17 +346,17 @@ bool CCControl::isHighlighted() return m_bHighlighted; } -bool CCControl::hasVisibleParents() -{ - CCNode* pParent = this->getParent(); - for( CCNode *c = pParent; c != NULL; c = c->getParent() ) - { - if( !c->isVisible() ) - { - return false; - } - } - return true; +bool CCControl::hasVisibleParents() +{ + CCNode* pParent = this->getParent(); + for( CCNode *c = pParent; c != NULL; c = c->getParent() ) + { + if( !c->isVisible() ) + { + return false; + } + } + return true; } NS_CC_EXT_END diff --git a/extensions/GUI/CCControlExtension/CCControl.h b/extensions/GUI/CCControlExtension/CCControl.h index 1c340ee9aa..b295123dfb 100644 --- a/extensions/GUI/CCControlExtension/CCControl.h +++ b/extensions/GUI/CCControlExtension/CCControl.h @@ -1,5 +1,6 @@ /* - * CCControl.h + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org * * Copyright 2011 Yannick Loriot. * http://yannickloriot.com @@ -72,17 +73,17 @@ enum }; typedef unsigned int CCControlState; -/* - * @class - * CCControl is inspired by the UIControl API class from the UIKit library of - * CocoaTouch. It provides a base class for control CCSprites such as CCButton - * or CCSlider that convey user intent to the application. - * - * The goal of CCControl is to define an interface and base implementation for - * preparing action messages and initially dispatching them to their targets when - * certain events occur. - * - * To use the CCControl you have to subclass it. +/* + * @class + * CCControl is inspired by the UIControl API class from the UIKit library of + * CocoaTouch. It provides a base class for control CCSprites such as CCButton + * or CCSlider that convey user intent to the application. + * + * The goal of CCControl is to define an interface and base implementation for + * preparing action messages and initially dispatching them to their targets when + * certain events occur. + * + * To use the CCControl you have to subclass it. */ class CCControl : public CCLayer, public CCRGBAProtocol { @@ -99,8 +100,8 @@ class CCControl : public CCLayer, public CCRGBAProtocol /** The current control state constant. */ CC_SYNTHESIZE_READONLY(CCControlState, m_eState, State); - /** True if all of the controls parents are visible */ -protected: + /** True if all of the controls parents are visible */ +protected: bool m_hasVisibleParents; public: @@ -114,9 +115,9 @@ public: virtual void setHighlighted(bool bHighlighted); virtual bool isHighlighted(); bool hasVisibleParents(); - /** - * Updates the control layout using its current internal state. - */ + /** + * Updates the control layout using its current internal state. + */ virtual void needsLayout(); protected: @@ -124,10 +125,10 @@ protected: bool m_bSelected; bool m_bHighlighted; - /** - * Table of connection between the CCControlEvents and their associated - * target-actions pairs. For each CCButtonEvents a list of NSInvocation - * (which contains the target-action pair) is linked. + /** + * Table of connection between the CCControlEvents and their associated + * target-actions pairs. For each CCButtonEvents a list of NSInvocation + * (which contains the target-action pair) is linked. */ CCDictionary* m_pDispatchTable; @@ -185,7 +186,7 @@ public: */ virtual CCPoint getTouchLocation(CCTouch* touch); - + /** * Returns a boolean value that indicates whether a touch is inside the bounds * of the receiver. The given touch must be relative to the world. @@ -226,32 +227,32 @@ protected: */ // CCArray* dispatchListforControlEvent(CCControlEvent controlEvent); - /** - * Adds a target and action for a particular event to an internal dispatch - * table. - * The action message may optionnaly include the sender and the event as - * parameters, in that order. - * When you call this method, target is not retained. - * - * @param target The target objectthat is, the object to which the action - * message is sent. It cannot be nil. The target is not retained. - * @param action A selector identifying an action message. It cannot be NULL. - * @param controlEvent A control event for which the action message is sent. - * See "CCControlEvent" for constants. + /** + * Adds a target and action for a particular event to an internal dispatch + * table. + * The action message may optionnaly include the sender and the event as + * parameters, in that order. + * When you call this method, target is not retained. + * + * @param target The target objectthat is, the object to which the action + * message is sent. It cannot be nil. The target is not retained. + * @param action A selector identifying an action message. It cannot be NULL. + * @param controlEvent A control event for which the action message is sent. + * See "CCControlEvent" for constants. */ void addTargetWithActionForControlEvent(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent); - /** - * Removes a target and action for a particular event from an internal dispatch - * table. - * - * @param target The target objectthat is, the object to which the action - * message is sent. Pass nil to remove all targets paired with action and the - * specified control events. - * @param action A selector identifying an action message. Pass NULL to remove - * all action messages paired with target. - * @param controlEvent A control event for which the action message is sent. - * See "CCControlEvent" for constants. + /** + * Removes a target and action for a particular event from an internal dispatch + * table. + * + * @param target The target objectthat is, the object to which the action + * message is sent. Pass nil to remove all targets paired with action and the + * specified control events. + * @param action A selector identifying an action message. Pass NULL to remove + * all action messages paired with target. + * @param controlEvent A control event for which the action message is sent. + * See "CCControlEvent" for constants. */ void removeTargetWithActionForControlEvent(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent); diff --git a/extensions/GUI/CCControlExtension/CCControlButton.cpp b/extensions/GUI/CCControlExtension/CCControlButton.cpp index 37b40efe20..82e0c3cba5 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.cpp +++ b/extensions/GUI/CCControlExtension/CCControlButton.cpp @@ -1,5 +1,6 @@ /* - * CCControlButton.m + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org * * Copyright 2011 Yannick Loriot. * http://yannickloriot.com @@ -500,7 +501,7 @@ void CCControlButton::setBackgroundSpriteForState(CCScale9Sprite* sprite, CCCont { if (oldPreferredSize.equals(m_preferredSize)) { - // Force update of preferred size + // Force update of preferred size sprite->setPreferredSize(CCSizeMake(oldPreferredSize.width+1, oldPreferredSize.height+1)); } diff --git a/extensions/GUI/CCControlExtension/CCControlButton.h b/extensions/GUI/CCControlExtension/CCControlButton.h index ea5c3b3877..69ac69eac9 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.h +++ b/extensions/GUI/CCControlExtension/CCControlButton.h @@ -1,5 +1,6 @@ /* - * CCControlButton.h + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org * * Copyright 2011 Yannick Loriot. All rights reserved. * http://yannickloriot.com @@ -35,10 +36,10 @@ NS_CC_EXT_BEGIN -/* Define the button margin for Left/Right edge */ -#define CCControlButtonMarginLR 8 // px -/* Define the button margin for Top/Bottom edge */ -#define CCControlButtonMarginTB 2 // px +/* Define the button margin for Left/Right edge */ +#define CCControlButtonMarginLR 8 // px +/* Define the button margin for Top/Bottom edge */ +#define CCControlButtonMarginTB 2 // px /** diff --git a/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp b/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp index b4381b4c50..2de4e1bc0d 100644 --- a/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp +++ b/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp @@ -1,5 +1,6 @@ /* - * CCControlColourPicker.m + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org * * Copyright 2012 Stewart Hamilton-Arrandale. * http://creativewax.co.uk @@ -49,19 +50,19 @@ CCControlColourPicker::~CCControlColourPicker() { m_background->removeFromParentAndCleanup(true); } - + if (m_huePicker) { m_huePicker->removeFromParentAndCleanup(true); - } - - if (m_colourPicker) - { - m_colourPicker->removeFromParentAndCleanup(true); - } - - m_background = NULL; - m_huePicker = NULL; + } + + if (m_colourPicker) + { + m_colourPicker->removeFromParentAndCleanup(true); + } + + m_background = NULL; + m_huePicker = NULL; m_colourPicker = NULL; } @@ -147,18 +148,18 @@ void CCControlColourPicker::setColor(const ccColor3B& color) updateHueAndControlPicker(); } -void CCControlColourPicker::setEnabled(bool enabled) -{ - CCControl::setEnabled(enabled); +void CCControlColourPicker::setEnabled(bool enabled) +{ + CCControl::setEnabled(enabled); if (m_huePicker != NULL) { m_huePicker->setEnabled(enabled); - } - if (m_colourPicker) - { - m_colourPicker->setEnabled(enabled); - } -} + } + if (m_colourPicker) + { + m_colourPicker->setEnabled(enabled); + } +} //need two events to prevent an infinite loop! (can't update huePicker when the huePicker triggers the callback due to CCControlEventValueChanged) diff --git a/extensions/GUI/CCControlExtension/CCControlColourPicker.h b/extensions/GUI/CCControlExtension/CCControlColourPicker.h index e8748d3977..804f3465c3 100644 --- a/extensions/GUI/CCControlExtension/CCControlColourPicker.h +++ b/extensions/GUI/CCControlExtension/CCControlColourPicker.h @@ -1,5 +1,6 @@ /* - * CCControlColourPicker.h + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org * * Copyright 2012 Stewart Hamilton-Arrandale. * http://creativewax.co.uk diff --git a/extensions/GUI/CCControlExtension/CCControlExtensions.h b/extensions/GUI/CCControlExtension/CCControlExtensions.h index 6b82369171..bda22946b4 100644 --- a/extensions/GUI/CCControlExtension/CCControlExtensions.h +++ b/extensions/GUI/CCControlExtension/CCControlExtensions.h @@ -1,6 +1,30 @@ -#ifndef __CCCONTROL_EXTENSIONS_H__ -#define __CCCONTROL_EXTENSIONS_H__ - +/**************************************************************************** +Copyright (c) 2012 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + +#ifndef __CCCONTROL_EXTENSIONS_H__ +#define __CCCONTROL_EXTENSIONS_H__ + #include "CCScale9Sprite.h" #include "CCControl.h" #include "CCControlButton.h" @@ -8,6 +32,6 @@ #include "CCControlPotentiometer.h" #include "CCControlSlider.h" #include "CCControlStepper.h" -#include "CCControlSwitch.h" - +#include "CCControlSwitch.h" + #endif \ No newline at end of file diff --git a/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp b/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp index 40c3e1417e..d57c701d6b 100644 --- a/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp +++ b/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp @@ -1,5 +1,6 @@ /* - * CCControlHuePicker.m + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org * * Copyright 2012 Stewart Hamilton-Arrandale. * http://creativewax.co.uk @@ -44,8 +45,8 @@ CCControlHuePicker::CCControlHuePicker() CCControlHuePicker::~CCControlHuePicker() { - removeAllChildrenWithCleanup(true); - CC_SAFE_RELEASE(m_background); + removeAllChildrenWithCleanup(true); + CC_SAFE_RELEASE(m_background); CC_SAFE_RELEASE(m_slider); } @@ -89,8 +90,8 @@ bool CCControlHuePicker::initWithTargetAndPos(CCNode* target, CCPoint pos) void CCControlHuePicker::setHue(float hueValue) { m_hue=hueValue; - // Set the position of the slider to the correct hue - // We need to divide it by 360 as its taken as an angle in degrees + // Set the position of the slider to the correct hue + // We need to divide it by 360 as its taken as an angle in degrees float huePercentage = hueValue / 360.0f; setHuePercentage(huePercentage); } @@ -121,13 +122,13 @@ void CCControlHuePicker::setHuePercentage(float hueValueInPercent) } -void CCControlHuePicker::setEnabled(bool enabled) -{ - CCControl::setEnabled(enabled); - if (m_slider != NULL) - { - m_slider->setOpacity(enabled ? 255 : 128); - } +void CCControlHuePicker::setEnabled(bool enabled) +{ + CCControl::setEnabled(enabled); + if (m_slider != NULL) + { + m_slider->setOpacity(enabled ? 255 : 128); + } } void CCControlHuePicker::updateSliderPosition(CCPoint location) @@ -157,15 +158,15 @@ void CCControlHuePicker::updateSliderPosition(CCPoint location) bool CCControlHuePicker::checkSliderPosition(CCPoint location) { - // compute the distance between the current location and the center - double distance = sqrt(pow (location.x + 10, 2) + pow(location.y, 2)); - - // check that the touch location is within the circle - if (160 > distance && distance > 118) - { - updateSliderPosition(location); - return true; - } + // compute the distance between the current location and the center + double distance = sqrt(pow (location.x + 10, 2) + pow(location.y, 2)); + + // check that the touch location is within the circle + if (160 > distance && distance > 118) + { + updateSliderPosition(location); + return true; + } return false; } diff --git a/extensions/GUI/CCControlExtension/CCControlHuePicker.h b/extensions/GUI/CCControlExtension/CCControlHuePicker.h index eb30667715..7bd9f02789 100644 --- a/extensions/GUI/CCControlExtension/CCControlHuePicker.h +++ b/extensions/GUI/CCControlExtension/CCControlHuePicker.h @@ -1,5 +1,6 @@ /* - * CCControlHuePicker.h + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org * * Copyright 2012 Stewart Hamilton-Arrandale. * http://creativewax.co.uk diff --git a/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp b/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp index 3de9af6b5c..41c258e925 100644 --- a/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp +++ b/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp @@ -1,5 +1,6 @@ /* - * CCControlPotentiometer.m + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org * * Copyright 2012 Yannick Loriot. All rights reserved. * http://yannickloriot.com diff --git a/extensions/GUI/CCControlExtension/CCControlPotentiometer.h b/extensions/GUI/CCControlExtension/CCControlPotentiometer.h index 728cce127d..98a6d4d58c 100644 --- a/extensions/GUI/CCControlExtension/CCControlPotentiometer.h +++ b/extensions/GUI/CCControlExtension/CCControlPotentiometer.h @@ -1,5 +1,6 @@ /* - * CCControlPotentiometer.h + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org * * Copyright 2012 Yannick Loriot. All rights reserved. * http://yannickloriot.com diff --git a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp index 3e3d42034c..712702fedc 100644 --- a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp @@ -1,5 +1,6 @@ /* - * CCControlSaturationBrightnessPicker.m + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org * * Copyright 2012 Stewart Hamilton-Arrandale. * http://creativewax.co.uk @@ -48,11 +49,11 @@ CCControlSaturationBrightnessPicker::CCControlSaturationBrightnessPicker() CCControlSaturationBrightnessPicker::~CCControlSaturationBrightnessPicker() { - removeAllChildrenWithCleanup(true); - - m_background = NULL; - m_overlay = NULL; - m_shadow = NULL; + removeAllChildrenWithCleanup(true); + + m_background = NULL; + m_overlay = NULL; + m_shadow = NULL; m_slider = NULL; } @@ -91,13 +92,13 @@ CCControlSaturationBrightnessPicker* CCControlSaturationBrightnessPicker::create return pRet; } -void CCControlSaturationBrightnessPicker::setEnabled(bool enabled) -{ - CCControl::setEnabled(enabled); +void CCControlSaturationBrightnessPicker::setEnabled(bool enabled) +{ + CCControl::setEnabled(enabled); if (m_slider != NULL) { m_slider->setOpacity(enabled ? 255 : 128); - } + } } void CCControlSaturationBrightnessPicker::updateWithHSV(HSV hsv) diff --git a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h index 038e3512e4..300e901b88 100644 --- a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h +++ b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h @@ -1,5 +1,6 @@ /* - * CCControlSaturationBrightnessPicker.h + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org * * Copyright 2012 Stewart Hamilton-Arrandale. * http://creativewax.co.uk diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.cpp b/extensions/GUI/CCControlExtension/CCControlSlider.cpp index dc17712299..d6b5981609 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSlider.cpp @@ -1,5 +1,6 @@ /* - * CCControlSlider + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org * * Copyright 2011 Yannick Loriot. * http://yannickloriot.com @@ -89,8 +90,8 @@ CCControlSlider* CCControlSlider::create(CCSprite * backgroundSprite, CCSprite* { if (CCControl::init()) { - CCAssert(backgroundSprite, "Background sprite must be not nil"); - CCAssert(progressSprite, "Progress sprite must be not nil"); + CCAssert(backgroundSprite, "Background sprite must be not nil"); + CCAssert(progressSprite, "Progress sprite must be not nil"); CCAssert(thumbSprite, "Thumb sprite must be not nil"); ignoreAnchorPointForPosition(false); @@ -133,32 +134,32 @@ CCControlSlider* CCControlSlider::create(CCSprite * backgroundSprite, CCSprite* } -void CCControlSlider::setEnabled(bool enabled) -{ - CCControl::setEnabled(enabled); - if (m_thumbSprite != NULL) - { - m_thumbSprite->setOpacity((enabled) ? 255 : 128); - } +void CCControlSlider::setEnabled(bool enabled) +{ + CCControl::setEnabled(enabled); + if (m_thumbSprite != NULL) + { + m_thumbSprite->setOpacity((enabled) ? 255 : 128); + } } void CCControlSlider::setValue(float value) { - // set new value with sentinel - if (value < m_minimumValue) - { - value = m_minimumValue; - } - - if (value > m_maximumValue) - { - value = m_maximumValue; - } - - m_value = value; - - this->needsLayout(); - + // set new value with sentinel + if (value < m_minimumValue) + { + value = m_minimumValue; + } + + if (value > m_maximumValue) + { + value = m_maximumValue; + } + + m_value = value; + + this->needsLayout(); + this->sendActionsForControlEvents(CCControlEventValueChanged); } @@ -183,34 +184,34 @@ void CCControlSlider::setEnabled(bool enabled) } setValue(m_value); } - -bool CCControlSlider::isTouchInside(CCTouch * touch) -{ - CCPoint touchLocation = touch->getLocation(); - touchLocation = this->getParent()->convertToNodeSpace(touchLocation); - - CCRect rect = this->boundingBox(); - rect.size.width += m_thumbSprite->getContentSize().width; - rect.origin.x -= m_thumbSprite->getContentSize().width / 2; - - return rect.containsPoint(touchLocation); -} - -CCPoint CCControlSlider::locationFromTouch(CCTouch* touch) -{ - CCPoint touchLocation = touch->getLocation(); // Get the touch position - touchLocation = this->convertToNodeSpace(touchLocation); // Convert to the node space of this class - - if (touchLocation.x < 0) - { - touchLocation.x = 0; - } else if (touchLocation.x > m_backgroundSprite->getContentSize().width) - { - touchLocation.x = m_backgroundSprite->getContentSize().width; - } - - return touchLocation; -} + +bool CCControlSlider::isTouchInside(CCTouch * touch) +{ + CCPoint touchLocation = touch->getLocation(); + touchLocation = this->getParent()->convertToNodeSpace(touchLocation); + + CCRect rect = this->boundingBox(); + rect.size.width += m_thumbSprite->getContentSize().width; + rect.origin.x -= m_thumbSprite->getContentSize().width / 2; + + return rect.containsPoint(touchLocation); +} + +CCPoint CCControlSlider::locationFromTouch(CCTouch* touch) +{ + CCPoint touchLocation = touch->getLocation(); // Get the touch position + touchLocation = this->convertToNodeSpace(touchLocation); // Convert to the node space of this class + + if (touchLocation.x < 0) + { + touchLocation.x = 0; + } else if (touchLocation.x > m_backgroundSprite->getContentSize().width) + { + touchLocation.x = m_backgroundSprite->getContentSize().width; + } + + return touchLocation; +} bool CCControlSlider::ccTouchBegan(CCTouch* touch, CCEvent* pEvent) @@ -234,23 +235,23 @@ void CCControlSlider::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent) sliderEnded(CCPointZero); } -void CCControlSlider::needsLayout() -{ +void CCControlSlider::needsLayout() +{ if (NULL == m_thumbSprite || NULL == m_backgroundSprite || NULL == m_progressSprite) { return; - } - // Update thumb position for new value - float percent = (m_value - m_minimumValue) / (m_maximumValue - m_minimumValue); - - CCPoint pos = m_thumbSprite->getPosition(); - pos.x = percent * m_backgroundSprite->getContentSize().width; - m_thumbSprite->setPosition(pos); - - // Stretches content proportional to newLevel - CCRect textureRect = m_progressSprite->getTextureRect(); - textureRect = CCRectMake(textureRect.origin.x, textureRect.origin.y, pos.x, textureRect.size.height); - m_progressSprite->setTextureRect(textureRect, m_progressSprite->isTextureRectRotated(), textureRect.size); + } + // Update thumb position for new value + float percent = (m_value - m_minimumValue) / (m_maximumValue - m_minimumValue); + + CCPoint pos = m_thumbSprite->getPosition(); + pos.x = percent * m_backgroundSprite->getContentSize().width; + m_thumbSprite->setPosition(pos); + + // Stretches content proportional to newLevel + CCRect textureRect = m_progressSprite->getTextureRect(); + textureRect = CCRectMake(textureRect.origin.x, textureRect.origin.y, pos.x, textureRect.size.height); + m_progressSprite->setTextureRect(textureRect, m_progressSprite->isTextureRectRotated(), textureRect.size); } void CCControlSlider::sliderBegan(CCPoint location) diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.h b/extensions/GUI/CCControlExtension/CCControlSlider.h index cebf5d580e..84ab207bcb 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.h +++ b/extensions/GUI/CCControlExtension/CCControlSlider.h @@ -1,5 +1,6 @@ /* - * CCControlSlider + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org * * Copyright 2011 Yannick Loriot. All rights reserved. * http://yannickloriot.com @@ -47,11 +48,11 @@ class CCControlSlider: public CCControl /** Contains the receivers current value. */ CC_SYNTHESIZE_READONLY(float, m_value, Value); virtual void setValue(float val); - /** Contains the minimum value of the receiver. + /** Contains the minimum value of the receiver. * The default value of this property is 0.0. */ CC_SYNTHESIZE_READONLY(float, m_minimumValue, MinimumValue); virtual void setMinimumValue(float val); - /** Contains the maximum value of the receiver. + /** Contains the maximum value of the receiver. * The default value of this property is 1.0. */ CC_SYNTHESIZE_READONLY(float, m_maximumValue, MaximumValue); virtual void setMaximumValue(float val); diff --git a/extensions/GUI/CCControlExtension/CCControlStepper.cpp b/extensions/GUI/CCControlExtension/CCControlStepper.cpp index bcc0828799..a6a0db2108 100644 --- a/extensions/GUI/CCControlExtension/CCControlStepper.cpp +++ b/extensions/GUI/CCControlExtension/CCControlStepper.cpp @@ -1,5 +1,6 @@ /* - * CCControlStepper.m + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org * * Copyright 2012 Yannick Loriot. All rights reserved. * http://yannickloriot.com diff --git a/extensions/GUI/CCControlExtension/CCControlStepper.h b/extensions/GUI/CCControlExtension/CCControlStepper.h index 51fab80cbc..01e763286a 100644 --- a/extensions/GUI/CCControlExtension/CCControlStepper.h +++ b/extensions/GUI/CCControlExtension/CCControlStepper.h @@ -1,5 +1,6 @@ /* - * CCControlStepper.h + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org * * Copyright 2012 Yannick Loriot. All rights reserved. * http://yannickloriot.com diff --git a/extensions/GUI/CCControlExtension/CCControlSwitch.cpp b/extensions/GUI/CCControlExtension/CCControlSwitch.cpp index 36cc11210e..30ad1bf0d6 100644 --- a/extensions/GUI/CCControlExtension/CCControlSwitch.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSwitch.cpp @@ -1,5 +1,7 @@ /* - * + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org + * * Copyright 2012 Yannick Loriot. All rights reserved. * http://yannickloriot.com * diff --git a/extensions/GUI/CCControlExtension/CCControlSwitch.h b/extensions/GUI/CCControlExtension/CCControlSwitch.h index e00dccc803..a17f8a08be 100644 --- a/extensions/GUI/CCControlExtension/CCControlSwitch.h +++ b/extensions/GUI/CCControlExtension/CCControlSwitch.h @@ -1,5 +1,6 @@ /* - * CCControlSwitch.h + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org * * Copyright 2012 Yannick Loriot. All rights reserved. * http://yannickloriot.com diff --git a/extensions/GUI/CCControlExtension/CCControlUtils.cpp b/extensions/GUI/CCControlExtension/CCControlUtils.cpp index 3a5d095796..226fb20351 100644 --- a/extensions/GUI/CCControlExtension/CCControlUtils.cpp +++ b/extensions/GUI/CCControlExtension/CCControlUtils.cpp @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2012 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + #include "CCControlUtils.h" #include "support/CCPointExtension.h" diff --git a/extensions/GUI/CCControlExtension/CCControlUtils.h b/extensions/GUI/CCControlExtension/CCControlUtils.h index ac2c4cfd74..aaf7093d10 100644 --- a/extensions/GUI/CCControlExtension/CCControlUtils.h +++ b/extensions/GUI/CCControlExtension/CCControlUtils.h @@ -1,5 +1,7 @@ /* - * ColourUtils.h + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org + * * * Copyright 2012 Stewart Hamilton-Arrandale. * http://creativewax.co.uk diff --git a/extensions/GUI/CCControlExtension/CCInvocation.cpp b/extensions/GUI/CCControlExtension/CCInvocation.cpp index ec1a7a6457..0838a66391 100644 --- a/extensions/GUI/CCControlExtension/CCInvocation.cpp +++ b/extensions/GUI/CCControlExtension/CCInvocation.cpp @@ -1,3 +1,29 @@ +/* + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * + * Converted to c++ / cocos2d-x by Angus C + */ + #include "CCInvocation.h" NS_CC_EXT_BEGIN diff --git a/extensions/GUI/CCControlExtension/CCInvocation.h b/extensions/GUI/CCControlExtension/CCInvocation.h index 3094f18b15..f6e1dfcd18 100644 --- a/extensions/GUI/CCControlExtension/CCInvocation.h +++ b/extensions/GUI/CCControlExtension/CCInvocation.h @@ -1,4 +1,29 @@ - /* +/* + * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * + * Converted to c++ / cocos2d-x by Angus C + */ +/* * * Helper class to store targets and selectors (and eventually, params?) in the same CCMutableArray. Basically a very crude form of a NSInvocation */ diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp index 545de4e20b..8f0220b1de 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp @@ -1,10 +1,29 @@ -// -// CCScale9Sprite.cpp -// PlantCaring -// -// Created by Jung Sang-Taik on 12. 3. 16.. -// Copyright (c) 2012 Neofect. All rights reserved. -// +/**************************************************************************** +Copyright (c) 2012 cocos2d-x.org + +http://www.cocos2d-x.org + +Created by Jung Sang-Taik on 12. 3. 16.. +Copyright (c) 2012 Neofect. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "CCScale9Sprite.h" @@ -28,20 +47,20 @@ CCScale9Sprite::CCScale9Sprite() , m_insetTop(0) , m_insetRight(0) , m_insetBottom(0) -, m_cOpacity(0) -, m_bSpritesGenerated(false) -, m_bSpriteFrameRotated(false) -, m_positionsAreDirty(false) -, scale9Image(NULL) -, topLeft(NULL) -, top(NULL) -, topRight(NULL) -, left(NULL) -, centre(NULL) -, right(NULL) -, bottomLeft(NULL) -, bottom(NULL) -, bottomRight(NULL) +, m_cOpacity(0) +, m_bSpritesGenerated(false) +, m_bSpriteFrameRotated(false) +, m_positionsAreDirty(false) +, scale9Image(NULL) +, topLeft(NULL) +, top(NULL) +, topRight(NULL) +, left(NULL) +, centre(NULL) +, right(NULL) +, bottomLeft(NULL) +, bottom(NULL) +, bottomRight(NULL) , m_bIsOpacityModifyRGB(false) { @@ -85,7 +104,7 @@ bool CCScale9Sprite::initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, bool rotated, CCRect capInsets) { - GLubyte opacity = m_cOpacity; + GLubyte opacity = m_cOpacity; ccColor3B color = m_tColor; // Release old sprites @@ -128,10 +147,10 @@ bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect re m_preferredSize = m_originalSize; m_capInsetsInternal = capInsets; - // Get the image edges - float l = rect.origin.x; - float t = rect.origin.y; - float h = rect.size.height; + // Get the image edges + float l = rect.origin.x; + float t = rect.origin.y; + float h = rect.size.height; float w = rect.size.width; // If there is no specified center region @@ -152,93 +171,93 @@ bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect re // Set up the image // if (rotated) - { - // Sprite frame is rotated - - // Centre - centre = new CCSprite(); - centre->initWithTexture(scale9Image->getTexture(), m_capInsetsInternal, true); - scale9Image->addChild(centre, 0, pCentre); - - // Bottom - bottom = new CCSprite(); - bottom->initWithTexture(scale9Image->getTexture(), CCRectMake(l, - m_capInsetsInternal.origin.y, - m_capInsetsInternal.size.width, - m_capInsetsInternal.origin.x - l), - rotated - ); - scale9Image->addChild(bottom, 1, pBottom); - - // Top - top = new CCSprite(); - top->initWithTexture(scale9Image->getTexture(),CCRectMake(m_capInsetsInternal.origin.x + m_capInsetsInternal.size.height, - m_capInsetsInternal.origin.y, - m_capInsetsInternal.size.width, - h - m_capInsetsInternal.size.height - (m_capInsetsInternal.origin.x - l)), - rotated - ); - scale9Image->addChild(top, 1, pTop); - - // Right - right = new CCSprite(); - right->initWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsetsInternal.origin.x, - m_capInsetsInternal.origin.y+m_capInsetsInternal.size.width, - w - (m_capInsetsInternal.origin.y-t)-m_capInsetsInternal.size.width, - m_capInsetsInternal.size.height), - rotated - ); - scale9Image->addChild(right, 1, pRight); - - // Left - left = new CCSprite(); - left->initWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsetsInternal.origin.x, - t, - m_capInsetsInternal.origin.y - t, - m_capInsetsInternal.size.height), - rotated - ); - scale9Image->addChild(left ,1, pLeft); - - // Top right - topRight = new CCSprite(); - topRight->initWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsetsInternal.origin.x + m_capInsetsInternal.size.height, - m_capInsetsInternal.origin.y + m_capInsetsInternal.size.width, - w - (m_capInsetsInternal.origin.y-t)-m_capInsetsInternal.size.width, - h - m_capInsetsInternal.size.height - (m_capInsetsInternal.origin.x - l)), - rotated - ); - scale9Image->addChild(topRight ,2 ,pTopRight); - - // Top left - topLeft = new CCSprite(); - topLeft->initWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsetsInternal.origin.x + m_capInsetsInternal.size.height, - t, - m_capInsetsInternal.origin.y - t, - h - m_capInsetsInternal.size.height - (m_capInsetsInternal.origin.x - l)), - rotated - ); - scale9Image->addChild(topLeft, 2, pTopLeft); - - // Bottom right - bottomRight = new CCSprite(); - bottomRight->initWithTexture(scale9Image->getTexture(),CCRectMake(l, - m_capInsetsInternal.origin.y + m_capInsetsInternal.size.width, - w - (m_capInsetsInternal.origin.y-t)-m_capInsetsInternal.size.width, - m_capInsetsInternal.origin.x - l), - rotated - ); - scale9Image->addChild(bottomRight, 2, pBottomRight); - - // Bottom left - bottomLeft = new CCSprite(); - bottomLeft->initWithTexture(scale9Image->getTexture(), CCRectMake(l, - t, - m_capInsetsInternal.origin.y - t, - m_capInsetsInternal.origin.x - l), - rotated - ); - scale9Image->addChild(bottomLeft, 2, pBottomLeft); + { + // Sprite frame is rotated + + // Centre + centre = new CCSprite(); + centre->initWithTexture(scale9Image->getTexture(), m_capInsetsInternal, true); + scale9Image->addChild(centre, 0, pCentre); + + // Bottom + bottom = new CCSprite(); + bottom->initWithTexture(scale9Image->getTexture(), CCRectMake(l, + m_capInsetsInternal.origin.y, + m_capInsetsInternal.size.width, + m_capInsetsInternal.origin.x - l), + rotated + ); + scale9Image->addChild(bottom, 1, pBottom); + + // Top + top = new CCSprite(); + top->initWithTexture(scale9Image->getTexture(),CCRectMake(m_capInsetsInternal.origin.x + m_capInsetsInternal.size.height, + m_capInsetsInternal.origin.y, + m_capInsetsInternal.size.width, + h - m_capInsetsInternal.size.height - (m_capInsetsInternal.origin.x - l)), + rotated + ); + scale9Image->addChild(top, 1, pTop); + + // Right + right = new CCSprite(); + right->initWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsetsInternal.origin.x, + m_capInsetsInternal.origin.y+m_capInsetsInternal.size.width, + w - (m_capInsetsInternal.origin.y-t)-m_capInsetsInternal.size.width, + m_capInsetsInternal.size.height), + rotated + ); + scale9Image->addChild(right, 1, pRight); + + // Left + left = new CCSprite(); + left->initWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsetsInternal.origin.x, + t, + m_capInsetsInternal.origin.y - t, + m_capInsetsInternal.size.height), + rotated + ); + scale9Image->addChild(left ,1, pLeft); + + // Top right + topRight = new CCSprite(); + topRight->initWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsetsInternal.origin.x + m_capInsetsInternal.size.height, + m_capInsetsInternal.origin.y + m_capInsetsInternal.size.width, + w - (m_capInsetsInternal.origin.y-t)-m_capInsetsInternal.size.width, + h - m_capInsetsInternal.size.height - (m_capInsetsInternal.origin.x - l)), + rotated + ); + scale9Image->addChild(topRight ,2 ,pTopRight); + + // Top left + topLeft = new CCSprite(); + topLeft->initWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsetsInternal.origin.x + m_capInsetsInternal.size.height, + t, + m_capInsetsInternal.origin.y - t, + h - m_capInsetsInternal.size.height - (m_capInsetsInternal.origin.x - l)), + rotated + ); + scale9Image->addChild(topLeft, 2, pTopLeft); + + // Bottom right + bottomRight = new CCSprite(); + bottomRight->initWithTexture(scale9Image->getTexture(),CCRectMake(l, + m_capInsetsInternal.origin.y + m_capInsetsInternal.size.width, + w - (m_capInsetsInternal.origin.y-t)-m_capInsetsInternal.size.width, + m_capInsetsInternal.origin.x - l), + rotated + ); + scale9Image->addChild(bottomRight, 2, pBottomRight); + + // Bottom left + bottomLeft = new CCSprite(); + bottomLeft->initWithTexture(scale9Image->getTexture(), CCRectMake(l, + t, + m_capInsetsInternal.origin.y - t, + m_capInsetsInternal.origin.x - l), + rotated + ); + scale9Image->addChild(bottomLeft, 2, pBottomLeft); } else { @@ -333,12 +352,12 @@ bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect re this->setContentSize(rect.size); this->addChild(scale9Image); - if (m_bSpritesGenerated) - { - // Restore color and opacity - this->setOpacity(opacity); - this->setColor(color); - } + if (m_bSpritesGenerated) + { + // Restore color and opacity + this->setOpacity(opacity); + this->setColor(color); + } m_bSpritesGenerated = true; return true; @@ -708,18 +727,18 @@ void CCScale9Sprite::updateCapInset() } else { - if (m_bSpriteFrameRotated) - { - insets = CCRectMake(m_spriteRect.origin.x + m_insetBottom, - m_spriteRect.origin.y + m_insetLeft, - m_spriteRect.size.width-m_insetRight-m_insetLeft, - m_spriteRect.size.height-m_insetTop-m_insetBottom); - } - else + if (m_bSpriteFrameRotated) { - insets = CCRectMake(m_spriteRect.origin.x + m_insetLeft, - m_spriteRect.origin.y + m_insetTop, - m_spriteRect.size.width-m_insetLeft-m_insetRight, + insets = CCRectMake(m_spriteRect.origin.x + m_insetBottom, + m_spriteRect.origin.y + m_insetLeft, + m_spriteRect.size.width-m_insetRight-m_insetLeft, + m_spriteRect.size.height-m_insetTop-m_insetBottom); + } + else + { + insets = CCRectMake(m_spriteRect.origin.x + m_insetLeft, + m_spriteRect.origin.y + m_insetTop, + m_spriteRect.size.width-m_insetLeft-m_insetRight, m_spriteRect.size.height-m_insetTop-m_insetBottom); } } diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.h b/extensions/GUI/CCControlExtension/CCScale9Sprite.h index 324f56c001..3bddeed826 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.h +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.h @@ -1,10 +1,29 @@ -// -// CCScale9Sprite.h -// PlantCaring -// -// Created by Jung Sang-Taik on 12. 3. 16.. -// Copyright (c) 2012 Neofect. All rights reserved. -// +/**************************************************************************** +Copyright (c) 2012 cocos2d-x.org + +http://www.cocos2d-x.org + +Created by Jung Sang-Taik on 12. 3. 16.. +Copyright (c) 2012 Neofect. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __CCScale9Sprite_H__ #define __CCScale9Sprite_H__ diff --git a/licenses/LICENSE_CCControlExtension.txt b/licenses/LICENSE_CCControlExtension.txt new file mode 100644 index 0000000000..bcd4f4d254 --- /dev/null +++ b/licenses/LICENSE_CCControlExtension.txt @@ -0,0 +1,24 @@ +/* + * + * Copyright 2012 Yannick Loriot. + * http://yannickloriot.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ \ No newline at end of file From 6878b626cd98a6064dc24351f8fc5081960a7a7a Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 25 Sep 2012 18:00:06 +0800 Subject: [PATCH 138/181] add new GUI component --- samples/TestCpp/Android.mk | 2 ++ .../proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/samples/TestCpp/Android.mk b/samples/TestCpp/Android.mk index 03b1baf841..57c0d33223 100644 --- a/samples/TestCpp/Android.mk +++ b/samples/TestCpp/Android.mk @@ -42,7 +42,9 @@ Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp \ Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.cpp \ Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp \ Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp \ +Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp \ Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp \ +Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp \ Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp \ Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp \ Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp \ diff --git a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id index 8a60780539..e56c8faf78 100644 --- a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -ac587f51ddf162f82f3d28d80f9f3d2b4687ad41 \ No newline at end of file +ac3dd574a71d609ed13ae44389209e35f22d6392 \ No newline at end of file From 4a3127f41f10678f25313386cb669d0db7b2705e Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 25 Sep 2012 21:52:30 +0800 Subject: [PATCH 139/181] Updated android template. Added 'cocos2dx/platform/android/java/res/.gitignore' since res folder is needed for eclipse. --- cocos2dx/platform/android/java/.project | 2 +- cocos2dx/platform/android/java/res/.gitignore | 0 samples/HelloCpp/proj.android/.project | 7 ------- template/android/copy_files.sh | 5 ----- 4 files changed, 1 insertion(+), 13 deletions(-) create mode 100644 cocos2dx/platform/android/java/res/.gitignore diff --git a/cocos2dx/platform/android/java/.project b/cocos2dx/platform/android/java/.project index 45ae73e116..9a978af554 100644 --- a/cocos2dx/platform/android/java/.project +++ b/cocos2dx/platform/android/java/.project @@ -1,6 +1,6 @@ - java + libcocos2dx diff --git a/cocos2dx/platform/android/java/res/.gitignore b/cocos2dx/platform/android/java/res/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/samples/HelloCpp/proj.android/.project b/samples/HelloCpp/proj.android/.project index ea1edd86d6..157527b4b7 100644 --- a/samples/HelloCpp/proj.android/.project +++ b/samples/HelloCpp/proj.android/.project @@ -30,11 +30,4 @@ com.android.ide.eclipse.adt.AndroidNature org.eclipse.jdt.core.javanature - - - src_common - 2 - PARENT-3-PROJECT_LOC/cocos2dx/platform/android/java/src_common - - diff --git a/template/android/copy_files.sh b/template/android/copy_files.sh index 3e3bcfd659..d102d0684e 100644 --- a/template/android/copy_files.sh +++ b/template/android/copy_files.sh @@ -45,10 +45,6 @@ copy_src_and_jni(){ sh $COCOS2DX_ROOT/template/android/gamemk.sh $APP_DIR/proj.android/jni/Android.mk $NEED_BOX2D $NEED_CHIPMUNK $NEED_LUA } -copy_library_src(){ - cp -rf $COCOSJAVALIB_ROOT/src_common/* $APP_DIR/proj.android/src/ -} - # copy build_native.sh and replace something copy_build_native(){ # here should use # instead of /, why?? @@ -95,7 +91,6 @@ copy_icon(){ copy_cpp_h copy_resouces copy_src_and_jni -copy_library_src copy_build_native modify_project_classpath modify_androidmanifest From fdb53e1e927d84ace2d62e974ec5430fa76538a4 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 25 Sep 2012 22:12:14 +0800 Subject: [PATCH 140/181] Added library dependence for create-android-project script. --- create-android-project.bat | 2 +- create-android-project.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/create-android-project.bat b/create-android-project.bat index 3b32ec9e92..a935eb3f15 100644 --- a/create-android-project.bat +++ b/create-android-project.bat @@ -36,7 +36,7 @@ echo Create android project mkdir %_PROJECTDIR% echo Create Android project inside proj.android call "%_ANDROIDTOOLS%\android.bat" create project -n %_PROJECTNAME% -t %_TARGETID% -k %_PACKAGEPATH% -a %_PROJECTNAME% -p %_PROJECTDIR%\proj.android - +call "%_ANDROIDTOOLS%\android.bat" update project -l ../../cocos2dx/platform/android/java -p %_PROJECTDIR%\proj.android :: Resolve ___.sh to /cygdrive based *nix path and store in %_CYGSCRIPT% for /f "delims=" %%A in ('%_CYGBIN%\cygpath.exe "%~dpn0.sh"') do set _CYGSCRIPT=%%A diff --git a/create-android-project.sh b/create-android-project.sh index 79d63ff2c8..b83370324b 100755 --- a/create-android-project.sh +++ b/create-android-project.sh @@ -117,6 +117,7 @@ create_android_project(){ mkdir $PROJECT_DIR # Create Android project inside proj.android $ANDROID_SDK_ROOT_LOCAL/tools/android create project -n $PROJECT_NAME -t $TARGET_ID -k $PACKAGE_PATH -a $PROJECT_NAME -p $PROJECT_DIR/proj.android + $ANDROID_SDK_ROOT_LOCAL/tools/android update project -l ../../cocos2dx/platform/android/java -p $PROJECT_DIR/proj.android } check_path From a245199075e608219ebe50352a88f9cb6b6d0b5e Mon Sep 17 00:00:00 2001 From: Donald Alan Morrison Date: Tue, 25 Sep 2012 10:13:49 -0700 Subject: [PATCH 141/181] Jianhua Chen pointed out a semantic error in my "fix". Thanks James! The Static Analyzer doesn't search for this semantic error, even though it is common. --- extensions/GUI/CCEditBox/EditBoxImplIOS.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/GUI/CCEditBox/EditBoxImplIOS.mm b/extensions/GUI/CCEditBox/EditBoxImplIOS.mm index 30bac05245..b889c54c3f 100644 --- a/extensions/GUI/CCEditBox/EditBoxImplIOS.mm +++ b/extensions/GUI/CCEditBox/EditBoxImplIOS.mm @@ -63,7 +63,7 @@ { if (self == nil) break; editState_ = NO; - textField_ = [[[CustomUITextField alloc] initWithFrame: frameRect] autorelease]; + self.textField = [[[CustomUITextField alloc] initWithFrame: frameRect] autorelease]; if (!textField_) break; [textField_ setTextColor:[UIColor whiteColor]]; textField_.font = [UIFont systemFontOfSize:frameRect.size.height*2/3]; //TODO need to delete hard code here. From 53889c5b3c21e9ef1310385a374d21e336f669b3 Mon Sep 17 00:00:00 2001 From: folecr Date: Tue, 25 Sep 2012 13:55:06 -0700 Subject: [PATCH 142/181] Fix comment. No functional changes. --- .../jenkins_scripts/mac/android/generate-js-cxx-bindings.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/jenkins_scripts/mac/android/generate-js-cxx-bindings.sh b/tools/jenkins_scripts/mac/android/generate-js-cxx-bindings.sh index f1ad4aec6a..ad6c5c9f33 100755 --- a/tools/jenkins_scripts/mac/android/generate-js-cxx-bindings.sh +++ b/tools/jenkins_scripts/mac/android/generate-js-cxx-bindings.sh @@ -3,11 +3,12 @@ # Generate JS bindings for Cocos2D-X # ... using Android NDK system headers -# Environment variables required +# Dependencies (see ../../../tojs/genbindings.sh +# ... for the defaults used if the environment is not customized) +# # * $PYTHON_BIN # * $CLANG_ROOT # * $NDK_ROOT -# * $COCOS2DX_ROOT compileresult=0 From 0dfa1b566be6b60da3823e05bacdd4c4b9e9d874 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 26 Sep 2012 11:16:44 +0800 Subject: [PATCH 143/181] Fixed compilation errors of blackberry platform. --- CocosDenshion/include/SimpleAudioEngine.h | 2 +- cocos2dx/include/ccTypeInfo.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CocosDenshion/include/SimpleAudioEngine.h b/CocosDenshion/include/SimpleAudioEngine.h index 8c9cf1c8c1..b180c67e47 100644 --- a/CocosDenshion/include/SimpleAudioEngine.h +++ b/CocosDenshion/include/SimpleAudioEngine.h @@ -40,7 +40,7 @@ public: virtual long getClassTypeInfo() = 0; }; -static unsigned int getHashCodeByString(const char *key) +static inline unsigned int getHashCodeByString(const char *key) { unsigned int len = strlen(key); const char *end=key+len; diff --git a/cocos2dx/include/ccTypeInfo.h b/cocos2dx/include/ccTypeInfo.h index 096c661003..c7eeeddf91 100644 --- a/cocos2dx/include/ccTypeInfo.h +++ b/cocos2dx/include/ccTypeInfo.h @@ -28,6 +28,8 @@ THE SOFTWARE. #include "platform/CCPlatformMacros.h" #include +#include +#include NS_CC_BEGIN @@ -37,7 +39,7 @@ public: virtual long getClassTypeInfo() = 0; }; -static unsigned int getHashCodeByString(const char *key) +static inline unsigned int getHashCodeByString(const char *key) { unsigned int len = strlen(key); const char *end=key+len; From dc3ba6e0cc7c3a2a3e67c7c58c9213a4b61ddb10 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 26 Sep 2012 12:01:42 +0800 Subject: [PATCH 144/181] fix some bugs when testing --- .../proj.mac/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- samples/TestLua/proj.android/build_native.sh | 0 2 files changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 samples/TestLua/proj.android/build_native.sh diff --git a/samples/TestCpp/proj.mac/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/TestCpp/proj.mac/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id index 86484a7483..54d31e8db3 100644 --- a/samples/TestCpp/proj.mac/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/TestCpp/proj.mac/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -35ee36aee350134dbe3d44c7a91b309972ea00ad \ No newline at end of file +bbbb2450a8de63794b1d5e2b00341086f5aee574 \ No newline at end of file diff --git a/samples/TestLua/proj.android/build_native.sh b/samples/TestLua/proj.android/build_native.sh old mode 100644 new mode 100755 From ac8edf1384409333c4616797f2bd2dcb115ec069 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 26 Sep 2012 14:06:49 +0800 Subject: [PATCH 145/181] Updated samples/TestCpp/proj.linux/Makefile. --- samples/TestCpp/proj.linux/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/TestCpp/proj.linux/Makefile b/samples/TestCpp/proj.linux/Makefile index e1d855df5f..f05c22528a 100644 --- a/samples/TestCpp/proj.linux/Makefile +++ b/samples/TestCpp/proj.linux/Makefile @@ -78,6 +78,8 @@ OBJECTS = ../Classes/AccelerometerTest/AccelerometerTest.o \ ../Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.o \ ../Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.o \ ../Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.o \ + ../Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.o \ + ../Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.o \ ../Classes/ExtensionsTest/TableViewTest/TableViewTestScene.o \ ../Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.o \ ../Classes/ExtensionsTest/ExtensionsTest.o \ From 0517372557ac7cdad0c66155970f93291e8b03b6 Mon Sep 17 00:00:00 2001 From: jzgenius Date: Wed, 26 Sep 2012 14:10:52 +0800 Subject: [PATCH 146/181] add CC_SAFE_RETAIN into constructor of CCNotificationObserver. --- cocos2dx/support/CCNotificationCenter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos2dx/support/CCNotificationCenter.cpp b/cocos2dx/support/CCNotificationCenter.cpp index 4d678f4a18..7b00d84c40 100644 --- a/cocos2dx/support/CCNotificationCenter.cpp +++ b/cocos2dx/support/CCNotificationCenter.cpp @@ -165,8 +165,10 @@ CCNotificationObserver::CCNotificationObserver(CCObject *target, CCObject *obj) { m_target = target; + CC_SAFE_RETAIN(m_target); m_selector = selector; m_object = obj; + CC_SAFE_RETAIN(m_object); m_name = new char[strlen(name)+1]; memset(m_name,0,strlen(name)+1); From 0ca7e007003b8fc9062f5cda4b89639718ce716b Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 26 Sep 2012 15:23:10 +0800 Subject: [PATCH 147/181] fixed some compilation errors for linux platform. --- cocos2dx/proj.linux/Makefile | 4 ++-- make-all-linux-project.sh | 12 ++---------- samples/HelloCpp/proj.linux/.cproject | 17 +++++++++-------- samples/HelloCpp/proj.linux/main.cpp | 3 +-- samples/TestCpp/proj.linux/.cproject | 4 ++-- 5 files changed, 16 insertions(+), 24 deletions(-) diff --git a/cocos2dx/proj.linux/Makefile b/cocos2dx/proj.linux/Makefile index 009e01d258..bbddb59751 100644 --- a/cocos2dx/proj.linux/Makefile +++ b/cocos2dx/proj.linux/Makefile @@ -165,8 +165,8 @@ OBJECTS = ../actions/CCAction.o \ ../../extensions/GUI/CCControlExtension/CCControlUtils.o \ ../../extensions/GUI/CCControlExtension/CCInvocation.o \ ../../extensions/GUI/CCControlExtension/CCScale9Sprite.o \ - ../../extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp \ - ../../extensions/GUI/CCControlExtension/CCControlStepper.cpp \ + ../../extensions/GUI/CCControlExtension/CCControlPotentiometer.o \ + ../../extensions/GUI/CCControlExtension/CCControlStepper.o \ ../../extensions/network/HttpClient.o \ ../kazmath/src/aabb.o \ ../kazmath/src/plane.o \ diff --git a/make-all-linux-project.sh b/make-all-linux-project.sh index fd421a442e..678567d8fe 100755 --- a/make-all-linux-project.sh +++ b/make-all-linux-project.sh @@ -26,7 +26,8 @@ if ! test -d $DIR_GLEW170/glew-1.7.0/; then DEPENDS+=' libglfw-dev' DEPENDS+=' g++' DEPENDS+=' libzip-dev' - DEPENDS+=' libcurl4-gnutls-dev' + DEPENDS+=' libcurl4-gnutls-dev' + DEPENDS+=' libfontconfig1-dev' for i in $DEPENDS; do echo -e $TXTCOLOR_GREEN"sudo apt-get install $i, please enter your password:"$TXTCOLOR_DEFAULT sudo apt-get install $i @@ -40,15 +41,6 @@ if ! test -d $DIR_GLEW170/glew-1.7.0/; then make -C ./glew-1.7.0/ cd - fi - - DIR_SPIDERMONKEY_LINUX=$COCOS2DX20_TRUNK/scripting/javascript/spidermonkey-linux - if ! test -d $DIR_SPIDERMONKEY_LINUX/js-1.8.5; then - cd $DIR_SPIDERMONKEY_LINUX - echo -e $TXTCOLOR_GREEN"building spidermonkey ..."$TXTCOLOR_DEFAULT; - tar -zxf js185-1.0.0.tar.gz - cd ./js-1.8.5/js/src - ./configure && make - fi fi #OUTPUT_DEBUG=$COCOS2DX20_TRUNK/lib/linux/Debug/ diff --git a/samples/HelloCpp/proj.linux/.cproject b/samples/HelloCpp/proj.linux/.cproject index 57d73ccd60..6cf45d4792 100644 --- a/samples/HelloCpp/proj.linux/.cproject +++ b/samples/HelloCpp/proj.linux/.cproject @@ -16,13 +16,13 @@ - + - - - + + + - + - + - + - + diff --git a/samples/HelloCpp/proj.linux/main.cpp b/samples/HelloCpp/proj.linux/main.cpp index 74529cfc6d..bb6061e8fe 100644 --- a/samples/HelloCpp/proj.linux/main.cpp +++ b/samples/HelloCpp/proj.linux/main.cpp @@ -1,8 +1,7 @@ #include "main.h" - #include "../Classes/AppDelegate.h" #include "cocos2d.h" -#include "CCEGLView.h" + #include #include diff --git a/samples/TestCpp/proj.linux/.cproject b/samples/TestCpp/proj.linux/.cproject index 872c32dce7..d05b0d5421 100755 --- a/samples/TestCpp/proj.linux/.cproject +++ b/samples/TestCpp/proj.linux/.cproject @@ -16,7 +16,7 @@ - + @@ -58,7 +58,7 @@ - +