Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into v3_new_spine

This commit is contained in:
samuele3hu 2014-10-17 17:37:18 +08:00
commit 30f375ef07
19 changed files with 239 additions and 142 deletions

View File

@ -204,9 +204,9 @@ def build_samples(target,ndk_build_param,android_platform,build_mode):
exit(1)
if build_mode is None:
build_mode = 'debug'
elif build_mode != 'release':
build_mode = 'debug'
build_mode = 'release'
elif build_mode != 'debug':
build_mode = 'release'
app_android_root = ''

View File

@ -2622,12 +2622,12 @@
1D6058910D05DD3D006BFB54 /* cpp-tests Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "cpp-tests Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; };
1F33634D18E37E840074764D /* RefPtrTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RefPtrTest.cpp; sourceTree = "<group>"; };
1F33634E18E37E840074764D /* RefPtrTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RefPtrTest.h; sourceTree = "<group>"; };
29080D1A191B574B0066F8DF /* UITest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UITest.cpp; path = ../UITest.cpp; sourceTree = "<group>"; };
29080D1B191B574B0066F8DF /* UITest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UITest.h; path = ../UITest.h; sourceTree = "<group>"; };
29080D1A191B574B0066F8DF /* UITest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UITest.cpp; path = UITest/UITest.cpp; sourceTree = "<group>"; };
29080D1B191B574B0066F8DF /* UITest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UITest.h; path = UITest/UITest.h; sourceTree = "<group>"; };
29080D1F191B595E0066F8DF /* CocosGUIScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CocosGUIScene.cpp; sourceTree = "<group>"; };
29080D20191B595E0066F8DF /* CocosGUIScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocosGUIScene.h; sourceTree = "<group>"; };
29080D21191B595E0066F8DF /* CocoStudioGUITest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CocoStudioGUITest.cpp; sourceTree = "<group>"; };
29080D22191B595E0066F8DF /* CocoStudioGUITest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocoStudioGUITest.h; sourceTree = "<group>"; };
29080D21191B595E0066F8DF /* CocoStudioGUITest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CocoStudioGUITest.cpp; path = UITest/CocoStudioGUITest/CocoStudioGUITest.cpp; sourceTree = "<group>"; };
29080D22191B595E0066F8DF /* CocoStudioGUITest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CocoStudioGUITest.h; path = UITest/CocoStudioGUITest/CocoStudioGUITest.h; sourceTree = "<group>"; };
29080D23191B595E0066F8DF /* CustomGUIScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CustomGUIScene.cpp; path = ../CustomGUIScene.cpp; sourceTree = "<group>"; };
29080D24191B595E0066F8DF /* CustomGUIScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CustomGUIScene.h; path = ../CustomGUIScene.h; sourceTree = "<group>"; };
29080D27191B595E0066F8DF /* CustomImageTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomImageTest.cpp; sourceTree = "<group>"; };
@ -6482,14 +6482,6 @@
sourceTree = "<group>";
};
29080D17191B571F0066F8DF /* UITest */ = {
isa = PBXGroup;
children = (
29080D1E191B595E0066F8DF /* CocoStudioGUITest */,
);
name = UITest;
sourceTree = "<group>";
};
29080D1E191B595E0066F8DF /* CocoStudioGUITest */ = {
isa = PBXGroup;
children = (
29080D1A191B574B0066F8DF /* UITest.cpp */,
@ -6500,8 +6492,7 @@
29FBBBFB196A9ECD00E65826 /* CocostudioParserTest */,
29080D25191B595E0066F8DF /* CustomTest */,
);
name = CocoStudioGUITest;
path = UITest/CocoStudioGUITest;
name = UITest;
sourceTree = "<group>";
};
29080D25191B595E0066F8DF /* CustomTest */ = {
@ -6513,7 +6504,8 @@
29080D26191B595E0066F8DF /* CustomImageTest */,
29080D29191B595E0066F8DF /* CustomParticleWidgetTest */,
);
path = CustomTest;
name = CustomTest;
path = UITest/CocoStudioGUITest/CustomTest;
sourceTree = "<group>";
};
29080D26191B595E0066F8DF /* CustomImageTest */ = {
@ -6733,6 +6725,24 @@
name = UIWebViewTest;
sourceTree = "<group>";
};
29AAE28519F0BD02004F5A18 /* UIScale9SpriteTest */ = {
isa = PBXGroup;
children = (
295824571987415900F9746D /* UIScale9SpriteTest.cpp */,
295824581987415900F9746D /* UIScale9SpriteTest.h */,
);
name = UIScale9SpriteTest;
sourceTree = "<group>";
};
29AAE28619F0BD12004F5A18 /* UIEditBoxTest */ = {
isa = PBXGroup;
children = (
292CF01219A1965E00E8E6A0 /* UIEditBoxTest.cpp */,
292CF01319A1965E00E8E6A0 /* UIEditBoxTest.h */,
);
name = UIEditBoxTest;
sourceTree = "<group>";
};
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
isa = PBXGroup;
children = (
@ -6807,17 +6817,13 @@
29FBBBFC196A9ECD00E65826 /* CocostudioParserJsonTest.cpp */,
29FBBBFD196A9ECD00E65826 /* CocostudioParserJsonTest.h */,
);
path = CocostudioParserTest;
name = CocostudioParserTest;
path = UITest/CocoStudioGUITest/CocostudioParserTest;
sourceTree = "<group>";
};
29FBBC00196A9F0D00E65826 /* UIAndEditorTests */ = {
isa = PBXGroup;
children = (
298D7F6C19AC31C000FF096D /* UIWebViewTest */,
295824571987415900F9746D /* UIScale9SpriteTest.cpp */,
295824581987415900F9746D /* UIScale9SpriteTest.h */,
292CF01219A1965E00E8E6A0 /* UIEditBoxTest.cpp */,
292CF01319A1965E00E8E6A0 /* UIEditBoxTest.h */,
29080D1F191B595E0066F8DF /* CocosGUIScene.cpp */,
29080D20191B595E0066F8DF /* CocosGUIScene.h */,
29080D37191B595E0066F8DF /* GUIEditorTest.cpp */,
@ -6830,6 +6836,9 @@
29080D67191B595E0066F8DF /* UISceneManager.h */,
29080D68191B595E0066F8DF /* UISceneManager_Editor.cpp */,
29080D69191B595E0066F8DF /* UISceneManager_Editor.h */,
29AAE28619F0BD12004F5A18 /* UIEditBoxTest */,
29AAE28519F0BD02004F5A18 /* UIScale9SpriteTest */,
298D7F6C19AC31C000FF096D /* UIWebViewTest */,
29080D6A191B595E0066F8DF /* UIScrollViewTest */,
29080D6F191B595E0066F8DF /* UISliderTest */,
29080D74191B595E0066F8DF /* UITextAtlasTest */,
@ -6849,6 +6858,7 @@
3EA0FB6F191C844400B170C8 /* UIVideoPlayerTest */,
);
name = UIAndEditorTests;
path = UITest/CocoStudioGUITest;
sourceTree = "<group>";
};
38FA2E70194AEBE100FF2BE4 /* CocoStudioActionTimelineTest */ = {

View File

@ -44,6 +44,21 @@
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- create Animate3D by frame section, [startFrame, endFrame)<br>
-- param animation used to generate animate3D<br>
-- param startFrame<br>
-- param endFrame<br>
-- param frameRate default is 30 per second<br>
-- return Animate3D created using animate
-- @function [parent=#Animate3D] createWithFrames
-- @param self
-- @param #cc.Animation3D animation
-- @param #int startFrame
-- @param #int endFrame
-- @param #float frameRate
-- @return Animate3D#Animate3D ret (return value: cc.Animate3D)
--------------------------------
--
-- @function [parent=#Animate3D] startWithTarget

View File

@ -74,14 +74,4 @@
-- @function [parent=#SkeletonAnimation] clearTrack
-- @param self
--------------------------------
-- @overload self, string, string, float
-- @overload self, string, spAtlas, float
-- @function [parent=#SkeletonAnimation] createWithFile
-- @param self
-- @param #string skeletonDataFile
-- @param #spAtlas atlas
-- @param #float scale
-- @return SkeletonAnimation#SkeletonAnimation ret (retunr value: sp.SkeletonAnimation)
return nil

View File

@ -1754,6 +1754,59 @@ int lua_cocos2dx_3d_Animate3D_getTransitionTime(lua_State* tolua_S)
#endif
return 0;
}
int lua_cocos2dx_3d_Animate3D_createWithFrames(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"cc.Animate3D",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 3)
{
cocos2d::Animation3D* arg0;
int arg1;
int arg2;
ok &= luaval_to_object<cocos2d::Animation3D>(tolua_S, 2, "cc.Animation3D",&arg0);
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "cc.Animate3D:createWithFrames");
ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2, "cc.Animate3D:createWithFrames");
if(!ok)
return 0;
cocos2d::Animate3D* ret = cocos2d::Animate3D::createWithFrames(arg0, arg1, arg2);
object_to_luaval<cocos2d::Animate3D>(tolua_S, "cc.Animate3D",(cocos2d::Animate3D*)ret);
return 1;
}
if (argc == 4)
{
cocos2d::Animation3D* arg0;
int arg1;
int arg2;
double arg3;
ok &= luaval_to_object<cocos2d::Animation3D>(tolua_S, 2, "cc.Animation3D",&arg0);
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "cc.Animate3D:createWithFrames");
ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2, "cc.Animate3D:createWithFrames");
ok &= luaval_to_number(tolua_S, 5,&arg3, "cc.Animate3D:createWithFrames");
if(!ok)
return 0;
cocos2d::Animate3D* ret = cocos2d::Animate3D::createWithFrames(arg0, arg1, arg2, arg3);
object_to_luaval<cocos2d::Animate3D>(tolua_S, "cc.Animate3D",(cocos2d::Animate3D*)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Animate3D:createWithFrames",argc, 3);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Animate3D_createWithFrames'.",&tolua_err);
#endif
return 0;
}
static int lua_cocos2dx_3d_Animate3D_finalize(lua_State* tolua_S)
{
printf("luabindings: finalizing LUA object (Animate3D)");
@ -1772,6 +1825,7 @@ int lua_register_cocos2dx_3d_Animate3D(lua_State* tolua_S)
tolua_function(tolua_S,"getWeight",lua_cocos2dx_3d_Animate3D_getWeight);
tolua_function(tolua_S,"create", lua_cocos2dx_3d_Animate3D_create);
tolua_function(tolua_S,"getTransitionTime", lua_cocos2dx_3d_Animate3D_getTransitionTime);
tolua_function(tolua_S,"createWithFrames", lua_cocos2dx_3d_Animate3D_createWithFrames);
tolua_endmodule(tolua_S);
std::string typeName = typeid(cocos2d::Animate3D).name();
g_luaType[typeName] = "cc.Animate3D";

View File

@ -58,6 +58,7 @@ int register_all_cocos2dx_3d(lua_State* tolua_S);
#endif // __cocos2dx_3d_h__

View File

@ -1276,100 +1276,6 @@ int lua_cocos2dx_spine_SkeletonAnimation_clearTrack(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_spine_SkeletonAnimation_createWithFile(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S)-1;
do
{
if (argc == 2)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "sp.SkeletonAnimation:createWithFile");
if (!ok) { break; }
std::string arg1;
ok &= luaval_to_std_string(tolua_S, 3,&arg1, "sp.SkeletonAnimation:createWithFile");
if (!ok) { break; }
spine::SkeletonAnimation* ret = spine::SkeletonAnimation::createWithFile(arg0, arg1);
object_to_luaval<spine::SkeletonAnimation>(tolua_S, "sp.SkeletonAnimation",(spine::SkeletonAnimation*)ret);
return 1;
}
} while (0);
ok = true;
do
{
if (argc == 3)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "sp.SkeletonAnimation:createWithFile");
if (!ok) { break; }
std::string arg1;
ok &= luaval_to_std_string(tolua_S, 3,&arg1, "sp.SkeletonAnimation:createWithFile");
if (!ok) { break; }
double arg2;
ok &= luaval_to_number(tolua_S, 4,&arg2, "sp.SkeletonAnimation:createWithFile");
if (!ok) { break; }
spine::SkeletonAnimation* ret = spine::SkeletonAnimation::createWithFile(arg0, arg1, arg2);
object_to_luaval<spine::SkeletonAnimation>(tolua_S, "sp.SkeletonAnimation",(spine::SkeletonAnimation*)ret);
return 1;
}
} while (0);
ok = true;
do
{
if (argc == 2)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "sp.SkeletonAnimation:createWithFile");
if (!ok) { break; }
spAtlas* arg1;
#pragma warning NO CONVERSION TO NATIVE FOR spAtlas*
ok = false;
if (!ok) { break; }
spine::SkeletonAnimation* ret = spine::SkeletonAnimation::createWithFile(arg0, arg1);
object_to_luaval<spine::SkeletonAnimation>(tolua_S, "sp.SkeletonAnimation",(spine::SkeletonAnimation*)ret);
return 1;
}
} while (0);
ok = true;
do
{
if (argc == 3)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "sp.SkeletonAnimation:createWithFile");
if (!ok) { break; }
spAtlas* arg1;
#pragma warning NO CONVERSION TO NATIVE FOR spAtlas*
ok = false;
if (!ok) { break; }
double arg2;
ok &= luaval_to_number(tolua_S, 4,&arg2, "sp.SkeletonAnimation:createWithFile");
if (!ok) { break; }
spine::SkeletonAnimation* ret = spine::SkeletonAnimation::createWithFile(arg0, arg1, arg2);
object_to_luaval<spine::SkeletonAnimation>(tolua_S, "sp.SkeletonAnimation",(spine::SkeletonAnimation*)ret);
return 1;
}
} while (0);
ok = true;
CCLOG("%s has wrong number of arguments: %d, was expecting %d", "sp.SkeletonAnimation:createWithFile",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_spine_SkeletonAnimation_createWithFile'.",&tolua_err);
#endif
return 0;
}
static int lua_cocos2dx_spine_SkeletonAnimation_finalize(lua_State* tolua_S)
{
printf("luabindings: finalizing LUA object (SkeletonAnimation)");
@ -1393,7 +1299,6 @@ int lua_register_cocos2dx_spine_SkeletonAnimation(lua_State* tolua_S)
tolua_function(tolua_S,"setEndListener",lua_cocos2dx_spine_SkeletonAnimation_setEndListener);
tolua_function(tolua_S,"clearTracks",lua_cocos2dx_spine_SkeletonAnimation_clearTracks);
tolua_function(tolua_S,"clearTrack",lua_cocos2dx_spine_SkeletonAnimation_clearTrack);
tolua_function(tolua_S,"createWithFile", lua_cocos2dx_spine_SkeletonAnimation_createWithFile);
tolua_endmodule(tolua_S);
std::string typeName = typeid(spine::SkeletonAnimation).name();
g_luaType[typeName] = "sp.SkeletonAnimation";

View File

@ -37,7 +37,6 @@ int register_all_cocos2dx_spine(lua_State* tolua_S);
#endif // __cocos2dx_spine_h__

View File

@ -6,7 +6,7 @@ LOCAL_MODULE := cocos_localstorage_static
LOCAL_MODULE_FILENAME := liblocalstorage
LOCAL_SRC_FILES := LocalStorage.cpp \
LocalStorageAndroid.cpp
LocalStorage-android.cpp
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/..

View File

@ -1422,10 +1422,12 @@ void ScrollView::endRecordSlidAction()
}
float totalDis = 0.0f;
Vec2 dir;
Vec2 touchEndPositionInNodeSpace = this->convertToNodeSpace(_touchEndPosition);
Vec2 touchBeganPositionInNodeSpace = this->convertToNodeSpace(_touchBeganPosition);
switch (_direction)
{
case Direction::VERTICAL:
totalDis = _touchEndPosition.y - _touchBeganPosition.y;
totalDis = touchEndPositionInNodeSpace.y - touchBeganPositionInNodeSpace.y;
if (totalDis < 0.0f)
{
dir = SCROLLDIR_DOWN;
@ -1436,7 +1438,7 @@ void ScrollView::endRecordSlidAction()
}
break;
case Direction::HORIZONTAL:
totalDis = _touchEndPosition.x - _touchBeganPosition.x;
totalDis = touchEndPositionInNodeSpace.x - touchBeganPositionInNodeSpace.x;
if (totalDis < 0.0f)
{
dir = SCROLLDIR_LEFT;
@ -1448,7 +1450,7 @@ void ScrollView::endRecordSlidAction()
break;
case Direction::BOTH:
{
Vec2 subVector = _touchEndPosition - _touchBeganPosition;
Vec2 subVector = touchEndPositionInNodeSpace - touchBeganPositionInNodeSpace;
totalDis = subVector.getLength();
dir = subVector.getNormalized();
break;
@ -1470,7 +1472,9 @@ void ScrollView::handlePressLogic(Touch *touch)
void ScrollView::handleMoveLogic(Touch *touch)
{
Vec2 delta = touch->getLocation() - touch->getPreviousLocation();
Vec2 touchPositionInNodeSpace = this->convertToNodeSpace(touch->getLocation());
Vec2 previousTouchPositionInNodeSpace = this->convertToNodeSpace(touch->getPreviousLocation());
Vec2 delta = touchPositionInNodeSpace - previousTouchPositionInNodeSpace;
switch (_direction)
{
case Direction::VERTICAL: // vertical

View File

@ -54,7 +54,7 @@ bool HelloWorld::init()
// add a label shows "Hello World"
// create and initialize a label
auto label = Label::createWithTTF("Hello World", "Arial", 24);
auto label = Label::createWithTTF("Hello World", "fonts/Marker Felt.ttf", 24);
// position the label on the center of the screen
label->setPosition(Vec2(origin.x + visibleSize.width/2,

View File

@ -26,14 +26,35 @@
]
},
{
"from": "external/win32-specific/zlib/prebuilt",
"from": "external/win32-specific/icon/prebuilt",
"to": "runtime/win32",
"include": [
"*.dll"
]
},
{
"from": "external/win32-specific/icon/prebuilt",
"from": "external/win32-specific/MP3Decoder/prebuilt",
"to": "runtime/win32",
"include": [
"*.dll"
]
},
{
"from": "external/win32-specific/OggDecoder/prebuilt",
"to": "runtime/win32",
"include": [
"*.dll"
]
},
{
"from": "external/win32-specific/OpenalSoft/prebuilt",
"to": "runtime/win32",
"include": [
"*.dll"
]
},
{
"from": "external/win32-specific/zlib/prebuilt",
"to": "runtime/win32",
"include": [
"*.dll"

View File

@ -93,6 +93,7 @@ void startScript(string strDebugArg)
if (!strDebugArg.empty())
{
// open debugger.lua module
luaopen_lua_debugger(engine->getLuaStack()->getLuaState());
engine->executeString(strDebugArg.c_str());
}
cocos2d::log("debug args = %s", strDebugArg.c_str());
@ -1220,7 +1221,6 @@ void initRuntime()
auto engine = LuaEngine::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(engine);
register_runtime_override_function(engine->getLuaStack()->getLuaState());
luaopen_lua_debugger(engine->getLuaStack()->getLuaState());
static ConsoleCustomCommand *g_customCommand;
g_customCommand = new ConsoleCustomCommand();

View File

@ -214,6 +214,7 @@ void SceneEditorTestLayer::changeLoadTypeCallback(cocos2d::Ref *pSender)
if(_rootNode != nullptr)
{
ActionManagerEx::getInstance()->releaseActions();
this->removeChild(_rootNode);
_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str());
if (_rootNode == nullptr)

View File

@ -211,7 +211,7 @@ g_guisTests[] =
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
sceneManager->setCurrentUISceneId(kUIScrollViewTest_Vertical);
sceneManager->setMinUISceneId(kUIScrollViewTest_Vertical);
sceneManager->setMaxUISceneId(kUIScrollViewNestTest);
sceneManager->setMaxUISceneId(kUIScrollViewRotated);
Scene* scene = sceneManager->currentUIScene();
Director::getInstance()->replaceScene(scene);
}

View File

@ -91,6 +91,7 @@ static const char* s_testArray[] =
"UIScrollViewTest_ScrollToPercentBothDirection",
"UIScrollViewTest_ScrollToPercentBothDirection_Bounce",
"UIScrollViewNestTest",
"UIScrollViewRotated",
"UIPageViewTest",
"UIPageViewButtonTest",
@ -323,6 +324,9 @@ Scene *UISceneManager::currentUIScene()
return UIScrollViewTest_ScrollToPercentBothDirection_Bounce::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIScrollViewNestTest:
return UIScrollViewNestTest::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIScrollViewRotated:
return UIScrollViewRotated::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIPageViewTest:
return UIPageViewTest::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIPageViewButtonTest:

View File

@ -82,6 +82,8 @@ enum
kUIScrollViewTest_ScrollToPercentBothDirection,
kUIScrollViewTest_ScrollToPercentBothDirection_Bounce,
kUIScrollViewNestTest,
kUIScrollViewRotated,
kUIPageViewTest,
kUIPageViewButtonTest,
kUIPageViewCustomScrollThreshold,

View File

@ -39,7 +39,7 @@ bool UIScrollViewTest_Vertical::init()
// Create the scrollview by vertical
ui::ScrollView* scrollView = ui::ScrollView::create();
scrollView->setContentSize(Size(280.0f, 150.0f));
scrollView->setContentSize(Size(280.0f, 100.0f));
Size backgroundSize = background->getContentSize();
scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
(backgroundSize.width - scrollView->getContentSize().width) / 2.0f,
@ -71,7 +71,8 @@ bool UIScrollViewTest_Vertical::init()
imageView->setPosition(Vec2(innerWidth / 2.0f, imageView->getContentSize().height / 2.0f));
scrollView->addChild(imageView);
return true;
}
@ -425,3 +426,81 @@ bool UIScrollViewNestTest::init()
return false;
}
// UIScrollViewRotated
UIScrollViewRotated::UIScrollViewRotated()
: _displayValueLabel(nullptr)
{
}
UIScrollViewRotated::~UIScrollViewRotated()
{
}
bool UIScrollViewRotated::init()
{
if (UIScene::init())
{
Size widgetSize = _widget->getContentSize();
// Add a label in which the scrollview alert will be displayed
_displayValueLabel = Text::create("Move by vertical direction", "fonts/Marker Felt.ttf", 32);
_displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
_displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f,
widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
_uiLayer->addChild(_displayValueLabel);
// Add the alert
Text* alert = Text::create("ScrollView vertical", "fonts/Marker Felt.ttf", 30);
alert->setColor(Color3B(159, 168, 176));
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
_uiLayer->addChild(alert);
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel"));
// Create the scrollview by vertical
ui::ScrollView* scrollView = ui::ScrollView::create();
scrollView->setContentSize(Size(280.0f, 150.0f));
scrollView->setDirection(ui::ScrollView::Direction::BOTH);
Size backgroundSize = background->getContentSize();
scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
(backgroundSize.width - scrollView->getContentSize().width) / 2.0f,
(widgetSize.height - backgroundSize.height) / 2.0f +
(backgroundSize.height - scrollView->getContentSize().height) / 2.0f + 100) );
scrollView->setRotation(45);
_uiLayer->addChild(scrollView);
ImageView* imageView = ImageView::create("cocosui/ccicon.png");
float innerWidth = scrollView->getContentSize().width;
float innerHeight = scrollView->getContentSize().height + imageView->getContentSize().height;
scrollView->setInnerContainerSize(Size(innerWidth, innerHeight));
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
button->setPosition(Vec2(innerWidth / 2.0f, scrollView->getInnerContainerSize().height - button->getContentSize().height / 2.0f));
scrollView->addChild(button);
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
titleButton->setTitleText("Title Button");
titleButton->setPosition(Vec2(innerWidth / 2.0f, button->getBottomBoundary() - button->getContentSize().height));
scrollView->addChild(titleButton);
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
button_scale9->setScale9Enabled(true);
button_scale9->setContentSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
button_scale9->setPosition(Vec2(innerWidth / 2.0f, titleButton->getBottomBoundary() - titleButton->getContentSize().height));
scrollView->addChild(button_scale9);
imageView->setPosition(Vec2(innerWidth / 2.0f, imageView->getContentSize().height / 2.0f));
scrollView->addChild(imageView);
return true;
}
return false;
}

View File

@ -99,4 +99,16 @@ protected:
Text* _displayValueLabel;
};
class UIScrollViewRotated : public UIScene
{
public:
UIScrollViewRotated();
~UIScrollViewRotated();
bool init();
protected:
UI_SCENE_CREATE_FUNC(UIScrollViewRotated)
Text* _displayValueLabel;
};
#endif /* defined(__TestCpp__UIScrollViewTest__) */