From 5349aa7efba0f6803020d3c92547478141e62029 Mon Sep 17 00:00:00 2001 From: gin0606 Date: Thu, 7 Aug 2014 20:57:26 +0900 Subject: [PATCH 01/34] Add ccRandom.h --- build/cocos2d_libs.xcodeproj/project.pbxproj | 6 ++ cocos/base/ccRandom.h | 103 +++++++++++++++++++ templates/cocos2dx_files.json | 1 + 3 files changed, 110 insertions(+) create mode 100644 cocos/base/ccRandom.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index ae84e6534b..910a81b397 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -567,6 +567,8 @@ 1AD71EF5180E27CF00808F54 /* CCPhysicsSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71EEE180E27CF00808F54 /* CCPhysicsSprite.cpp */; }; 1AD71EF6180E27CF00808F54 /* CCPhysicsSprite.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71EEF180E27CF00808F54 /* CCPhysicsSprite.h */; }; 1AD71EF7180E27CF00808F54 /* CCPhysicsSprite.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71EEF180E27CF00808F54 /* CCPhysicsSprite.h */; }; + 1F36C031BE016A88AB195F1B /* ccRandom.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F36C53D12BFE7AD4C769D4D /* ccRandom.h */; }; + 1F36C5F58B5642071337D8E2 /* ccRandom.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F36C53D12BFE7AD4C769D4D /* ccRandom.h */; }; 2958244B19873D8E00F9746D /* UIScale9Sprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2958244919873D8E00F9746D /* UIScale9Sprite.cpp */; }; 2958244C19873D8E00F9746D /* UIScale9Sprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2958244919873D8E00F9746D /* UIScale9Sprite.cpp */; }; 2958244D19873D8E00F9746D /* UIScale9Sprite.h in Headers */ = {isa = PBXBuildFile; fileRef = 2958244A19873D8E00F9746D /* UIScale9Sprite.h */; }; @@ -2393,6 +2395,7 @@ 1AD71EED180E27CF00808F54 /* CCPhysicsDebugNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsDebugNode.h; sourceTree = ""; }; 1AD71EEE180E27CF00808F54 /* CCPhysicsSprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsSprite.cpp; sourceTree = ""; }; 1AD71EEF180E27CF00808F54 /* CCPhysicsSprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsSprite.h; sourceTree = ""; }; + 1F36C53D12BFE7AD4C769D4D /* ccRandom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ccRandom.h; path = ../base/ccRandom.h; sourceTree = ""; }; 2905F9E918CF08D000240AA3 /* CocosGUI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CocosGUI.cpp; sourceTree = ""; }; 2905F9EA18CF08D000240AA3 /* CocosGUI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocosGUI.h; sourceTree = ""; }; 2905F9EB18CF08D000240AA3 /* GUIDefine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIDefine.h; sourceTree = ""; }; @@ -3469,6 +3472,7 @@ 50ABBDFB1925AB6E00A911A9 /* CCProfiling.cpp */, 50ABBDFC1925AB6E00A911A9 /* CCProfiling.h */, 50ABBDFD1925AB6E00A911A9 /* CCProtocols.h */, + 1F36C53D12BFE7AD4C769D4D /* ccRandom.h */, 50ABBDFE1925AB6E00A911A9 /* CCRef.cpp */, 50ABBDFF1925AB6E00A911A9 /* CCRef.h */, 50ABBE001925AB6E00A911A9 /* CCRefPtr.h */, @@ -5457,6 +5461,7 @@ B6ACD899193D6693005E0B8A /* CCMeshSkin.h in Headers */, B6ACD8A0193DC0CC005E0B8A /* CCAnimate3D.h in Headers */, B6AAF84319404E0D0069DE01 /* CCBundle3D.h in Headers */, + 1F36C031BE016A88AB195F1B /* ccRandom.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -5833,6 +5838,7 @@ B6ACD89A193D6693005E0B8A /* CCMeshSkin.h in Headers */, B6ACD8A1193DC0CC005E0B8A /* CCAnimate3D.h in Headers */, B6AAF84419404E0D0069DE01 /* CCBundle3D.h in Headers */, + 1F36C5F58B5642071337D8E2 /* ccRandom.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/cocos/base/ccRandom.h b/cocos/base/ccRandom.h new file mode 100644 index 0000000000..2be07b6a95 --- /dev/null +++ b/cocos/base/ccRandom.h @@ -0,0 +1,103 @@ +/**************************************************************************** +Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +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 __ccRandom_H_ +#define __ccRandom_H_ + +#include "base/CCPlatformMacros.h" +#include + + +NS_CC_BEGIN + +class RandomHelper { +public: + template + static inline T random_real(T min, T max) { + std::uniform_real_distribution dist(min, max); + std::mt19937 mt = RandomHelper::getEngine(); + return dist(mt); + } + + template + static inline T random_int(T min, T max) { + std::uniform_int_distribution<> dist(min, max); + std::mt19937 mt = RandomHelper::getEngine(); + return dist(mt); + } +private: + static std::mt19937 getEngine() { + static std::random_device seed_gen; + static std::mt19937 engine(seed_gen()); + return engine; + } +}; + +/** +* returns a random value between `min` and `max` +*/ +template +inline T random(T min, T max) { + return RandomHelper::random_int(min, max); +} + +template<> +inline float random(float min, float max) { + return RandomHelper::random_real(min, max); +} + +template<> +inline long double random(long double min, long double max) { + return RandomHelper::random_real(min, max); +} + +template<> +inline double random(double min, double max) { + return RandomHelper::random_real(min, max); +} + +/** +* returns a random int between 0 and RAND_MAX +*/ +inline int random() { + return cocos2d::random(0, RAND_MAX); +}; + +/** +* returns a random float between -1 and 1 +*/ +inline float rand_minus1_1() { + return cocos2d::random(-1.f, 1.f); +}; + +/** +* returns a random float between 0 and 1 +*/ +inline float rand_0_1() { + return cocos2d::random(0.f, 1.f); +}; + +NS_CC_END +#endif //__ccRandom_H_ diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 49bba596f5..e9f888e127 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -344,6 +344,7 @@ "cocos/base/CCProfiling.cpp", "cocos/base/CCProfiling.h", "cocos/base/CCProtocols.h", + "cocos/base/ccRanrom.h", "cocos/base/CCRef.cpp", "cocos/base/CCRef.h", "cocos/base/CCRefPtr.h", From 2ca881287ff799fa21f9e4516c1b0932476992d7 Mon Sep 17 00:00:00 2001 From: gin0606 Date: Thu, 7 Aug 2014 21:01:30 +0900 Subject: [PATCH 02/34] CCRANDOM macro use ccRandom --- cocos/base/ccMacros.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cocos/base/ccMacros.h b/cocos/base/ccMacros.h index 165dbab7cf..9c13d654df 100644 --- a/cocos/base/ccMacros.h +++ b/cocos/base/ccMacros.h @@ -69,16 +69,17 @@ simple macro that swaps 2 variables x = y; y = temp; \ } +#include "base/ccRandom.h" /** @def CCRANDOM_MINUS1_1 returns a random float between -1 and 1 */ -#define CCRANDOM_MINUS1_1() ((2.0f*((float)rand()/RAND_MAX))-1.0f) +#define CCRANDOM_MINUS1_1() cocos2d::rand_minus1_1() /** @def CCRANDOM_0_1 returns a random float between 0 and 1 */ -#define CCRANDOM_0_1() ((float)rand()/RAND_MAX) +#define CCRANDOM_0_1() cocos2d::rand_0_1() /** @def CC_DEGREES_TO_RADIANS converts degrees to radians From 6722f8d5463fa456dd664807fdb523c04c577639 Mon Sep 17 00:00:00 2001 From: gin0606 Date: Fri, 8 Aug 2014 13:27:09 +0900 Subject: [PATCH 03/34] Fix typo --- templates/cocos2dx_files.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index e9f888e127..4830583baf 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -344,7 +344,7 @@ "cocos/base/CCProfiling.cpp", "cocos/base/CCProfiling.h", "cocos/base/CCProtocols.h", - "cocos/base/ccRanrom.h", + "cocos/base/ccRandom.h", "cocos/base/CCRef.cpp", "cocos/base/CCRef.h", "cocos/base/CCRefPtr.h", From 89cf0c1e8c7bf08f21fdd57960c744dcb1493a36 Mon Sep 17 00:00:00 2001 From: gin0606 Date: Tue, 12 Aug 2014 11:56:08 +0900 Subject: [PATCH 04/34] fix getEngine --- cocos/base/ccRandom.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/base/ccRandom.h b/cocos/base/ccRandom.h index 2be07b6a95..9bb813d29d 100644 --- a/cocos/base/ccRandom.h +++ b/cocos/base/ccRandom.h @@ -37,18 +37,18 @@ public: template static inline T random_real(T min, T max) { std::uniform_real_distribution dist(min, max); - std::mt19937 mt = RandomHelper::getEngine(); + auto &mt = RandomHelper::getEngine(); return dist(mt); } template static inline T random_int(T min, T max) { std::uniform_int_distribution<> dist(min, max); - std::mt19937 mt = RandomHelper::getEngine(); + auto &mt = RandomHelper::getEngine(); return dist(mt); } private: - static std::mt19937 getEngine() { + static std::mt19937 &getEngine() { static std::random_device seed_gen; static std::mt19937 engine(seed_gen()); return engine; From 17aa2833db739f6f05cdf5b5d83559a4b6c5ade7 Mon Sep 17 00:00:00 2001 From: gin0606 Date: Tue, 12 Aug 2014 12:46:14 +0900 Subject: [PATCH 05/34] Fix xcode warning that cause `getEngine` inline expansion --- build/cocos2d_libs.xcodeproj/project.pbxproj | 6 ++++ cocos/Android.mk | 1 + cocos/base/CMakeLists.txt | 1 + cocos/base/ccRandom.cpp | 32 ++++++++++++++++++++ cocos/base/ccRandom.h | 6 +--- templates/cocos2dx_files.json | 1 + 6 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 cocos/base/ccRandom.cpp diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 910a81b397..eddca4ccc3 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -568,7 +568,9 @@ 1AD71EF6180E27CF00808F54 /* CCPhysicsSprite.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71EEF180E27CF00808F54 /* CCPhysicsSprite.h */; }; 1AD71EF7180E27CF00808F54 /* CCPhysicsSprite.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71EEF180E27CF00808F54 /* CCPhysicsSprite.h */; }; 1F36C031BE016A88AB195F1B /* ccRandom.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F36C53D12BFE7AD4C769D4D /* ccRandom.h */; }; + 1F36C5262E265FD5FFEA0D04 /* ccRandom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1F36CB4D61681865AFA7E8DC /* ccRandom.cpp */; }; 1F36C5F58B5642071337D8E2 /* ccRandom.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F36C53D12BFE7AD4C769D4D /* ccRandom.h */; }; + 1F36CBBF38533B59D96661B1 /* ccRandom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1F36CB4D61681865AFA7E8DC /* ccRandom.cpp */; }; 2958244B19873D8E00F9746D /* UIScale9Sprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2958244919873D8E00F9746D /* UIScale9Sprite.cpp */; }; 2958244C19873D8E00F9746D /* UIScale9Sprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2958244919873D8E00F9746D /* UIScale9Sprite.cpp */; }; 2958244D19873D8E00F9746D /* UIScale9Sprite.h in Headers */ = {isa = PBXBuildFile; fileRef = 2958244A19873D8E00F9746D /* UIScale9Sprite.h */; }; @@ -2396,6 +2398,7 @@ 1AD71EEE180E27CF00808F54 /* CCPhysicsSprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsSprite.cpp; sourceTree = ""; }; 1AD71EEF180E27CF00808F54 /* CCPhysicsSprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsSprite.h; sourceTree = ""; }; 1F36C53D12BFE7AD4C769D4D /* ccRandom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ccRandom.h; path = ../base/ccRandom.h; sourceTree = ""; }; + 1F36CB4D61681865AFA7E8DC /* ccRandom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ccRandom.cpp; path = ../base/ccRandom.cpp; sourceTree = ""; }; 2905F9E918CF08D000240AA3 /* CocosGUI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CocosGUI.cpp; sourceTree = ""; }; 2905F9EA18CF08D000240AA3 /* CocosGUI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocosGUI.h; sourceTree = ""; }; 2905F9EB18CF08D000240AA3 /* GUIDefine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIDefine.h; sourceTree = ""; }; @@ -3506,6 +3509,7 @@ 50ABBE1C1925AB6F00A911A9 /* utlist.h */, 50ABBE1D1925AB6F00A911A9 /* ZipUtils.cpp */, 50ABBE1E1925AB6F00A911A9 /* ZipUtils.h */, + 1F36CB4D61681865AFA7E8DC /* ccRandom.cpp */, ); name = base; path = ../cocos/2d; @@ -6912,6 +6916,7 @@ B6ACD897193D6693005E0B8A /* CCMeshSkin.cpp in Sources */, B6ACD89E193DC0CC005E0B8A /* CCAnimate3D.cpp in Sources */, B6AAF84119404E0D0069DE01 /* CCBundle3D.cpp in Sources */, + 1F36CBBF38533B59D96661B1 /* ccRandom.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -7244,6 +7249,7 @@ B6ACD898193D6693005E0B8A /* CCMeshSkin.cpp in Sources */, B6ACD89F193DC0CC005E0B8A /* CCAnimate3D.cpp in Sources */, B6AAF84219404E0D0069DE01 /* CCBundle3D.cpp in Sources */, + 1F36C5262E265FD5FFEA0D04 /* ccRandom.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/cocos/Android.mk b/cocos/Android.mk index de7056977b..49cd30c780 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -128,6 +128,7 @@ base/CCEventTouch.cpp \ base/CCIMEDispatcher.cpp \ base/CCNS.cpp \ base/CCProfiling.cpp \ +base/ccRandom.cpp \ base/CCRef.cpp \ base/CCScheduler.cpp \ base/CCScriptSupport.cpp \ diff --git a/cocos/base/CMakeLists.txt b/cocos/base/CMakeLists.txt index e57058fd5a..9e4bab6394 100644 --- a/cocos/base/CMakeLists.txt +++ b/cocos/base/CMakeLists.txt @@ -23,6 +23,7 @@ set(COCOS_BASE_SRC base/CCIMEDispatcher.cpp base/CCNS.cpp base/CCProfiling.cpp + base/ccRandom.cpp base/CCRef.cpp base/CCScheduler.cpp base/CCScriptSupport.cpp diff --git a/cocos/base/ccRandom.cpp b/cocos/base/ccRandom.cpp new file mode 100644 index 0000000000..b14783f2e9 --- /dev/null +++ b/cocos/base/ccRandom.cpp @@ -0,0 +1,32 @@ +/**************************************************************************** +Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +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 "ccRandom.h" + +std::mt19937 &cocos2d::RandomHelper::getEngine() { + static std::random_device seed_gen; + static std::mt19937 engine(seed_gen()); + return engine; +} diff --git a/cocos/base/ccRandom.h b/cocos/base/ccRandom.h index 9bb813d29d..5d3a7ab2e0 100644 --- a/cocos/base/ccRandom.h +++ b/cocos/base/ccRandom.h @@ -48,11 +48,7 @@ public: return dist(mt); } private: - static std::mt19937 &getEngine() { - static std::random_device seed_gen; - static std::mt19937 engine(seed_gen()); - return engine; - } + static std::mt19937 &getEngine(); }; /** diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 4830583baf..cb271b5e8a 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -344,6 +344,7 @@ "cocos/base/CCProfiling.cpp", "cocos/base/CCProfiling.h", "cocos/base/CCProtocols.h", + "cocos/base/ccRandom.cpp", "cocos/base/ccRandom.h", "cocos/base/CCRef.cpp", "cocos/base/CCRef.h", From bef6a2a7f1f3ca020ca8d9806876aecb3dc24254 Mon Sep 17 00:00:00 2001 From: xiangxw Date: Tue, 19 Aug 2014 11:46:30 +0800 Subject: [PATCH 06/34] fix sendPrompt() a extra '\0' will be sent when sizeof() is used --- cocos/base/CCConsole.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/base/CCConsole.cpp b/cocos/base/CCConsole.cpp index 3e02abbd2d..85775dbaad 100644 --- a/cocos/base/CCConsole.cpp +++ b/cocos/base/CCConsole.cpp @@ -131,7 +131,7 @@ static ssize_t mydprintf(int sock, const char *format, ...) static void sendPrompt(int fd) { const char prompt[] = "> "; - send(fd, prompt, sizeof(prompt),0); + send(fd, prompt, strlen(prompt),0); } static int printSceneGraph(int fd, Node* node, int level) From deb7ff64d46ada5171d55008e08fa55944035405 Mon Sep 17 00:00:00 2001 From: andyque Date: Tue, 19 Aug 2014 15:14:07 +0800 Subject: [PATCH 07/34] fix pageView touch location --- cocos/ui/UIPageView.cpp | 3 +++ cocos/ui/UIScrollView.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index 3f7bf90c78..f7b98d22a5 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -533,6 +533,7 @@ void PageView::interceptTouchEvent(TouchEventType event, Widget *sender, Touch * { case TouchEventType::BEGAN: { + _touchBeganPosition = touch->getLocation(); _isInterceptTouch = true; } break; @@ -540,6 +541,7 @@ void PageView::interceptTouchEvent(TouchEventType event, Widget *sender, Touch * { float offset = 0; offset = fabs(sender->getTouchBeganPosition().x - touchPoint.x); + _touchMovePosition = touch->getLocation(); if (offset > _childFocusCancelOffset) { sender->setHighlighted(false); @@ -550,6 +552,7 @@ void PageView::interceptTouchEvent(TouchEventType event, Widget *sender, Touch * case TouchEventType::CANCELED: case TouchEventType::ENDED: { + _touchEndPosition = touch->getLocation(); handleReleaseLogic(touch); if (sender->isSwallowTouches()) { diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index d3b39ad2fe..a9451fd813 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -1573,10 +1573,10 @@ void ScrollView::interceptTouchEvent(Widget::TouchEventType event, Widget *sende case TouchEventType::MOVED: { float offset = (sender->getTouchBeganPosition() - touchPoint).getLength(); + _touchMovePosition = touch->getLocation(); if (offset > _childFocusCancelOffset) { sender->setHighlighted(false); - _touchMovePosition = touch->getLocation(); handleMoveLogic(touch); } } From d884054ec9f33184b847eb3a9f195a88401af9d4 Mon Sep 17 00:00:00 2001 From: "kaile.yin" Date: Tue, 19 Aug 2014 15:19:47 +0800 Subject: [PATCH 08/34] remove cascade color for CorlorFrame --- cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp index b97cb461ed..917cadd851 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp @@ -516,9 +516,6 @@ void ColorFrame::onEnter(Frame *nextFrame) _betweenGreen = color.g - _color.g; _betweenBlue = color.b - _color.b; } - - _node->setCascadeColorEnabled(true); - _node->setCascadeOpacityEnabled(true); } void ColorFrame::apply(float percent) From dab6e5fb70b8182c9eef4eabf05aa2501bea602e Mon Sep 17 00:00:00 2001 From: zhangbin Date: Tue, 19 Aug 2014 15:21:43 +0800 Subject: [PATCH 09/34] Update the reference of submodule cocos2d-console. --- tools/cocos2d-console | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cocos2d-console b/tools/cocos2d-console index b2a0338f0a..196bb42c4f 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit b2a0338f0a6d51878ce96c4e0521d083e232e67b +Subproject commit 196bb42c4fb72442230685fda0f100540052d60d From cdd67be77a49d6803e6bdcff30081a4b02262ff0 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 19 Aug 2014 15:29:40 +0800 Subject: [PATCH 10/34] use LOCAL_STATIC_LIBRARIES instead of LOCAL_WHOLE_STATIC_LIBRARIES --- cocos/Android.mk | 8 ++--- cocos/editor-support/cocosbuilder/Android.mk | 2 +- cocos/editor-support/cocostudio/Android.mk | 4 +-- cocos/editor-support/spine/Android.mk | 2 +- cocos/network/Android.mk | 6 ++-- .../lua-bindings/proj.android/Android.mk | 36 +++++++++---------- cocos/storage/local-storage/Android.mk | 2 +- cocos/ui/Android.mk | 4 +-- .../proj.android/jni/Android.mk | 2 +- tests/cpp-tests/Android.mk | 16 ++++----- tests/cpp-tests/proj.android/jni/Android.mk | 2 +- .../proj.android/jni/Android.mk | 2 +- .../project/proj.android/jni/Android.mk | 6 ++-- .../project/proj.android/jni/Android.mk | 4 +-- .../project/proj.android/jni/Android.mk | 18 +++++----- 15 files changed, 57 insertions(+), 57 deletions(-) diff --git a/cocos/Android.mk b/cocos/Android.mk index fc522d5810..511ebd5804 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -210,10 +210,10 @@ LOCAL_EXPORT_LDLIBS := -lGLESv2 \ -lz \ -landroid -LOCAL_WHOLE_STATIC_LIBRARIES := cocos_freetype2_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_png_static +LOCAL_STATIC_LIBRARIES := cocos_freetype2_static +LOCAL_STATIC_LIBRARIES += chipmunk_static +LOCAL_STATIC_LIBRARIES += cocos_png_static +LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dxandroid_static # define the macro to compile through support/zip_support/ioapi.c LOCAL_CFLAGS := -DUSE_FILE32API diff --git a/cocos/editor-support/cocosbuilder/Android.mk b/cocos/editor-support/cocosbuilder/Android.mk index 52863eda24..5bde8a025b 100644 --- a/cocos/editor-support/cocosbuilder/Android.mk +++ b/cocos/editor-support/cocosbuilder/Android.mk @@ -36,7 +36,7 @@ $(LOCAL_PATH) \ $(LOCAL_PATH)/../../.. -LOCAL_WHOLE_STATIC_LIBRARIES := cocos_extension_static +LOCAL_STATIC_LIBRARIES := cocos_extension_static include $(BUILD_STATIC_LIBRARY) diff --git a/cocos/editor-support/cocostudio/Android.mk b/cocos/editor-support/cocostudio/Android.mk index 3ae4b7fe27..39fecd8321 100644 --- a/cocos/editor-support/cocostudio/Android.mk +++ b/cocos/editor-support/cocostudio/Android.mk @@ -71,8 +71,8 @@ $(LOCAL_PATH)/../.. LOCAL_CFLAGS += -fexceptions -LOCAL_WHOLE_STATIC_LIBRARIES := cocos_ui_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static +LOCAL_STATIC_LIBRARIES := cocos_ui_static +LOCAL_STATIC_LIBRARIES += cocosdenshion_static include $(BUILD_STATIC_LIBRARY) diff --git a/cocos/editor-support/spine/Android.mk b/cocos/editor-support/spine/Android.mk index afdbad89a3..b7f3446e1b 100644 --- a/cocos/editor-support/spine/Android.mk +++ b/cocos/editor-support/spine/Android.mk @@ -36,7 +36,7 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. LOCAL_C_INCLUDES := $(LOCAL_PATH)/../.. \ $(LOCAL_PATH)/.. -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static +LOCAL_STATIC_LIBRARIES := cocos2dx_static include $(BUILD_STATIC_LIBRARY) diff --git a/cocos/network/Android.mk b/cocos/network/Android.mk index 045a8d5eab..b47964af29 100644 --- a/cocos/network/Android.mk +++ b/cocos/network/Android.mk @@ -16,9 +16,9 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../.. \ $(LOCAL_PATH)/.. -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_curl_static -LOCAL_WHOLE_STATIC_LIBRARIES += libwebsockets_static +LOCAL_STATIC_LIBRARIES := cocos2dx_static +LOCAL_STATIC_LIBRARIES += cocos_curl_static +LOCAL_STATIC_LIBRARIES += libwebsockets_static include $(BUILD_STATIC_LIBRARY) diff --git a/cocos/scripting/lua-bindings/proj.android/Android.mk b/cocos/scripting/lua-bindings/proj.android/Android.mk index 2e6031074c..84a8fafa63 100644 --- a/cocos/scripting/lua-bindings/proj.android/Android.mk +++ b/cocos/scripting/lua-bindings/proj.android/Android.mk @@ -55,8 +55,8 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../external/lua/tolua \ $(LOCAL_PATH)/../manual/cocos2d -LOCAL_WHOLE_STATIC_LIBRARIES := luajit_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static +LOCAL_STATIC_LIBRARIES := luajit_static +LOCAL_STATIC_LIBRARIES += cocos2dx_static include $(BUILD_STATIC_LIBRARY) @@ -76,8 +76,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../auto \ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../manual/3d -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2d_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos3d_static +LOCAL_STATIC_LIBRARIES := cocos2d_lua_static +LOCAL_STATIC_LIBRARIES += cocos3d_static include $(BUILD_STATIC_LIBRARY) @@ -97,8 +97,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../auto \ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../manual/cocosdenshion -LOCAL_WHOLE_STATIC_LIBRARIES := cocosdenshion_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos2d_lua_static +LOCAL_STATIC_LIBRARIES := cocosdenshion_static +LOCAL_STATIC_LIBRARIES += cocos2d_lua_static include $(BUILD_STATIC_LIBRARY) @@ -134,8 +134,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../manual/network \ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../manual/network -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2d_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_network_static +LOCAL_STATIC_LIBRARIES := cocos2d_lua_static +LOCAL_STATIC_LIBRARIES += cocos_network_static include $(BUILD_STATIC_LIBRARY) @@ -156,8 +156,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../manual/cocosbuilder \ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../manual/cocosbuilder -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2d_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocosbuilder_static +LOCAL_STATIC_LIBRARIES := cocos2d_lua_static +LOCAL_STATIC_LIBRARIES += cocosbuilder_static include $(BUILD_STATIC_LIBRARY) @@ -179,8 +179,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../manual/cocostudio \ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../manual/cocostudio -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2d_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static +LOCAL_STATIC_LIBRARIES := cocos2d_lua_static +LOCAL_STATIC_LIBRARIES += cocostudio_static include $(BUILD_STATIC_LIBRARY) @@ -201,8 +201,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../manual/spine \ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../manual/spine -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2d_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += spine_static +LOCAL_STATIC_LIBRARIES := cocos2d_lua_static +LOCAL_STATIC_LIBRARIES += spine_static include $(BUILD_STATIC_LIBRARY) @@ -223,8 +223,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../manual/extension \ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../manual/extension -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2d_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static +LOCAL_STATIC_LIBRARIES := cocos2d_lua_static +LOCAL_STATIC_LIBRARIES += cocos_extension_static include $(BUILD_STATIC_LIBRARY) @@ -246,8 +246,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../manual/ui \ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../manual/ui -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2d_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_ui_static +LOCAL_STATIC_LIBRARIES := cocos2d_lua_static +LOCAL_STATIC_LIBRARIES += cocos_ui_static include $(BUILD_STATIC_LIBRARY) diff --git a/cocos/storage/local-storage/Android.mk b/cocos/storage/local-storage/Android.mk index c1351e7fb5..3a7a2604ee 100644 --- a/cocos/storage/local-storage/Android.mk +++ b/cocos/storage/local-storage/Android.mk @@ -17,7 +17,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../.. LOCAL_CFLAGS += -Wno-psabi LOCAL_EXPORT_CFLAGS += -Wno-psabi -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static +LOCAL_STATIC_LIBRARIES := cocos2dx_static include $(BUILD_STATIC_LIBRARY) diff --git a/cocos/ui/Android.mk b/cocos/ui/Android.mk index 40f4cb6a31..ab417448f1 100644 --- a/cocos/ui/Android.mk +++ b/cocos/ui/Android.mk @@ -42,8 +42,8 @@ $(LOCAL_PATH)/../.. \ $(LOCAL_PATH)/../editor-support -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static +LOCAL_STATIC_LIBRARIES := cocos2dx_static +LOCAL_STATIC_LIBRARIES += cocos_extension_static include $(BUILD_STATIC_LIBRARY) diff --git a/tests/cpp-empty-test/proj.android/jni/Android.mk b/tests/cpp-empty-test/proj.android/jni/Android.mk index 5917f78021..66788e1c7f 100644 --- a/tests/cpp-empty-test/proj.android/jni/Android.mk +++ b/tests/cpp-empty-test/proj.android/jni/Android.mk @@ -12,7 +12,7 @@ LOCAL_SRC_FILES := main.cpp \ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static +LOCAL_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static include $(BUILD_SHARED_LIBRARY) diff --git a/tests/cpp-tests/Android.mk b/tests/cpp-tests/Android.mk index c1fcaefe21..3fd81f2445 100644 --- a/tests/cpp-tests/Android.mk +++ b/tests/cpp-tests/Android.mk @@ -188,14 +188,14 @@ Classes/ZwoptexTest/ZwoptexTest.cpp LOCAL_C_INCLUDES := $(LOCAL_PATH)/Classes -LOCAL_WHOLE_STATIC_LIBRARIES := cocosbuilder_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static -LOCAL_WHOLE_STATIC_LIBRARIES += spine_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_network_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static -LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos3d_static +LOCAL_STATIC_LIBRARIES := cocosbuilder_static +LOCAL_STATIC_LIBRARIES += cocosdenshion_static +LOCAL_STATIC_LIBRARIES += spine_static +LOCAL_STATIC_LIBRARIES += cocostudio_static +LOCAL_STATIC_LIBRARIES += cocos_network_static +LOCAL_STATIC_LIBRARIES += cocos_extension_static +LOCAL_STATIC_LIBRARIES += box2d_static +LOCAL_STATIC_LIBRARIES += cocos3d_static LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/Classes diff --git a/tests/cpp-tests/proj.android/jni/Android.mk b/tests/cpp-tests/proj.android/jni/Android.mk index 75950d8494..bb2c8fb025 100644 --- a/tests/cpp-tests/proj.android/jni/Android.mk +++ b/tests/cpp-tests/proj.android/jni/Android.mk @@ -10,7 +10,7 @@ LOCAL_SRC_FILES := main.cpp LOCAL_C_INCLUDES := ../../Classes -LOCAL_WHOLE_STATIC_LIBRARIES := cocos_cpp_tests_common +LOCAL_STATIC_LIBRARIES := cocos_cpp_tests_common include $(BUILD_SHARED_LIBRARY) diff --git a/tests/game-controller-test/proj.android/jni/Android.mk b/tests/game-controller-test/proj.android/jni/Android.mk index 9aff92cd27..fbb8613e91 100644 --- a/tests/game-controller-test/proj.android/jni/Android.mk +++ b/tests/game-controller-test/proj.android/jni/Android.mk @@ -13,7 +13,7 @@ LOCAL_SRC_FILES := main.cpp \ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \ $(LOCAL_PATH)/../../../../external -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static +LOCAL_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static include $(BUILD_SHARED_LIBRARY) diff --git a/tests/lua-empty-test/project/proj.android/jni/Android.mk b/tests/lua-empty-test/project/proj.android/jni/Android.mk index 61c5baf884..98cbf8f9c4 100644 --- a/tests/lua-empty-test/project/proj.android/jni/Android.mk +++ b/tests/lua-empty-test/project/proj.android/jni/Android.mk @@ -12,9 +12,9 @@ LOCAL_SRC_FILES := main.cpp \ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \ $(LOCAL_PATH)/../../../../../external/lua/tolua \ -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2d_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += network_lua_static +LOCAL_STATIC_LIBRARIES := cocos2d_lua_static +LOCAL_STATIC_LIBRARIES += cocosdenshion_lua_static +LOCAL_STATIC_LIBRARIES += network_lua_static include $(BUILD_SHARED_LIBRARY) diff --git a/tests/lua-game-controller-test/project/proj.android/jni/Android.mk b/tests/lua-game-controller-test/project/proj.android/jni/Android.mk index c1f283cb9f..9b9640e484 100644 --- a/tests/lua-game-controller-test/project/proj.android/jni/Android.mk +++ b/tests/lua-game-controller-test/project/proj.android/jni/Android.mk @@ -17,8 +17,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \ $(LOCAL_PATH)/../../../../../cocos/scripting/lua-bindings/manual\controller \ $(LOCAL_PATH)/../../../../../cocos/base -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2d_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static +LOCAL_STATIC_LIBRARIES := cocos2d_lua_static +LOCAL_STATIC_LIBRARIES += cocosdenshion_static include $(BUILD_SHARED_LIBRARY) diff --git a/tests/lua-tests/project/proj.android/jni/Android.mk b/tests/lua-tests/project/proj.android/jni/Android.mk index 44aff93129..77cb96921f 100644 --- a/tests/lua-tests/project/proj.android/jni/Android.mk +++ b/tests/lua-tests/project/proj.android/jni/Android.mk @@ -13,15 +13,15 @@ LOCAL_SRC_FILES += main.cpp \ LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Classes -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2d_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += network_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocosbuilder_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += spine_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += extension_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += ui_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos3d_lua_static +LOCAL_STATIC_LIBRARIES := cocos2d_lua_static +LOCAL_STATIC_LIBRARIES += cocosdenshion_lua_static +LOCAL_STATIC_LIBRARIES += network_lua_static +LOCAL_STATIC_LIBRARIES += cocosbuilder_lua_static +LOCAL_STATIC_LIBRARIES += cocostudio_lua_static +LOCAL_STATIC_LIBRARIES += spine_lua_static +LOCAL_STATIC_LIBRARIES += extension_lua_static +LOCAL_STATIC_LIBRARIES += ui_lua_static +LOCAL_STATIC_LIBRARIES += cocos3d_lua_static include $(BUILD_SHARED_LIBRARY) From 0e7ec265ee04a5044ab323b2992fd6ec3308a4f5 Mon Sep 17 00:00:00 2001 From: teivaz Date: Wed, 20 Aug 2014 11:54:41 +0300 Subject: [PATCH 11/34] * [WP8] Fixed default search path: renamed "Assets\Resources" to "Assets\res" --- cocos/platform/winrt/CCFileUtilsWinRT.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/platform/winrt/CCFileUtilsWinRT.cpp b/cocos/platform/winrt/CCFileUtilsWinRT.cpp index 736a597504..a5b0e7214c 100644 --- a/cocos/platform/winrt/CCFileUtilsWinRT.cpp +++ b/cocos/platform/winrt/CCFileUtilsWinRT.cpp @@ -53,7 +53,7 @@ static void _checkPath() if (s_pszResourcePath.empty()) { // TODO: needs to be tested - s_pszResourcePath = convertPathFormatToUnixStyle(CCFileUtilsWinRT::getAppPath() + '\\' + "Assets\\Resources" + '\\'); + s_pszResourcePath = convertPathFormatToUnixStyle(CCFileUtilsWinRT::getAppPath() + '\\' + "Assets\\res" + '\\'); } } From bfe6513706a353fcd9fd3e3e673feebdc23f0496 Mon Sep 17 00:00:00 2001 From: Sergey Date: Mon, 18 Aug 2014 16:41:12 +0400 Subject: [PATCH 12/34] setKeepScreenOn method --- cocos/platform/CCDevice.h | 2 ++ cocos/platform/android/CCDevice.cpp | 6 ++++++ .../java/src/org/cocos2dx/lib/Cocos2dxActivity.java | 11 +++++++++++ .../java/src/org/cocos2dx/lib/Cocos2dxHelper.java | 4 ++++ .../jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp | 10 ++++++++++ .../jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h | 1 + cocos/platform/ios/CCDevice.mm | 5 +++++ cocos/platform/linux/CCDevice.cpp | 4 ++++ cocos/platform/mac/CCDevice.mm | 5 +++++ cocos/platform/win32/CCDevice.cpp | 4 ++++ cocos/platform/winrt/CCDevice.cpp | 4 ++++ 11 files changed, 56 insertions(+) diff --git a/cocos/platform/CCDevice.h b/cocos/platform/CCDevice.h index 1affa43e7b..91e6485559 100644 --- a/cocos/platform/CCDevice.h +++ b/cocos/platform/CCDevice.h @@ -65,6 +65,8 @@ public: static void setAccelerometerInterval(float interval); static Data getTextureDataForText(const char * text, const FontDefinition& textDefinition, TextAlign align, int &width, int &height, bool& hasPremultipliedAlpha); + + static void setKeepScreenOn(bool value); private: CC_DISALLOW_IMPLICIT_CONSTRUCTORS(Device); diff --git a/cocos/platform/android/CCDevice.cpp b/cocos/platform/android/CCDevice.cpp index fc5a0902f8..3ccb441d19 100644 --- a/cocos/platform/android/CCDevice.cpp +++ b/cocos/platform/android/CCDevice.cpp @@ -202,6 +202,12 @@ Data Device::getTextureDataForText(const char * text, const FontDefinition& text return ret; } + +void Device::setKeepScreenOn(bool value) +{ + setKeepScreenOnJni(value); +} + NS_CC_END #endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java index 78929fb300..9ae61cc165 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java @@ -34,6 +34,7 @@ import android.os.Build; import android.os.Bundle; import android.os.Message; import android.view.ViewGroup; +import android.view.WindowManager; import android.util.Log; import android.widget.FrameLayout; import android.preference.PreferenceManager.OnActivityResultListener; @@ -58,6 +59,16 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe return sContext; } + public void setKeepScreenOn(boolean value) { + final boolean newValue = value; + runOnUiThread(new Runnable() { + @Override + public void run() { + mGLSurfaceView.setKeepScreenOn(newValue); + } + }); + } + protected void onLoadNativeLibraries() { try { ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA); diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java index 3cabec4822..ea102e7f73 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java @@ -167,6 +167,10 @@ public class Cocos2dxHelper { Cocos2dxHelper.sAccelerometerEnabled = false; Cocos2dxHelper.sCocos2dxAccelerometer.disable(); } + + public static void setKeepScreenOn(boolean value) { + ((Cocos2dxActivity)sActivity).setKeepScreenOn(value); + } public static void preloadBackgroundMusic(final String pPath) { Cocos2dxHelper.sCocos2dMusic.preloadBackgroundMusic(pPath); diff --git a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp index 3449bbbc9d..ef9fac20a4 100644 --- a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp +++ b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp @@ -209,6 +209,16 @@ void disableAccelerometerJni() { } } +void setKeepScreenOnJni(bool value) { + JniMethodInfo t; + + if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setKeepScreenOn", "(Z)V")) { + t.env->CallStaticVoidMethod(t.classID, t.methodID, value); + + t.env->DeleteLocalRef(t.classID); + } +} + // functions for UserDefault bool getBoolForKeyJNI(const char* key, bool defaultValue) { diff --git a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h index 34d521a911..7044a4e5e4 100644 --- a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h +++ b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h @@ -39,6 +39,7 @@ extern std::string getFileDirectoryJNI(); extern void enableAccelerometerJni(); extern void disableAccelerometerJni(); extern void setAccelerometerIntervalJni(float interval); +extern void setKeepScreenOnJni(bool value); // functions for UserDefault extern bool getBoolForKeyJNI(const char* key, bool defaultValue); extern int getIntegerForKeyJNI(const char* key, int defaultValue); diff --git a/cocos/platform/ios/CCDevice.mm b/cocos/platform/ios/CCDevice.mm index 607d95340b..28438ea897 100644 --- a/cocos/platform/ios/CCDevice.mm +++ b/cocos/platform/ios/CCDevice.mm @@ -477,6 +477,11 @@ Data Device::getTextureDataForText(const char * text, const FontDefinition& text return ret; } +void Device::setKeepScreenOn(bool value) +{ + [[UIApplication sharedApplication] setIdleTimerDisabled:YES]; +} + NS_CC_END #endif // CC_PLATFORM_IOS diff --git a/cocos/platform/linux/CCDevice.cpp b/cocos/platform/linux/CCDevice.cpp index 5536c87d81..24b70d05b2 100644 --- a/cocos/platform/linux/CCDevice.cpp +++ b/cocos/platform/linux/CCDevice.cpp @@ -499,6 +499,10 @@ Data Device::getTextureDataForText(const char * text, const FontDefinition& text return ret; } +void Device::setKeepScreenOn(bool value) +{ +} + NS_CC_END #endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX diff --git a/cocos/platform/mac/CCDevice.mm b/cocos/platform/mac/CCDevice.mm index 185dded81d..885a643bc6 100644 --- a/cocos/platform/mac/CCDevice.mm +++ b/cocos/platform/mac/CCDevice.mm @@ -247,6 +247,11 @@ Data Device::getTextureDataForText(const char * text, const FontDefinition& text return ret; } + +void Device::setKeepScreenOn(bool value) +{ +} + NS_CC_END #endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC diff --git a/cocos/platform/win32/CCDevice.cpp b/cocos/platform/win32/CCDevice.cpp index f6bce3bac5..ed69905ab1 100644 --- a/cocos/platform/win32/CCDevice.cpp +++ b/cocos/platform/win32/CCDevice.cpp @@ -451,6 +451,10 @@ Data Device::getTextureDataForText(const char * text, const FontDefinition& text return ret; } +void Device::setKeepScreenOn(bool value) +{ +} + NS_CC_END #endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 diff --git a/cocos/platform/winrt/CCDevice.cpp b/cocos/platform/winrt/CCDevice.cpp index edf747764a..eedd87cd87 100644 --- a/cocos/platform/winrt/CCDevice.cpp +++ b/cocos/platform/winrt/CCDevice.cpp @@ -163,6 +163,10 @@ Data Device::getTextureDataForText(const char * text, const FontDefinition& text return ret; } +void Device::setKeepScreenOn(bool value) +{ +} + NS_CC_END #endif // (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) From 055a143f9d033325e8a771c64596120278f985b4 Mon Sep 17 00:00:00 2001 From: Sergey Date: Tue, 19 Aug 2014 14:50:47 +0400 Subject: [PATCH 13/34] Label performance problem --- cocos/2d/CCLabel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 9eaf5ee5f1..3ad34b2acf 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -1023,7 +1023,8 @@ void Label::updateFont() void Label::drawTextSprite(Renderer *renderer, uint32_t parentFlags) { - if (_fontDefinition._fontFillColor != _textColor) + if (_fontDefinition._fontFillColor.r != _textColor.r || _fontDefinition._fontFillColor.g != _textColor.g + || _fontDefinition._fontFillColor.b != _textColor.b) { updateContent(); } From eecaac3384a2aac900148afe476aa5cb556fe49e Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 20 Aug 2014 09:48:39 +0800 Subject: [PATCH 14/34] [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index bc7dbd38df..7926008d81 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ cocos2d-x-3.3 ?? [NEW] Added Camera, AABB, OBB and Ray [NEW] Added render primitive and render primitive command, support passing point, line and triangle data [NEW] Added support for applicationDidEnterBackground / applicationWillEnterForeground on desktop + [NEW] Device: added setKeepScreenOn() for iOS and Android [NEW] EventMouse: support getDelta, getDeltaX, getDeltaY functions [NEW] FileUtils: add isDirectoryExist(), createDirectory(), removeDirectory(), removeFile(), renameFile() getFileSize() From 83ccfa0faa4215209657863d0671a616fbeaa6a5 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 20 Aug 2014 09:50:39 +0800 Subject: [PATCH 15/34] [ci skip] --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index d01ef93c82..feb91b4de3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -805,6 +805,7 @@ Developers: Add support of software PVRTC v1 decompression Fixed a bug that ttf font have not effect on Mac OS X Fixed a bug that before touchMove Touch::_prevPoint contains junk + Added Device::setKeepScreenOn() youknowone Adds iOS-like elastic bounceback support for cocos2d::extension::ScrollView From 2fe45ec6ccea0600affecfda6d7bfc5564a2d96a Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 20 Aug 2014 10:26:53 +0800 Subject: [PATCH 16/34] [ci skip] --- AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS b/AUTHORS index feb91b4de3..951e9cbb69 100644 --- a/AUTHORS +++ b/AUTHORS @@ -980,6 +980,9 @@ Developers: zaWasp Added support for applicationDidEnterBackground / applicationWillEnterForeground on win32 + + xiangxw + Fixed the bug that Console::sendPrompt() will send extra `\0` Retired Core Developers: WenSheng Yang From 2c4fe854fbdd51a6a70c0cbc1545c134980c0ff4 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 20 Aug 2014 10:28:48 +0800 Subject: [PATCH 17/34] [ --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 951e9cbb69..325fac3d05 100644 --- a/AUTHORS +++ b/AUTHORS @@ -806,6 +806,7 @@ Developers: Fixed a bug that ttf font have not effect on Mac OS X Fixed a bug that before touchMove Touch::_prevPoint contains junk Added Device::setKeepScreenOn() + Fixed Label performance problem youknowone Adds iOS-like elastic bounceback support for cocos2d::extension::ScrollView From 0e5a79d486d3f584af021b66ccfa949a06fca14b Mon Sep 17 00:00:00 2001 From: teivaz Date: Wed, 20 Aug 2014 12:02:16 +0300 Subject: [PATCH 18/34] + [WP8] Added method for custom precompiled shader program loading --- cocos/platform/winrt/CCPrecompiledShaders.cpp | 19 +++++++++++++++++++ cocos/platform/winrt/CCPrecompiledShaders.h | 1 + 2 files changed, 20 insertions(+) diff --git a/cocos/platform/winrt/CCPrecompiledShaders.cpp b/cocos/platform/winrt/CCPrecompiledShaders.cpp index 3ec3131651..da7c40080b 100644 --- a/cocos/platform/winrt/CCPrecompiledShaders.cpp +++ b/cocos/platform/winrt/CCPrecompiledShaders.cpp @@ -135,6 +135,25 @@ void CCPrecompiledShaders::loadPrecompiledPrograms() #endif } +void CCPrecompiledShaders::addPrecompiledProgram(const char* key, const unsigned char* program, int programLength) +{ + std::string id = key; + PrecompiledProgram* p = nullptr; + auto it = m_precompiledPrograms.find(id); + if (it != m_precompiledPrograms.end()) + { + p = it->second; + } + else + { + p = new PrecompiledProgram(); + m_precompiledPrograms[id] = p; + } + p->key = key; + p->program = program; + p->length = programLength; +} + bool CCPrecompiledShaders::loadProgram(GLuint program, const GLchar* vShaderByteArray, const GLchar* fShaderByteArray) { std::string id = computeHash(vShaderByteArray, fShaderByteArray); diff --git a/cocos/platform/winrt/CCPrecompiledShaders.h b/cocos/platform/winrt/CCPrecompiledShaders.h index dd619b0dd9..d1dba0896a 100644 --- a/cocos/platform/winrt/CCPrecompiledShaders.h +++ b/cocos/platform/winrt/CCPrecompiledShaders.h @@ -70,6 +70,7 @@ public: */ static CCPrecompiledShaders* getInstance(); + void addPrecompiledProgram(const char* key, const unsigned char* program, int programLength); std::string addShaders(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray); bool addProgram(GLuint program, const std::string& id); From fa95bda6296f7b23aefba5b321b284ff9ae77db7 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 20 Aug 2014 11:23:50 +0800 Subject: [PATCH 19/34] [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 7926008d81..dad8e382d8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ cocos2d-x-3.3 ?? [NEW] Added Camera, AABB, OBB and Ray [NEW] Added render primitive and render primitive command, support passing point, line and triangle data [NEW] Added support for applicationDidEnterBackground / applicationWillEnterForeground on desktop + [NEW] Added method for custom precompiled shader program loading on WP8 [NEW] Device: added setKeepScreenOn() for iOS and Android [NEW] EventMouse: support getDelta, getDeltaX, getDeltaY functions [NEW] FileUtils: add isDirectoryExist(), createDirectory(), removeDirectory(), removeFile(), renameFile() From 01165951dea0dead6f237f3b5f750a9a6dc4b45b Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 20 Aug 2014 11:24:53 +0800 Subject: [PATCH 20/34] [ci skip] --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 325fac3d05..8a64066b20 100644 --- a/AUTHORS +++ b/AUTHORS @@ -924,6 +924,7 @@ Developers: Teivaz Custom uniform search optimization Fixed compiling error on WP8. + Added method for custom precompiled shader program loading on WP8 chareice Make `setup.py` work on zsh From 8f30a7eeffee0c160091cd41d45a104b652791b8 Mon Sep 17 00:00:00 2001 From: zhangbin Date: Wed, 20 Aug 2014 11:41:58 +0800 Subject: [PATCH 21/34] Update the reference of submodule cocos2d-console. --- tools/cocos2d-console | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cocos2d-console b/tools/cocos2d-console index 196bb42c4f..f8f912183a 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit 196bb42c4fb72442230685fda0f100540052d60d +Subproject commit f8f912183afd6276156b989f5e14b1cea7db8962 From 34629f10148c093d981f9ca02b7eb37d15d1967e Mon Sep 17 00:00:00 2001 From: andyque Date: Wed, 20 Aug 2014 12:02:12 +0800 Subject: [PATCH 22/34] fix windows & win8 & wp8 compile error --- cocos/2d/cocos2d_wp8.vcxproj | 8 +++++++ cocos/2d/cocos2d_wp8.vcxproj.filters | 24 +++++++++++++++++++ cocos/2d/libcocos2d.vcxproj | 2 ++ cocos/2d/libcocos2d.vcxproj.filters | 6 +++++ cocos/base/ccRandom.h | 2 +- .../cpp-testsComponent.vcxproj | 4 ++++ .../cpp-testsComponent.vcxproj.filters | 15 ++++++++++++ 7 files changed, 60 insertions(+), 1 deletion(-) diff --git a/cocos/2d/cocos2d_wp8.vcxproj b/cocos/2d/cocos2d_wp8.vcxproj index ba6dbc0623..07a0aefc46 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj +++ b/cocos/2d/cocos2d_wp8.vcxproj @@ -222,6 +222,7 @@ NotUsing NotUsing + @@ -229,7 +230,9 @@ + + @@ -280,6 +283,7 @@ + @@ -442,6 +446,7 @@ + @@ -451,7 +456,9 @@ + + @@ -495,6 +502,7 @@ + diff --git a/cocos/2d/cocos2d_wp8.vcxproj.filters b/cocos/2d/cocos2d_wp8.vcxproj.filters index 2a8cead521..5a53e1329e 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj.filters +++ b/cocos/2d/cocos2d_wp8.vcxproj.filters @@ -650,6 +650,18 @@ base + + base + + + 3d + + + 3d + + + 3d + @@ -1328,6 +1340,18 @@ base + + base + + + 3d + + + 3d + + + 3d + diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index 91e74ad18a..457a0acc95 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -213,6 +213,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou + @@ -399,6 +400,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index eb482baa59..b7bbac671f 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -586,6 +586,9 @@ base + + base + @@ -1189,6 +1192,9 @@ base + + base + diff --git a/cocos/base/ccRandom.h b/cocos/base/ccRandom.h index 5d3a7ab2e0..272da902b2 100644 --- a/cocos/base/ccRandom.h +++ b/cocos/base/ccRandom.h @@ -32,7 +32,7 @@ THE SOFTWARE. NS_CC_BEGIN -class RandomHelper { +class CC_DLL RandomHelper { public: template static inline T random_real(T min, T max) { diff --git a/tests/cpp-tests/proj.wp8-xaml/cpp-testsComponent/cpp-testsComponent.vcxproj b/tests/cpp-tests/proj.wp8-xaml/cpp-testsComponent/cpp-testsComponent.vcxproj index c152ba0746..16806e1f8c 100644 --- a/tests/cpp-tests/proj.wp8-xaml/cpp-testsComponent/cpp-testsComponent.vcxproj +++ b/tests/cpp-tests/proj.wp8-xaml/cpp-testsComponent/cpp-testsComponent.vcxproj @@ -185,6 +185,7 @@ + @@ -228,6 +229,7 @@ + @@ -383,6 +385,7 @@ + @@ -429,6 +432,7 @@ + diff --git a/tests/cpp-tests/proj.wp8-xaml/cpp-testsComponent/cpp-testsComponent.vcxproj.filters b/tests/cpp-tests/proj.wp8-xaml/cpp-testsComponent/cpp-testsComponent.vcxproj.filters index 5959863578..44d9ce5bea 100644 --- a/tests/cpp-tests/proj.wp8-xaml/cpp-testsComponent/cpp-testsComponent.vcxproj.filters +++ b/tests/cpp-tests/proj.wp8-xaml/cpp-testsComponent/cpp-testsComponent.vcxproj.filters @@ -325,6 +325,9 @@ {dff38415-43e7-4aff-98ec-c6094899d142} + + {d17dc00f-2b4d-46af-a1ff-c3f4d937d621} + @@ -858,6 +861,12 @@ Classes\UITest\CocosStudioGUITest + + Classes\Sprite3DTest + + + Classes\Camera3DTest + @@ -1590,6 +1599,12 @@ Classes\UITest\CocosStudioGUITest + + Classes\Sprite3DTest + + + Classes\Camera3DTest + From 9c2cbaf742a819206e612e5c46eebb68712e5cbf Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 20 Aug 2014 05:37:22 +0000 Subject: [PATCH 23/34] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 3a8a2d9444..c1e45b22d8 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -360,8 +360,6 @@ "cocos/base/CCProfiling.cpp", "cocos/base/CCProfiling.h", "cocos/base/CCProtocols.h", - "cocos/base/ccRandom.cpp", - "cocos/base/ccRandom.h", "cocos/base/CCRef.cpp", "cocos/base/CCRef.h", "cocos/base/CCRefPtr.h", @@ -395,6 +393,8 @@ "cocos/base/ccFPSImages.c", "cocos/base/ccFPSImages.h", "cocos/base/ccMacros.h", + "cocos/base/ccRandom.cpp", + "cocos/base/ccRandom.h", "cocos/base/ccTypes.cpp", "cocos/base/ccTypes.h", "cocos/base/ccUTF8.cpp", From 6458a1fc6da735de466c31cdbe06bbd58361e8c3 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 20 Aug 2014 13:37:23 +0800 Subject: [PATCH 24/34] [ci skip] --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 8a64066b20..93f56e9cbd 100644 --- a/AUTHORS +++ b/AUTHORS @@ -917,6 +917,7 @@ Developers: Fix a bug that crash happened when try to remove videoView(STATE_PLAYBACK_COMPLETED) in android Fix video scale issue in iOS Fix iOS VideoPlayer memory leak + Added c++11 random library support billtt Fixed a bug that Node::setScale(float) may not work properly From 8034b5429ef2389cb2662ffb8423296c9efce517 Mon Sep 17 00:00:00 2001 From: zhangbin Date: Wed, 20 Aug 2014 13:45:01 +0800 Subject: [PATCH 25/34] Update the reference of submodule cocos2d-console. --- tools/cocos2d-console | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cocos2d-console b/tools/cocos2d-console index f8f912183a..802e261172 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit f8f912183afd6276156b989f5e14b1cea7db8962 +Subproject commit 802e261172e2f3b49d1feed20935a53820694ab2 From 5ef89382174159409887ecf5f54ffc84bbc1610b Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 20 Aug 2014 13:45:08 +0800 Subject: [PATCH 26/34] [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index dad8e382d8..83072a1e9a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ cocos2d-x-3.3 ?? [NEW] Added render primitive and render primitive command, support passing point, line and triangle data [NEW] Added support for applicationDidEnterBackground / applicationWillEnterForeground on desktop [NEW] Added method for custom precompiled shader program loading on WP8 + [NEW] Added c++11 random support [NEW] Device: added setKeepScreenOn() for iOS and Android [NEW] EventMouse: support getDelta, getDeltaX, getDeltaY functions [NEW] FileUtils: add isDirectoryExist(), createDirectory(), removeDirectory(), removeFile(), renameFile() From 22db2abcaf09a3edc3d86e1d1e2c1e549b2c30f9 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Wed, 20 Aug 2014 14:21:13 +0800 Subject: [PATCH 27/34] add != operator in Blendfunc --- cocos/base/ccTypes.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cocos/base/ccTypes.h b/cocos/base/ccTypes.h index 3a8e990b4e..8e75b828a8 100644 --- a/cocos/base/ccTypes.h +++ b/cocos/base/ccTypes.h @@ -348,6 +348,11 @@ struct CC_DLL BlendFunc return src == a.src && dst == a.dst; } + bool operator!=(const BlendFunc &a) const + { + return src != a.src || dst != a.dst; + } + bool operator<(const BlendFunc &a) const { return src < a.src || (src == a.src && dst < a.dst); From b5e5e2d8d55cd98f18bdfe1b73077e2952a5d66e Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Wed, 20 Aug 2014 14:48:50 +0800 Subject: [PATCH 28/34] add primitive head file to cocos2d.h --- cocos/cocos2d.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index 96158acfcf..f3ec0cece8 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -154,6 +154,10 @@ THE SOFTWARE. #include "renderer/ccShaders.h" #include "renderer/CCTexture2D.h" #include "renderer/CCTextureCache.h" +#include "renderer/CCVertexIndexBuffer.h" +#include "renderer/CCVertexIndexData.h" +#include "renderer/CCPrimitive.h" +#include "renderer/CCPrimitiveCommand.h" // physics #include "physics/CCPhysicsBody.h" From 4697cb07e663f540ba7647ae76860027dd5c07a0 Mon Sep 17 00:00:00 2001 From: teivaz Date: Thu, 21 Aug 2014 18:04:46 +0300 Subject: [PATCH 29/34] ! Set version to 3.3 (as it is no longer 3.2) --- cocos/cocos2d.cpp | 2 +- cocos/cocos2d.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/cocos2d.cpp b/cocos/cocos2d.cpp index 7e4cb18e48..83c40ab695 100644 --- a/cocos/cocos2d.cpp +++ b/cocos/cocos2d.cpp @@ -31,7 +31,7 @@ NS_CC_BEGIN CC_DLL const char* cocos2dVersion() { - return "cocos2d-x 3.2"; + return "cocos2d-x 3.3"; } NS_CC_END diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index f3ec0cece8..2998a244b6 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -29,8 +29,8 @@ THE SOFTWARE. #define __COCOS2D_H__ // 0x00 HI ME LO -// 00 03 02 00 -#define COCOS2D_VERSION 0x00030200 +// 00 03 03 00 +#define COCOS2D_VERSION 0x00030300 // // all cocos2d include files From 2fc3be27208f0c3d38f7354a53f349c2e4d5a574 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 21 Aug 2014 10:33:57 +0800 Subject: [PATCH 30/34] [ci skip] --- CHANGELOG | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 83072a1e9a..da8dcfcd4b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,4 @@ cocos2d-x-3.3 ?? - [NEW] Added submesh support, and support attaching a Sprite3D object to a bone [NEW] Added UIScale9Sprite [NEW] Added Camera, AABB, OBB and Ray [NEW] Added render primitive and render primitive command, support passing point, line and triangle data From a70688dc965c157c934d6014c9a48d4d7db2cac0 Mon Sep 17 00:00:00 2001 From: teivaz Date: Thu, 21 Aug 2014 13:47:53 +0300 Subject: [PATCH 31/34] + [WINRT] Inserted newly added files to cocos WIN RT project --- cocos/2d/cocos2d_winrt.vcxproj | 12 +++++++++ cocos/2d/cocos2d_winrt.vcxproj.filters | 36 ++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/cocos/2d/cocos2d_winrt.vcxproj b/cocos/2d/cocos2d_winrt.vcxproj index 3ad2b3a2f5..61a777d5a6 100644 --- a/cocos/2d/cocos2d_winrt.vcxproj +++ b/cocos/2d/cocos2d_winrt.vcxproj @@ -315,6 +315,7 @@ + @@ -345,6 +346,7 @@ CompileAsCpp + @@ -423,6 +425,8 @@ + + @@ -430,6 +434,8 @@ + + @@ -507,6 +513,7 @@ + @@ -535,6 +542,7 @@ + @@ -627,6 +635,8 @@ + + @@ -635,6 +645,8 @@ + + diff --git a/cocos/2d/cocos2d_winrt.vcxproj.filters b/cocos/2d/cocos2d_winrt.vcxproj.filters index 1fc613a19b..c49292bf34 100644 --- a/cocos/2d/cocos2d_winrt.vcxproj.filters +++ b/cocos/2d/cocos2d_winrt.vcxproj.filters @@ -581,6 +581,24 @@ base + + base + + + base + + + renderer + + + renderer + + + renderer + + + renderer + @@ -1188,6 +1206,24 @@ base + + base + + + base + + + renderer + + + renderer + + + renderer + + + renderer + From 312f57d7a64e9eb758fc0fccb1f3ed406154947c Mon Sep 17 00:00:00 2001 From: teivaz Date: Thu, 21 Aug 2014 18:49:52 +0300 Subject: [PATCH 32/34] - [WP8] Now replacing application display name with project name --- templates/cpp-template-default/cocos-project-template.json | 1 + .../proj.wp8-xaml/App/Properties/WMAppManifest.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/cpp-template-default/cocos-project-template.json b/templates/cpp-template-default/cocos-project-template.json index 9d4ee7d291..6002d95fd4 100644 --- a/templates/cpp-template-default/cocos-project-template.json +++ b/templates/cpp-template-default/cocos-project-template.json @@ -27,6 +27,7 @@ "proj.win32/PROJECT_NAME.sln", "proj.win32/main.cpp", "proj.wp8-xaml/App/PROJECT_NAME.csproj", + "proj.wp8-xaml/App/Properties/WMAppManifest.xml", "proj.wp8-xaml/PROJECT_NAME.sln", "proj.android/.project", "proj.android/.cproject", diff --git a/templates/cpp-template-default/proj.wp8-xaml/App/Properties/WMAppManifest.xml b/templates/cpp-template-default/proj.wp8-xaml/App/Properties/WMAppManifest.xml index 8437827d62..8622bf45fc 100644 --- a/templates/cpp-template-default/proj.wp8-xaml/App/Properties/WMAppManifest.xml +++ b/templates/cpp-template-default/proj.wp8-xaml/App/Properties/WMAppManifest.xml @@ -1,7 +1,7 @@  - + Assets\ApplicationIcon.png From 97a4258cd650841895e9cef991b34da4b0df56ca Mon Sep 17 00:00:00 2001 From: zhangbin Date: Thu, 21 Aug 2014 14:10:36 +0800 Subject: [PATCH 33/34] Update the reference of submodule cocos2d-console. --- tools/cocos2d-console | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cocos2d-console b/tools/cocos2d-console index 802e261172..fb44ec8cf7 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit 802e261172e2f3b49d1feed20935a53820694ab2 +Subproject commit fb44ec8cf77f6f51503987c3a1a0964580b5d88f From 88b8af0a342b79aa813443c6c81902e0f7fad872 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 21 Aug 2014 14:11:43 +0800 Subject: [PATCH 34/34] update release note --- docs/RELEASE_NOTES.md | 228 ++++++++++++------------------------------ 1 file changed, 62 insertions(+), 166 deletions(-) diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index 48060de875..78cd8ae2f3 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -1,4 +1,4 @@ -# cocos2d-x v3.2 Release Notes # +# cocos2d-x v3.3alpha0 Release Notes # **Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)* @@ -28,9 +28,7 @@ # Misc Information -* Download: http://cdn.cocos2d-x.org/cocos2d-x-3.2.zip -* Full Changelog: https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.2/CHANGELOG -* API Reference: http://www.cocos2d-x.org/reference/native-cpp/V3.2/index.html +* Full Changelog: https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.3alpha0/CHANGELOG * v3.0 Release Notes can be found here: [v3.0 Release Notes](https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.0/docs/RELEASE_NOTES.md) # Requirements @@ -49,7 +47,7 @@ * Xcode 5.1 or newer for iOS or Mac * gcc 4.9 or newer for Linux -* ndk-r9d or newer for Android +* ndk-r9d for Android * Visual Studio 2012 or newer for Windows (win32) * Visual Studio 2012 or newer for Windows Phone 8 @@ -117,179 +115,77 @@ Run Please refer to this document: [ReadMe](../README.md) -# Highlights of v3.2 +# Highlights of v3.3alpha0 -* `Animation3D`/`Animate3D`, new nodes for 3d animation -* `fbx-conv` supports generating binary format which is supported by `Sprite3D` -* Game controller support -* Fast tilemap support -* Added `utils::cpatureScreen` to take screenshot -* Physics body supports scale and rotation -* Added `Node::enumerateChildren` and `utils::findChildren`, and support c++ 11 regular expression -* Added `Node::setNormalizedPosition`, `Node`'s position in pixel will be calculated according its parent's content size - -# Documents - -* [Sprite3D & Animation3D](http://cocos2d-x.org/wiki/Sprite3D) -* [Game controller](http://www.cocos2d-x.org/wiki/Game_Controller) -* [How to compile shader on WP8](http://cocos2d-x.org/wiki/How_to_update_wp8_shader) - -# Toolchain requirement changed - -`Node::enumerateChildren()` uses `std::regex` which will cause crash using gcc v4.8 or lower version. -Because `OTHER_LDFLAGS` can not work in Xcode6 beta3. So we used fat library(including 64-bit libaries) on iOS. But Xcode 5.0 or lower version has building problem by this way. - -So - -* NDK r9d or newer version is required for Android building -* gcc 4.9 is required for linux building -* Xcode 5.1 or newer is required on iOS - -# atof issue on Android - -We found a bug of `atof` on Android when using libc++. The bug is that, the return value of `atof` may be `-inf` when passing some valid digit string. - -For example - -```c++ -atof("90.099998474121094"); // -> return value is -inf -``` - -We have reported it to google guys, and they confirmed that it is a bug. In order to work around this issue, we added `utils::atof()`. - -The corresponding pull request for this issue is [here](https://github.com/cocos2d/cocos2d-x/pull/7440). You can refer to this pull request for demail information. +* 3d: `Camera`, `AABB`, `OBB` and `Ray` +* ui: added `Scale9Sprite` +* FileUitls: added `isDirectoryExist()`, `createDirectory()`, `removeDirectory()`, `removeFile()`, `renameFile()` and `getFileSize()` +* Device: added `setKeepScreenOn()` on iOS and Android +* Added c++11 random support +* RenderTexture: added a call back function for `saveToFile()` +* SpriteFrameCache: support loading from plist file content data +* Many other small features added and many bugs fixed # Features in detail -## Sprite3D & Animation3D +## Camera + +This version of camera is powerful then previous one. And you can add it as a child anywhere. If you want to let a Node to be visited by a camera, Node's camera mask should include Camera's flag: -Sample code to use binary version ```c++ -auto sprite3d = Sprite3D::create("filename.c3b"); -addChild(sprite3d); - -auto animation3d = Animation3D("filename.c3b"); -auto animate3d = Animate3D::create(animation3d); -sprite3d->runAction(RepeatForEver::create(animate)); +// let sprite to be visited by a camera +auto sprite = Sprite::create("myFile.png"); +sprite->setCameraMask(CameraFlag::USER1); +auto camera = Camera::createPerspective(60, winSize.width/winSize.height, 1, 1000); +camera->setCameraFlag(CameraFlag::USER1); +scene->addChild(camera); ``` -Detail information please refer to [Sprite3D & Animation3D](http://cocos2d-x.org/wiki/Sprite3D). +If you have many Nodes that want to be visited by a camera, there is a convenient way: -### `fbx-conv` usage - -* Mac OS X - -``` -$ cd COCOS2DX_ROOT/tools/fbx-conv/mac -$ ./fbx-conv [-a|-b|-t] FBXFile -``` - -* Windows - -``` -cd COCOS2DX_ROOT/tools/fbx-conv/windows -fbx-conv [-a|-b|-t] FBXFile -``` - -Options: - -* -a: export both text and binary format -* -b: export binary format -* -t: export text format - -## Game controller - -Supported controller type: - -* Android standard controllers -* Amazon tv -* OUYA -* Moga -* Nibiru -* iOS standard controllers - -Sample codes ```c++ -// register event listener -auto listener = EventListenerController::create(); -listner->onKeyDown = ... +auto layer = Layer::create(); +auto sprite1 = Sprite::create(); +auto sprite2 = Sprite::create(); +layer->addChild(sprite1); +layer->addChild(sprite2); +// it will set camera mask for all its children +layer->setCameraMask(CameraFlg::USER1); + +auto camera = Camera::createPerspective(); +camera->setCameraFlag(CameraFlag::USER1); +scene->addChild(camera); +``` + +Full test case please refer to `tests/cpp-tests/res/Camera3DTest/Camera3DTest.cpp`. + +## AABB, OBB and Ray + +TBD + +## ui::Scale9Sprite + +TBD + +## c++11 random support + +Since `rand()` is not good(refer to [this document](http://c-faq.com/lib/randrange.html)), we use c++11 random library to do generate random number, and provide a function to easily using: + +```c++ +int randInt = cocos2d::random(1, 10); +float randFloat = cocos2d::random(1.f, 10.f); +``` + +## RenderTexture save function + +`RenderTexture::saveToFile()` will not save rendertexture when the function returns, because it just send render command to renderer. The file will be saved after render command is executed. It is not convenient if you want to use the saved file to do some work. So we added a parameter in `RenderTexture::saveToFile()` to set a call back function when the file is saved. + +```c++ +renderTexture->begin(); ... -eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); +renderTexture->end(); -// start connecting controller -Controller::startDiscoveryController(); +renderTexture->saveToFile("myFile.png", true, callback); -// handler key down/ key up event -void GameControllerTest::onKeyDown(Controller *controller, int keyCode, Event *event) -{ - switch (keyCode) - { - case Controller::Key::BUTTON_A: - ... - break; - - ... - } -} ``` -Detail information please refer to [Game controller](http://www.cocos2d-x.org/wiki/Game_Controller). - -## Fast tilemap - -Fast tilemap has the same API as `TMXTiledMap` without deprecated functions. - -Sample code -```c++ -auto tilemap = cocos2d::experimental::TMXTiledMap::create("MyFile.tmx"); -addChild(tilemap); -``` - -Full demo please refer to `COCOS2DX_ROOT/tests/cpp-tests/Classes/TileMapTest/TileMapTest2.cpp`. - -## Node::enumerateChildren - -This functions is used to enumerate children of a `Node`. It supports c++ 11 regular expression. - -```c++ -// Find nodes whose name is 'nameToFind' and end with digits. -node->enumerateChildren("nameToFind[[:digit:]]+", [](Node* node) -> bool { - ... - return false; // return true to stop at first match -}); - -// Find nodes whose name is 'nameToFind' and end with digits recursively. -node->enumerateChildren("nameToFind[[:digit:]]+", [](Node* node) -> bool { - ... - return false; // return true to stop at first match -}); -``` - -Full test please refer to `NodeNameTest` in `COCOS2DX_ROOT/tests/cpp-tests/NodeTest/NodeTest.cpp`. - -Because this function uses `std::regex` which is not supported well in gcc 4.8 or lower version. So we use `clang` and `stdc++` instead for Android building. This lead to the result that `NDK r9d` or newer is required. And `gcc 4.9` is required on linux. - -## utils::findChildren - -This is a helper function to find children of a `Node` share a name. The implementation of this function bases on `Node::enumerateChildren`. - -```c++ -auto children = utils::findChildren(node, "nameToFind"); - -... -``` - -## Node::setNormalizedPosition - -Can use this function to set Node's position(x,y) using value between 0 and 1. `Can use this function when it has a parent node.` The positions in pixels is calculated like the following: - -```c++ -// pseudo code -void setNormalizedPosition(Vec2 pos) -{ - Size s = getParent()->getContentSize(); - _position = pos * s; -} -``` - -Full test please refer to `NodeNormalizedPositionTest1/2` in `tests/cpp-tests/Classes/NodeTest/NodeTest.cpp`.