From 359fdb92f2cab8c5e6252bacdb2582343a14ca52 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 22 Jun 2016 14:05:58 +0800 Subject: [PATCH] remove studio related test cases --- .../CocoStudioActionTimelineTest.lua | 751 ---- .../CocoStudioActionTimelineTest2.lua | 726 ---- .../CocoStudioArmatureTest.lua | 1265 ------- .../CocoStudioGUITest/CocoStudioGUITest.lua | 3165 ----------------- .../CocoStudioSceneTest.lua | 929 ----- .../CocoStudioSceneTest/TriggerCode/acts.lua | 170 - .../CocoStudioSceneTest/TriggerCode/cons.lua | 53 - .../TriggerCode/eventDef.lua | 12 - .../src/CocoStudioTest/CocoStudioTest.lua | 135 - .../CocoStudioUIEditorTest.lua | 1442 -------- .../CocosStudio3DTest/CocosStudio3DTest.lua | 111 - tests/lua-tests/src/controller.lua | 70 - tests/lua-tests/src/mainMenu.lua | 4 - 13 files changed, 8833 deletions(-) delete mode 100644 tests/lua-tests/src/CocoStudioTest/CocoStudioActionTimelineTest/CocoStudioActionTimelineTest.lua delete mode 100644 tests/lua-tests/src/CocoStudioTest/CocoStudioActionTimelineTest2/CocoStudioActionTimelineTest2.lua delete mode 100644 tests/lua-tests/src/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua delete mode 100644 tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua delete mode 100644 tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua delete mode 100644 tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/TriggerCode/acts.lua delete mode 100644 tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/TriggerCode/cons.lua delete mode 100644 tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/TriggerCode/eventDef.lua delete mode 100644 tests/lua-tests/src/CocoStudioTest/CocoStudioTest.lua delete mode 100644 tests/lua-tests/src/CocoStudioTest/CocoStudioUIEditorTest/CocoStudioUIEditorTest.lua delete mode 100644 tests/lua-tests/src/CocosStudio3DTest/CocosStudio3DTest.lua diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioActionTimelineTest/CocoStudioActionTimelineTest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioActionTimelineTest/CocoStudioActionTimelineTest.lua deleted file mode 100644 index f07bf95df2..0000000000 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioActionTimelineTest/CocoStudioActionTimelineTest.lua +++ /dev/null @@ -1,751 +0,0 @@ -local itemTagBasic = 1000 -local winSize = cc.Director:getInstance():getWinSize() -local scheduler = cc.Director:getInstance():getScheduler() -local TimelineTestIndex = -{ - TEST_ACTION_TIMELINE = 1, - TEST_CHANGE_PLAY_SECTION = 2, - TEST_TIMELINE_FRAME_EVENT = 3, - TEST_TIMELINE_PERFORMACE = 4, - TEST_TIMELINE_ANIMATION_LIST = 5, - TEST_TIMELINE_PROJECT_NODE = 6, - TEST_PROJECT_NODE_FOR_SIMULATOR = 7, - TEST_TIMELINE_NODE_LOADED_CALLBACK = 8, - TEST_ACTION_TIMELINE_EASE = 9, -} -local timelineSceneIdx = TimelineTestIndex.TEST_ACTION_TIMELINE - -local TimelineTestScene = class("TimelineTestScene") -TimelineTestScene.__index = TimelineTestScene - -function TimelineTestScene.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TimelineTestScene) - return target -end - -function TimelineTestScene:runThisTest() - timelineSceneIdx = TimelineTestIndex.TEST_ACTION_TIMELINE - self:addChild(restartTimelineTest()) -end - -function TimelineTestScene.create() - local scene = TimelineTestScene.extend(cc.Scene:create()) - local bg = cc.Sprite:create("armature/bg.jpg") - bg:setPosition(VisibleRect:center()) - - local scaleX = VisibleRect:getVisibleRect().width / bg:getContentSize().width - local scaleY = VisibleRect:getVisibleRect().height / bg:getContentSize().height - - bg:setScaleX(scaleX) - bg:setScaleY(scaleY) - - scene:addChild(bg) - return scene -end - -function TimelineTestScene.toMainMenuCallback() - -end - -local TimelineTestLayer = class("TimelineTestLayer") -TimelineTestLayer.__index = TimelineTestLayer -TimelineTestLayer._backItem = nil -TimelineTestLayer._restarItem = nil -TimelineTestLayer._nextItem = nil - -function TimelineTestLayer:onEnter() - -end - -function TimelineTestLayer.title(idx) - if TimelineTestIndex.TEST_ACTION_TIMELINE == idx then - return "Test ActionTimeline" - elseif TimelineTestIndex.TEST_CHANGE_PLAY_SECTION == idx then - return "Test Change Play Section" - elseif TimelineTestIndex.TEST_TIMELINE_FRAME_EVENT == idx then - return "Test Frame Event" - elseif TimelineTestIndex.TEST_TIMELINE_PERFORMACE == idx then - return "Test ActionTimeline performance" - elseif TimelineTestIndex.TEST_ACTION_TIMELINE_EASE == idx then - return "Test ActionTimelineEase" - elseif TimelineTestIndex.TEST_TIMELINE_ANIMATION_LIST == idx then - return "Test ActionTimeline AnimationList" - elseif TimelineTestIndex.TEST_TIMELINE_PROJECT_NODE == idx then - return "Test ActionTimeline ProjectNode" - elseif TimelineTestIndex.TEST_PROJECT_NODE_FOR_SIMULATOR == idx then - return "Test ProjectNode for Simalator" - elseif TimelineTestIndex.TEST_TIMELINE_NODE_LOADED_CALLBACK == idx then - return "Test node loaded call back" - end -end - -function TimelineTestLayer.subTitle(idx) - if TimelineTestIndex.TEST_ACTION_TIMELINE == idx then - return "" - else - return "" - end -end - -function TimelineTestLayer.create() - local layer = TimelineTestLayer.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -function TimelineTestLayer.backCallback() - local newScene = TimelineTestScene.create() - newScene:addChild(backTimelineTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TimelineTestLayer.restartCallback() - local newScene = TimelineTestScene.create() - newScene:addChild(restartTimelineTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TimelineTestLayer.nextCallback() - local newScene = TimelineTestScene.create() - newScene:addChild(nextTimelineTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TimelineTestLayer:createMenu() - local menu = cc.Menu:create() - - self._backItem = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) - self._backItem:registerScriptTapHandler(self.backCallback) - menu:addChild(self._backItem,itemTagBasic) - self._restarItem = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) - self._restarItem:registerScriptTapHandler(self.restartCallback) - menu:addChild(self._restarItem,itemTagBasic) - self._nextItem = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) - menu:addChild(self._nextItem,itemTagBasic) - self._nextItem:registerScriptTapHandler(self.nextCallback) - - local size = cc.Director:getInstance():getWinSize() - self._backItem:setPosition(cc.p(size.width / 2 - self._restarItem:getContentSize().width * 2, self._restarItem:getContentSize().height / 2)) - self._restarItem:setPosition(cc.p(size.width / 2, self._restarItem:getContentSize().height / 2)) - self._nextItem:setPosition(cc.p(size.width / 2 + self._restarItem:getContentSize().width * 2, self._restarItem:getContentSize().height / 2)) - - menu:setPosition(cc.p(0, 0)) - - self:addChild(menu) -end - -function TimelineTestLayer.toExtensionMenu() - ccs.ArmatureDataManager:destroyInstance() - local scene = CocoStudioTestMain() - if scene ~= nil then - cc.Director:getInstance():replaceScene(scene) - end -end - -function TimelineTestLayer:createToExtensionMenu() - cc.MenuItemFont:setFontName("Arial") - cc.MenuItemFont:setFontSize(24) - local menuItemFont = cc.MenuItemFont:create("Back") - menuItemFont:setPosition(cc.p(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) - menuItemFont:registerScriptTapHandler(TimelineTestLayer.toExtensionMenu) - - local backMenu = cc.Menu:create() - backMenu:addChild(menuItemFont) - backMenu:setPosition(cc.p(0, 0)) - self:addChild(backMenu,10) -end - -function TimelineTestLayer:creatTitleAndSubTitle(idx) - print("set title") - local title = cc.Label:createWithTTF(TimelineTestLayer.title(idx), "fonts/Thonburi.ttf", 18) - title:setColor(cc.c3b(255,0,0)) - self:addChild(title, 1, 10000) - title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30)) - local subTitle = nil - if "" ~= TimelineTestLayer.subTitle(idx) then - local subTitle = cc.Label:createWithTTF(TimelineTestLayer.subTitle(idx), "fonts/Thonburi.ttf", 18) - subTitle:setColor(cc.c3b(0,0,0)) - self:addChild(subTitle, 1, 10001) - subTitle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 60) ) - end -end - -local TestActionTimeline = class("TestActionTimeline",TimelineTestLayer) -TestActionTimeline.__index = TestActionTimeline - -function TestActionTimeline.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestActionTimeline) - return target -end - -function TestActionTimeline:onEnter() - - local node = cc.CSLoader:createNode("ActionTimeline/DemoPlayer.csb") - local action = cc.CSLoader:createTimeline("ActionTimeline/DemoPlayer.csb") - node:runAction(action) - action:gotoFrameAndPlay(0) - - node:setScale(0.2) - node:setPosition(VisibleRect:center()) - - self:addChild(node) -end - -function TestActionTimeline.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = TimelineTestScene.create() - newScene:addChild(restartTimelineTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestActionTimeline.create() - local layer = TestActionTimeline.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local TestChangePlaySection = class("TestChangePlaySection",TimelineTestLayer) -TestChangePlaySection.__index = TestChangePlaySection - -function TestChangePlaySection.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestChangePlaySection) - return target -end - -function TestChangePlaySection:onEnter() - - local node = cc.CSLoader:createNode("ActionTimeline/DemoPlayer.csb") - local action = cc.CSLoader:createTimeline("ActionTimeline/DemoPlayer.csb") - node:runAction(action) - action:gotoFrameAndPlay(41) - - - node:setScale(0.2) - node:setPosition(VisibleRect:center()) - - action:addAnimationInfo(ccs.AnimationInfo("stand", 0 , 40)) - action:addAnimationInfo(ccs.AnimationInfo("walk", 41 , 81)) - action:addAnimationInfo(ccs.AnimationInfo("killall", 174, 249)) - - assert(action:IsAnimationInfoExists("stand") == true, "stand animation didn't exist") - action:play("stand", true) - assert(action:getAnimationInfo("stand").endIndex == 40, "endIndex of animationInfo is not 40") - action:removeAnimationInfo("stand") - assert(action:IsAnimationInfoExists("stand") == false, "stand animation has already existed") - - local function onTouchesEnded(touches, event) - if action:getStartFrame() == 0 then - action:gotoFrameAndPlay(41, 81, true) - else - action:gotoFrameAndPlay(0, 40, true) - end - end - - local listener = cc.EventListenerTouchAllAtOnce:create() - listener:registerScriptHandler(onTouchesEnded,cc.Handler.EVENT_TOUCHES_ENDED ) - - local eventDispatcher = self:getEventDispatcher() - eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self) - - self:addChild(node) -end - -function TestChangePlaySection.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = TimelineTestScene.create() - newScene:addChild(restartTimelineTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestChangePlaySection.create() - local layer = TestChangePlaySection.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local TestTimelineFrameEvent = class("TestTimelineFrameEvent",TimelineTestLayer) -TestTimelineFrameEvent.__index = TestTimelineFrameEvent - -function TestTimelineFrameEvent.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestTimelineFrameEvent) - return target -end - -function TestTimelineFrameEvent:onEnter() - - local node = cc.CSLoader:createNode("ActionTimeline/DemoPlayer.csb") - local action = cc.CSLoader:createTimeline("ActionTimeline/DemoPlayer.csb") - node:runAction(action) - action:gotoFrameAndPlay(0) - - node:setScale(0.2) - node:setPosition(VisibleRect:center()) - self:addChild(node) - - local function onFrameEvent(frame) - if nil == frame then - return - end - - local str = frame:getEvent() - - if str == "changeColor" then - frame:getNode():setColor(cc.c3b(0, 0, 0)) - elseif(str == "endChangeColor") then - frame:getNode():setColor(cc.c3b(255,255,255)) - end - end - - action:setFrameEventCallFunc(onFrameEvent) -end - -function TestTimelineFrameEvent.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = TimelineTestScene.create() - newScene:addChild(restartTimelineTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestTimelineFrameEvent.create() - local layer = TestTimelineFrameEvent.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local TestTimelinePerformance = class("TestTimelinePerformance",TimelineTestLayer) -TestTimelinePerformance.__index = TestTimelinePerformance - -function TestTimelinePerformance.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestTimelinePerformance) - return target -end - -function TestTimelinePerformance:onEnter() - - for i = 1,100 do - local node = cc.CSLoader:createNode("ActionTimeline/DemoPlayer.csb") - local action = cc.CSLoader:createTimeline("ActionTimeline/DemoPlayer.csb") - node:runAction(action) - action:gotoFrameAndPlay(41) - - node:setScale(0.1) - node:setPosition((i - 1) * 2, 100) - self:addChild(node) - end -end - -function TestTimelinePerformance.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = TimelineTestScene.create() - newScene:addChild(restartTimelineTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestTimelinePerformance.create() - local layer = TestTimelinePerformance.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -------------------------------------------- ----TestTimelineAnimationList -------------------------------------------- -local TestTimelineAnimationList = class("TestTimelineAnimationList",TimelineTestLayer) -TestTimelineAnimationList.__index = TestTimelineAnimationList - -function TestTimelineAnimationList.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestTimelineAnimationList) - return target -end - -function TestTimelineAnimationList:onEnter() - local node = cc.CSLoader:createNode("ActionTimeline/DemoPlayer.csb") - local action = cc.CSLoader:createTimeline("ActionTimeline/DemoPlayer.csb") - local standInfo = ccs.AnimationInfo("stand", 0, 40) - local walkInfo = ccs.AnimationInfo("walk", 41, 81) - action:addAnimationInfo(standInfo) - action:addAnimationInfo(walkInfo) - node:runAction(action) - action:play("walk", true) - - node:setScale(0.2) - node:setPosition(150,100) - self:addChild(node) -end - -function TestTimelineAnimationList.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = TimelineTestScene.create() - newScene:addChild(restartTimelineTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestTimelineAnimationList.create() - local layer = TestTimelineAnimationList.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - - -------------------------------------------- ----TestTimelineProjectNode -------------------------------------------- -local TestTimelineProjectNode = class("TestTimelineProjectNode",TimelineTestLayer) -TestTimelineProjectNode.__index = TestTimelineProjectNode - -function TestTimelineProjectNode.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestTimelineProjectNode) - return target -end - -function TestTimelineProjectNode:onEnter() - local node = cc.CSLoader:createNode("ActionTimeline/TestAnimation.csb") - local action = cc.CSLoader:createTimeline("ActionTimeline/TestAnimation.csb") - - node:runAction(action) - action:gotoFrameAndPlay(0, true) - - node:setPosition(-300, -300) - self:addChild(node) -end - -function TestTimelineProjectNode.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = TimelineTestScene.create() - newScene:addChild(restartTimelineTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestTimelineProjectNode.create() - local layer = TestTimelineProjectNode.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - - -------------------------------------------- ----TestProjectNodeForSimulator -------------------------------------------- -local TestProjectNodeForSimulator = class("TestProjectNodeForSimulator",TimelineTestLayer) -TestProjectNodeForSimulator.__index = TestProjectNodeForSimulator - -function TestProjectNodeForSimulator.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestProjectNodeForSimulator) - return target -end - -function TestProjectNodeForSimulator:onEnter() - local node = cc.CSLoader:getInstance():createNodeWithFlatBuffersForSimulator("ActionTimeline/TestAnimation.csd") - local action = ccs.ActionTimelineCache:getInstance():createActionWithFlatBuffersForSimulator("ActionTimeline/TestAnimation.csd") - - node:runAction(action) - action:gotoFrameAndPlay(0, true) - - node:setPosition(-300, -300) - self:addChild(node) - - --test for when ProjectNode file lost - local lackProjectNodefileNode = cc.CSLoader:getInstance():createNodeWithFlatBuffersForSimulator("ActionTimeline/TestNullProjectNode.csd") - local lackProjectNodefileAction = ccs.ActionTimelineCache:getInstance():createActionWithFlatBuffersForSimulator("ActionTimeline/TestNullProjectNode.csd") - lackProjectNodefileNode:runAction(lackProjectNodefileAction) - lackProjectNodefileAction:gotoFrameAndPlay(0) - self:addChild(lackProjectNodefileNode) -end - -function TestProjectNodeForSimulator.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = TimelineTestScene.create() - newScene:addChild(restartTimelineTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestProjectNodeForSimulator.create() - local layer = TestProjectNodeForSimulator.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -------------------------------------------- ----TestTimelineNodeLoadedCallback -------------------------------------------- -local TestTimelineNodeLoadedCallback = class("TestTimelineNodeLoadedCallback",TimelineTestLayer) -TestTimelineNodeLoadedCallback.__index = TestTimelineNodeLoadedCallback - -function TestTimelineNodeLoadedCallback.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestTimelineNodeLoadedCallback) - return target -end - -function TestTimelineNodeLoadedCallback:onEnter() - local node = cc.CSLoader:createNode("ActionTimeline/DemoPlayer.csb", function(object) - if nil ~= object then - print("object type is ", tolua.type(object)) - print("node name = ",object:getName()) - print("node parent name = ", object:getParent():getName()) - end - end) - local action = cc.CSLoader:createTimeline("ActionTimeline/DemoPlayer.csb") - node:runAction(action) - action:gotoFrameAndPlay(0) - - node:setScale(0.2) - node:setPosition(VisibleRect:center()) - - self:addChild(node) -end - -function TestTimelineNodeLoadedCallback.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = TimelineTestScene.create() - newScene:addChild(restartTimelineTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestTimelineNodeLoadedCallback.create() - local layer = TestTimelineNodeLoadedCallback.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -------------------------------------------- ----TestActionTimelineEase -------------------------------------------- -local TestActionTimelineEase = class("TestActionTimelineEase",TimelineTestLayer) -TestActionTimelineEase.__index = TestActionTimelineEase - -function TestActionTimelineEase.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestActionTimelineEase) - return target -end - -function TestActionTimelineEase:onEnter() - local node = cc.CSLoader:createNode("ActionTimeline/ActionTimelineEase.csb") - local action = cc.CSLoader:createTimeline("ActionTimeline/ActionTimelineEase.csb") - node:runAction(action) - action:gotoFrameAndPlay(0) - self:addChild(node) -end - -function TestActionTimelineEase.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = TimelineTestScene.create() - newScene:addChild(restartTimelineTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestActionTimelineEase.create() - local layer = TestActionTimelineEase.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local actionlineSceneArr = -{ - TestActionTimeline.create, - TestChangePlaySection.create, - TestTimelineFrameEvent.create, - TestTimelinePerformance.create, - TestTimelineAnimationList.create, - TestTimelineProjectNode.create, - TestProjectNodeForSimulator.create, - TestTimelineNodeLoadedCallback.create, - TestActionTimelineEase.create, -} - -function nextTimelineTest() - timelineSceneIdx = timelineSceneIdx + 1 - timelineSceneIdx = timelineSceneIdx % table.getn(actionlineSceneArr) - if 0 == timelineSceneIdx then - timelineSceneIdx = table.getn(actionlineSceneArr) - end - return actionlineSceneArr[timelineSceneIdx]() -end - -function backTimelineTest() - timelineSceneIdx = timelineSceneIdx - 1 - if timelineSceneIdx <= 0 then - timelineSceneIdx = timelineSceneIdx + table.getn(actionlineSceneArr) - end - - return actionlineSceneArr[timelineSceneIdx]() -end - -function restartTimelineTest() - return actionlineSceneArr[timelineSceneIdx]() -end - -function runCocoStudioActionTimelineTestScene() - local scene = TimelineTestScene.create() - scene:runThisTest() - cc.Director:getInstance():replaceScene(scene) -end diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioActionTimelineTest2/CocoStudioActionTimelineTest2.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioActionTimelineTest2/CocoStudioActionTimelineTest2.lua deleted file mode 100644 index 58a69c0eb6..0000000000 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioActionTimelineTest2/CocoStudioActionTimelineTest2.lua +++ /dev/null @@ -1,726 +0,0 @@ - -local itemTagBasic = 1000 -local timelineSceneIdx = 1 - -local winSize = cc.Director:getInstance():getWinSize() -local scheduler = cc.Director:getInstance():getScheduler() - -local TimelineTest2Scene = class("TimelineTest2Scene") -TimelineTest2Scene.__index = TimelineTest2Scene - -function TimelineTest2Scene.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TimelineTest2Scene) - return target -end - -function TimelineTest2Scene:runThisTest() - timelineSceneIdx = 1 - self:addChild(restartTimelineTest2()) -end - -function TimelineTest2Scene.create() - local scene = TimelineTest2Scene.extend(cc.Scene:create()) - local bg = cc.Sprite:create("armature/bg.jpg") - bg:setPosition(VisibleRect:center()) - - local scaleX = VisibleRect:getVisibleRect().width / bg:getContentSize().width - local scaleY = VisibleRect:getVisibleRect().height / bg:getContentSize().height - - bg:setScaleX(scaleX) - bg:setScaleY(scaleY) - - scene:addChild(bg) - return scene -end - -function TimelineTest2Scene.toMainMenuCallback() - -end - -local TimelineTest2Layer = class("TimelineTest2Layer") -TimelineTest2Layer.__index = TimelineTest2Layer -TimelineTest2Layer._backItem = nil -TimelineTest2Layer._restarItem = nil -TimelineTest2Layer._nextItem = nil - -function TimelineTest2Layer:onEnter() - -end - -local _titles = { - "debug", - "change animation", - "AnimationList: walk", - "AnimationList: stand", -} - -function TimelineTest2Layer.title(idx) - return _titles[idx] or ""; -end - -function TimelineTest2Layer.subTitle(idx) - return "" -end - -function TimelineTest2Layer.create() - local layer = TimelineTest2Layer.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -function TimelineTest2Layer.backCallback() - local newScene = TimelineTest2Scene.create() - newScene:addChild(backTimelineTest2()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TimelineTest2Layer.restartCallback() - local newScene = TimelineTest2Scene.create() - newScene:addChild(restartTimelineTest2()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TimelineTest2Layer.nextCallback() - local newScene = TimelineTest2Scene.create() - newScene:addChild(nextTimelineTest2()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TimelineTest2Layer:createMenu() - local menu = cc.Menu:create() - - self._backItem = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) - self._backItem:registerScriptTapHandler(self.backCallback) - menu:addChild(self._backItem,itemTagBasic) - self._restarItem = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) - self._restarItem:registerScriptTapHandler(self.restartCallback) - menu:addChild(self._restarItem,itemTagBasic) - self._nextItem = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) - menu:addChild(self._nextItem,itemTagBasic) - self._nextItem:registerScriptTapHandler(self.nextCallback) - - local size = cc.Director:getInstance():getWinSize() - self._backItem:setPosition(cc.p(size.width / 2 - self._restarItem:getContentSize().width * 2, self._restarItem:getContentSize().height / 2)) - self._restarItem:setPosition(cc.p(size.width / 2, self._restarItem:getContentSize().height / 2)) - self._nextItem:setPosition(cc.p(size.width / 2 + self._restarItem:getContentSize().width * 2, self._restarItem:getContentSize().height / 2)) - - menu:setPosition(cc.p(0, 0)) - - self:addChild(menu) -end - -function TimelineTest2Layer.toExtensionMenu() - ccs.ArmatureDataManager:destroyInstance() - local scene = CocoStudioTestMain() - if scene ~= nil then - cc.Director:getInstance():replaceScene(scene) - end -end - -function TimelineTest2Layer:createToExtensionMenu() - cc.MenuItemFont:setFontName("Arial") - cc.MenuItemFont:setFontSize(24) - local menuItemFont = cc.MenuItemFont:create("Back") - menuItemFont:setPosition(cc.p(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) - menuItemFont:registerScriptTapHandler(TimelineTest2Layer.toExtensionMenu) - - local backMenu = cc.Menu:create() - backMenu:addChild(menuItemFont) - backMenu:setPosition(cc.p(0, 0)) - self:addChild(backMenu,10) -end - -function TimelineTest2Layer:creatTitleAndSubTitle(idx) - print("set title") - local title = cc.Label:createWithTTF(TimelineTest2Layer.title(idx), "fonts/Thonburi.ttf", 18) - title:setColor(cc.c3b(255,0,0)) - self:addChild(title, 1, 10000) - title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30)) - local subTitle = nil - if "" ~= TimelineTest2Layer.subTitle(idx) then - local subTitle = cc.Label:createWithTTF(TimelineTest2Layer.subTitle(idx), "fonts/Thonburi.ttf", 18) - subTitle:setColor(cc.c3b(0,0,0)) - self:addChild(subTitle, 1, 10001) - subTitle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 60) ) - end -end - -local TestActionTimeline = class("TestActionTimeline",TimelineTest2Layer) -TestActionTimeline.__index = TestActionTimeline - -function TestActionTimeline.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestActionTimeline) - return target -end - -function TestActionTimeline:onEnter() - - local node = cc.CSLoader:createNode("ActionTimeline/DemoPlayer_skeleton.csb") - local action = cc.CSLoader:createTimeline("ActionTimeline/DemoPlayer_skeleton.csb") - node:runAction(action) - action:gotoFrameAndPlay(0) - - node:setScale(0.2) - node:setPosition(VisibleRect:center()) - - self:addChild(node) -end - -function TestActionTimeline.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = TimelineTest2Scene.create() - newScene:addChild(restartTimelineTest2()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestActionTimeline.create() - local layer = TestActionTimeline.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local TestChangePlaySection = class("TestChangePlaySection",TimelineTest2Layer) -TestChangePlaySection.__index = TestChangePlaySection - -function TestChangePlaySection.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestChangePlaySection) - return target -end - -function TestChangePlaySection:onEnter() - - local node = cc.CSLoader:createNode("ActionTimeline/DemoPlayer_skeleton.csb") - local action = cc.CSLoader:createTimeline("ActionTimeline/DemoPlayer_skeleton.csb") - node:runAction(action) - action:gotoFrameAndPlay(41) - - - node:setScale(0.2) - node:setPosition(VisibleRect:center()) - - action:addAnimationInfo(ccs.AnimationInfo("stand", 0 , 40)) - action:addAnimationInfo(ccs.AnimationInfo("walk", 41 , 81)) - action:addAnimationInfo(ccs.AnimationInfo("killall", 174, 249)) - - assert(action:IsAnimationInfoExists("stand") == true, "stand animation didn't exist") - action:play("stand", true) - assert(action:getAnimationInfo("stand").endIndex == 40, "endIndex of animationInfo is not 40") - action:removeAnimationInfo("stand") - assert(action:IsAnimationInfoExists("stand") == false, "stand animation has already existed") - - local function onTouchesEnded(touches, event) - if action:getStartFrame() == 0 then - action:gotoFrameAndPlay(41, 81, true) - else - action:gotoFrameAndPlay(0, 40, true) - end - end - - local listener = cc.EventListenerTouchAllAtOnce:create() - listener:registerScriptHandler(onTouchesEnded,cc.Handler.EVENT_TOUCHES_ENDED ) - - local eventDispatcher = self:getEventDispatcher() - eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self) - - self:addChild(node) -end - -function TestChangePlaySection.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = TimelineTest2Scene.create() - newScene:addChild(restartTimelineTest2()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestChangePlaySection.create() - local layer = TestChangePlaySection.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local TestTimelineFrameEvent = class("TestTimelineFrameEvent",TimelineTest2Layer) -TestTimelineFrameEvent.__index = TestTimelineFrameEvent - -function TestTimelineFrameEvent.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestTimelineFrameEvent) - return target -end - -function TestTimelineFrameEvent:onEnter() - - local node = cc.CSLoader:createNode("ActionTimeline/DemoPlayer_skeleton.csb") - local action = cc.CSLoader:createTimeline("ActionTimeline/DemoPlayer_skeleton.csb") - node:runAction(action) - action:gotoFrameAndPlay(0) - - node:setScale(0.2) - node:setPosition(VisibleRect:center()) - self:addChild(node) - - local function onFrameEvent(frame) - if nil == frame then - return - end - - local str = frame:getEvent() - - if str == "changeColor" then - frame:getNode():setColor(cc.c3b(0, 0, 0)) - elseif(str == "endChangeColor") then - frame:getNode():setColor(cc.c3b(255,255,255)) - end - end - - action:setFrameEventCallFunc(onFrameEvent) -end - -function TestTimelineFrameEvent.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = TimelineTest2Scene.create() - newScene:addChild(restartTimelineTest2()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestTimelineFrameEvent.create() - local layer = TestTimelineFrameEvent.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local TestTimelinePerformance = class("TestTimelinePerformance",TimelineTest2Layer) -TestTimelinePerformance.__index = TestTimelinePerformance - -function TestTimelinePerformance.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestTimelinePerformance) - return target -end - -function TestTimelinePerformance:onEnter() - - for i = 1,100 do - local node = cc.CSLoader:createNode("ActionTimeline/DemoPlayer_skeleton.csb") - local action = cc.CSLoader:createTimeline("ActionTimeline/DemoPlayer_skeleton.csb") - node:runAction(action) - action:gotoFrameAndPlay(41) - - node:setScale(0.1) - node:setPosition((i - 1) * 2, 100) - self:addChild(node) - end -end - -function TestTimelinePerformance.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = TimelineTest2Scene.create() - newScene:addChild(restartTimelineTest2()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestTimelinePerformance.create() - local layer = TestTimelinePerformance.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -------------------------------------------- ----TestTimelineAnimationList -------------------------------------------- -local TestTimelineAnimationList = class("TestTimelineAnimationList",TimelineTest2Layer) -TestTimelineAnimationList.__index = TestTimelineAnimationList - -function TestTimelineAnimationList.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestTimelineAnimationList) - return target -end - -function TestTimelineAnimationList:onEnter() - local node = cc.CSLoader:createNode("ActionTimeline/DemoPlayer_skeleton.csb") - local action = cc.CSLoader:createTimeline("ActionTimeline/DemoPlayer_skeleton.csb") - local standInfo = ccs.AnimationInfo("stand", 0, 40) - local walkInfo = ccs.AnimationInfo("walk", 41, 81) - action:addAnimationInfo(standInfo) - action:addAnimationInfo(walkInfo) - node:runAction(action) - action:play("walk", true) - - node:setScale(0.2) - node:setPosition(150,100) - self:addChild(node) -end - -function TestTimelineAnimationList.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = TimelineTest2Scene.create() - newScene:addChild(restartTimelineTest2()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestTimelineAnimationList.create() - local layer = TestTimelineAnimationList.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - - -------------------------------------------- ----TestTimelineProjectNode -------------------------------------------- -local TestTimelineProjectNode = class("TestTimelineProjectNode",TimelineTest2Layer) -TestTimelineProjectNode.__index = TestTimelineProjectNode - -function TestTimelineProjectNode.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestTimelineProjectNode) - return target -end - -function TestTimelineProjectNode:onEnter() - local node = cc.CSLoader:createNode("ActionTimeline/TestAnimation.csb") - local action = cc.CSLoader:createTimeline("ActionTimeline/TestAnimation.csb") - - node:runAction(action) - action:gotoFrameAndPlay(0, true) - - node:setPosition(-300, -300) - self:addChild(node) -end - -function TestTimelineProjectNode.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = TimelineTest2Scene.create() - newScene:addChild(restartTimelineTest2()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestTimelineProjectNode.create() - local layer = TestTimelineProjectNode.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - - -------------------------------------------- ----TestProjectNodeForSimulator -------------------------------------------- -local TestProjectNodeForSimulator = class("TestProjectNodeForSimulator",TimelineTest2Layer) -TestProjectNodeForSimulator.__index = TestProjectNodeForSimulator - -function TestProjectNodeForSimulator.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestProjectNodeForSimulator) - return target -end - -function TestProjectNodeForSimulator:onEnter() - local node = cc.CSLoader:getInstance():createNodeWithFlatBuffersForSimulator("ActionTimeline/TestAnimation.csd") - local action = ccs.ActionTimelineCache:getInstance():createActionWithFlatBuffersForSimulator("ActionTimeline/TestAnimation.csd") - - node:runAction(action) - action:gotoFrameAndPlay(0, true) - - node:setPosition(-300, -300) - self:addChild(node) - - --test for when ProjectNode file lost - local lackProjectNodefileNode = cc.CSLoader:getInstance():createNodeWithFlatBuffersForSimulator("ActionTimeline/TestNullProjectNode.csd") - local lackProjectNodefileAction = ccs.ActionTimelineCache:getInstance():createActionWithFlatBuffersForSimulator("ActionTimeline/TestNullProjectNode.csd") - lackProjectNodefileNode:runAction(lackProjectNodefileAction) - lackProjectNodefileAction:gotoFrameAndPlay(0) - self:addChild(lackProjectNodefileNode) -end - -function TestProjectNodeForSimulator.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = TimelineTest2Scene.create() - newScene:addChild(restartTimelineTest2()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestProjectNodeForSimulator.create() - local layer = TestProjectNodeForSimulator.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -------------------------------------------- ----TestTimelineNodeLoadedCallback -------------------------------------------- -local TestTimelineNodeLoadedCallback = class("TestTimelineNodeLoadedCallback",TimelineTest2Layer) -TestTimelineNodeLoadedCallback.__index = TestTimelineNodeLoadedCallback - -function TestTimelineNodeLoadedCallback.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestTimelineNodeLoadedCallback) - return target -end - -function TestTimelineNodeLoadedCallback:onEnter() - local node = cc.CSLoader:createNode("ActionTimeline/DemoPlayer_skeleton.csb", function(object) - if nil ~= object then - print("object type is ", tolua.type(object)) - print("node name = ",object:getName()) - print("node parent name = ", object:getParent():getName()) - end - end) - local action = cc.CSLoader:createTimeline("ActionTimeline/DemoPlayer_skeleton.csb") - node:runAction(action) - action:gotoFrameAndPlay(0) - - node:setScale(0.2) - node:setPosition(VisibleRect:center()) - - self:addChild(node) -end - -function TestTimelineNodeLoadedCallback.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = TimelineTest2Scene.create() - newScene:addChild(restartTimelineTest2()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestTimelineNodeLoadedCallback.create() - local layer = TestTimelineNodeLoadedCallback.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -------------------------------------------- ----TestActionTimelineEase -------------------------------------------- -local TestActionTimelineEase = class("TestActionTimelineEase",TimelineTest2Layer) -TestActionTimelineEase.__index = TestActionTimelineEase - -function TestActionTimelineEase.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestActionTimelineEase) - return target -end - -function TestActionTimelineEase:onEnter() - local node = cc.CSLoader:createNode("ActionTimeline/ActionTimelineEase.csb") - local action = cc.CSLoader:createTimeline("ActionTimeline/ActionTimelineEase.csb") - node:runAction(action) - action:gotoFrameAndPlay(0) - self:addChild(node) -end - -function TestActionTimelineEase.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = TimelineTest2Scene.create() - newScene:addChild(restartTimelineTest2()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestActionTimelineEase.create() - local layer = TestActionTimelineEase.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(timelineSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local actionlineSceneArr = -{ - TestActionTimeline.create, - TestChangePlaySection.create, - TestTimelineFrameEvent.create, - TestTimelinePerformance.create, - TestTimelineAnimationList.create, - TestTimelineProjectNode.create, - TestProjectNodeForSimulator.create, - TestTimelineNodeLoadedCallback.create, - TestActionTimelineEase.create, -} - -function nextTimelineTest2() - timelineSceneIdx = timelineSceneIdx + 1 - timelineSceneIdx = timelineSceneIdx % table.getn(actionlineSceneArr) - if 0 == timelineSceneIdx then - timelineSceneIdx = table.getn(actionlineSceneArr) - end - return actionlineSceneArr[timelineSceneIdx]() -end - -function backTimelineTest2() - timelineSceneIdx = timelineSceneIdx - 1 - if timelineSceneIdx <= 0 then - timelineSceneIdx = timelineSceneIdx + table.getn(actionlineSceneArr) - end - - return actionlineSceneArr[timelineSceneIdx]() -end - -function restartTimelineTest2() - return actionlineSceneArr[timelineSceneIdx]() -end - -function runCocoStudioActionTimelineTest2Scene() - local scene = TimelineTest2Scene.create() - scene:runThisTest() - cc.Director:getInstance():replaceScene(scene) -end diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua deleted file mode 100644 index 7a60bda075..0000000000 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua +++ /dev/null @@ -1,1265 +0,0 @@ -local itemTagBasic = 1000 -local armaturePerformanceTag = 20000 -local frameEventActionTag = 10000 -local winSize = cc.Director:getInstance():getWinSize() -local scheduler = cc.Director:getInstance():getScheduler() -local ArmatureTestIndex = -{ - TEST_ASYNCHRONOUS_LOADING = 1, - TEST_DIRECT_LOADING = 2, - TEST_COCOSTUDIO_WITH_SKELETON = 3, - TEST_DRAGON_BONES_2_0 = 4, - TEST_PERFORMANCE = 5, - TEST_CHANGE_ZORDER = 6, - TEST_ANIMATION_EVENT = 7, - TEST_FRAME_EVENT = 8, - TEST_PARTICLE_DISPLAY = 9, - TEST_USE_DIFFERENT_PICTURE = 10, - TEST_ANCHORPOINT = 11, - TEST_ARMATURE_NESTING = 12, - TEST_ARMATURE_NESTING_2 = 13, -} -local armatureSceneIdx = ArmatureTestIndex.TEST_ASYNCHRONOUS_LOADING - -local ArmatureTestScene = class("ArmatureTestScene") -ArmatureTestScene.__index = ArmatureTestScene - -function ArmatureTestScene.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, ArmatureTestScene) - return target -end - -function ArmatureTestScene:runThisTest() - armatureSceneIdx = ArmatureTestIndex.TEST_ASYNCHRONOUS_LOADING - self:addChild(restartArmatureTest()) -end - -function ArmatureTestScene.create() - local scene = ArmatureTestScene.extend(cc.Scene:create()) - local bg = cc.Sprite:create("armature/bg.jpg") - bg:setPosition(VisibleRect:center()) - - local scaleX = VisibleRect:getVisibleRect().width / bg:getContentSize().width - local scaleY = VisibleRect:getVisibleRect().height / bg:getContentSize().height - - bg:setScaleX(scaleX) - bg:setScaleY(scaleY) - - scene:addChild(bg) - return scene -end - -function ArmatureTestScene.toMainMenuCallback() - ccs.ArmatureDataManager:purgeArmatureSystem() -end - -local ArmatureTestLayer = class("ArmatureTestLayer") -ArmatureTestLayer.__index = ArmatureTestLayer -ArmatureTestLayer._backItem = nil -ArmatureTestLayer._restarItem = nil -ArmatureTestLayer._nextItem = nil - -function ArmatureTestLayer:onEnter() - -end - -function ArmatureTestLayer.title(idx) - if ArmatureTestIndex.TEST_ASYNCHRONOUS_LOADING == idx then - return "Test Asynchronous Loading" - elseif ArmatureTestIndex.TEST_DIRECT_LOADING == idx then - return "Test Direct Loading" - elseif ArmatureTestIndex.TEST_COCOSTUDIO_WITH_SKELETON == idx then - return "Test Export From CocoStudio With Skeleton Effect" - elseif ArmatureTestIndex.TEST_DRAGON_BONES_2_0 == idx then - return "Test Export From DragonBones version 2.0" - elseif ArmatureTestIndex.TEST_PERFORMANCE == idx then - return "Test Performance" - elseif ArmatureTestIndex.TEST_CHANGE_ZORDER == idx then - return "Test Change ZOrder Of Different Armature" - elseif ArmatureTestIndex.TEST_ANIMATION_EVENT == idx then - return "Test Armature Animation Event" - elseif ArmatureTestIndex.TEST_FRAME_EVENT == idx then - return "Test Frame Event" - elseif ArmatureTestIndex.TEST_PARTICLE_DISPLAY == idx then - return "Test Particle Display" - elseif ArmatureTestIndex.TEST_USE_DIFFERENT_PICTURE == idx then - return "Test One Armature Use Different Picture" - elseif ArmatureTestIndex.TEST_ANCHORPOINT == idx then - return "Test Set AnchorPoint" - elseif ArmatureTestIndex.TEST_ARMATURE_NESTING == idx then - return "Test Armature Nesting" - elseif ArmatureTestIndex.TEST_ARMATURE_NESTING_2 == idx then - return "Test Armature Nesting 2" - end -end - -function ArmatureTestLayer.subTitle(idx) - if ArmatureTestIndex.TEST_ASYNCHRONOUS_LOADING == idx then - return "current percent :" - elseif ArmatureTestIndex.TEST_PERFORMANCE == idx then - return "Current Armature Count : " - elseif ArmatureTestIndex.TEST_PARTICLE_DISPLAY == idx then - return "Touch to change animation" - elseif ArmatureTestIndex.TEST_USE_DIFFERENT_PICTURE == idx then - return "weapon and armature are in different picture" - elseif ArmatureTestIndex.TEST_ARMATURE_NESTING_2 == idx then - return "Move to a mount and press the ChangeMount Button." - else - return "" - end -end - -function ArmatureTestLayer.create() - local layer = ArmatureTestLayer.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - layer:creatTitleAndSubTitle(armatureSceneIdx) - end - - return layer -end - -function ArmatureTestLayer.backCallback() - local newScene = ArmatureTestScene.create() - newScene:addChild(backArmatureTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function ArmatureTestLayer.restartCallback() - local newScene = ArmatureTestScene.create() - newScene:addChild(restartArmatureTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function ArmatureTestLayer.nextCallback() - local newScene = ArmatureTestScene.create() - newScene:addChild(nextArmatureTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function ArmatureTestLayer:createMenu() - local menu = cc.Menu:create() - - self._backItem = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) - self._backItem:registerScriptTapHandler(self.backCallback) - menu:addChild(self._backItem,itemTagBasic) - self._restarItem = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) - self._restarItem:registerScriptTapHandler(self.restartCallback) - menu:addChild(self._restarItem,itemTagBasic) - self._nextItem = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) - menu:addChild(self._nextItem,itemTagBasic) - self._nextItem:registerScriptTapHandler(self.nextCallback) - - local size = cc.Director:getInstance():getWinSize() - self._backItem:setPosition(cc.p(size.width / 2 - self._restarItem:getContentSize().width * 2, self._restarItem:getContentSize().height / 2)) - self._restarItem:setPosition(cc.p(size.width / 2, self._restarItem:getContentSize().height / 2)) - self._nextItem:setPosition(cc.p(size.width / 2 + self._restarItem:getContentSize().width * 2, self._restarItem:getContentSize().height / 2)) - - menu:setPosition(cc.p(0, 0)) - - self:addChild(menu) -end - -function ArmatureTestLayer.toExtensionMenu() - ccs.ArmatureDataManager:destroyInstance() - local scene = CocoStudioTestMain() - if scene ~= nil then - cc.Director:getInstance():replaceScene(scene) - end -end - -function ArmatureTestLayer:createToExtensionMenu() - cc.MenuItemFont:setFontName("Arial") - cc.MenuItemFont:setFontSize(24) - local menuItemFont = cc.MenuItemFont:create("Back") - menuItemFont:setPosition(cc.p(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) - menuItemFont:registerScriptTapHandler(ArmatureTestLayer.toExtensionMenu) - - local backMenu = cc.Menu:create() - backMenu:addChild(menuItemFont) - backMenu:setPosition(cc.p(0, 0)) - self:addChild(backMenu,10) -end - -function ArmatureTestLayer:creatTitleAndSubTitle(idx) - local title = cc.Label:createWithTTF(ArmatureTestLayer.title(idx), s_arialPath, 18) - title:setColor(cc.c3b(0,0,0)) - self:addChild(title, 1, 10000) - title:setAnchorPoint(cc.p(0.5, 0.5)) - title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30)) - local subTitle = nil - if "" ~= ArmatureTestLayer.subTitle(idx) then - local subTitle = cc.Label:createWithTTF(ArmatureTestLayer.subTitle(idx), s_arialPath, 18) - subTitle:setColor(cc.c3b(0,0,0)) - self:addChild(subTitle, 1, 10001) - subTitle:setAnchorPoint(cc.p(0.5, 0.5)) - subTitle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 60) ) - end -end - -local TestAsynchronousLoading = class("TestAsynchronousLoading",ArmatureTestLayer) -TestAsynchronousLoading.__index = TestAsynchronousLoading - -function TestAsynchronousLoading.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestAsynchronousLoading) - return target -end - -function TestAsynchronousLoading:onEnter() - self._backItem:setEnabled(false) - self._restarItem:setEnabled(false) - self._nextItem:setEnabled(false) - - local title = cc.Label:createWithTTF(ArmatureTestLayer.title(1), s_arialPath, 18) - title:setColor(cc.c3b(0,0,0)) - self:addChild(title, 1, 10000) - title:setAnchorPoint(cc.p(0.5, 0.5)) - title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30)) - local subTitle = nil - if "" ~= ArmatureTestLayer.subTitle(1) then - local subInfo = ArmatureTestLayer.subTitle(1) .. 0.0 - local subTitle = cc.Label:createWithTTF(subInfo, s_arialPath, 18) - subTitle:setColor(cc.c3b(0,0,0)) - self:addChild(subTitle, 1, 10001) - subTitle:setAnchorPoint(cc.p(0.5, 0.5)) - subTitle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 60) ) - end - - local function dataLoaded(percent) - local label = self:getChildByTag(10001) - if nil ~= label then - local subInfo = ArmatureTestLayer.subTitle(1) .. (percent * 100) - label:setString(subInfo) - end - if percent >= 1 and nil ~= self._backItem and nil ~= self._restarItem and nil ~= self._nextItem then - self._backItem:setEnabled(true) - self._restarItem:setEnabled(true) - self._nextItem:setEnabled(true) - end - end - - ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/knight.png", "armature/knight.plist", "armature/knight.xml", dataLoaded) - ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/weapon.png", "armature/weapon.plist", "armature/weapon.xml", dataLoaded) - ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/robot.png", "armature/robot.plist", "armature/robot.xml", dataLoaded) - ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/cyborg.png", "armature/cyborg.plist", "armature/cyborg.xml", dataLoaded) - ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/Dragon.png", "armature/Dragon.plist", "armature/Dragon.xml", dataLoaded) - ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/Cowboy.ExportJson", dataLoaded) - ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/hero.ExportJson", dataLoaded) - ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/horse.ExportJson", dataLoaded) - ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/bear.ExportJson", dataLoaded) - ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/HeroAnimation.ExportJson", dataLoaded) - -end - -function TestAsynchronousLoading.restartCallback() - ccs.ArmatureDataManager:destroyInstance() - local newScene = ArmatureTestScene.create() - newScene:addChild(restartArmatureTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function TestAsynchronousLoading.create() - local layer = TestAsynchronousLoading.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local TestDirectLoading = class("TestDirectLoading",ArmatureTestLayer) -TestDirectLoading.__index = TestDirectLoading - -function TestDirectLoading.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestDirectLoading) - return target -end - -function TestDirectLoading:onEnter() - ccs.ArmatureDataManager:getInstance():removeArmatureFileInfo("armature/bear.ExportJson") - ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/bear.ExportJson") - local armature = ccs.Armature:create("bear") - armature:getAnimation():playWithIndex(0) - armature:setPosition(cc.p(VisibleRect:center())) - self:addChild(armature) -end - -function TestDirectLoading.create() - local layer = TestDirectLoading.extend(cc.Layer:create()) - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - - layer:creatTitleAndSubTitle(armatureSceneIdx) - end - return layer -end - - -local TestCSWithSkeleton = class("TestCSWithSkeleton",ArmatureTestLayer) -TestCSWithSkeleton.__index = TestCSWithSkeleton - -function TestCSWithSkeleton.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestCSWithSkeleton) - return target -end - -function TestCSWithSkeleton:onEnter() - local armature = ccs.Armature:create("Cowboy") - armature:getAnimation():playWithIndex(0) - armature:setScale(0.2) - armature:setAnchorPoint(cc.p(0.5, 0.5)) - armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2)) - self:addChild(armature) -end - -function TestCSWithSkeleton.create() - local layer = TestCSWithSkeleton.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - layer:creatTitleAndSubTitle(armatureSceneIdx) - end - - return layer -end - -local TestDragonBones20 = class("TestDragonBones20",ArmatureTestLayer) -TestDragonBones20.__index = TestDragonBones20 - -function TestDragonBones20.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestDragonBones20) - return target -end - -function TestDragonBones20:onEnter() - local armature = ccs.Armature:create("Dragon") - armature:getAnimation():playWithIndex(1) - armature:getAnimation():setSpeedScale(0.4) - armature:setPosition(cc.p(VisibleRect:center().x, VisibleRect:center().y * 0.3)) - armature:setScale(0.6) - self:addChild(armature) -end - -function TestDragonBones20.create() - local layer = TestDragonBones20.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - layer:creatTitleAndSubTitle(armatureSceneIdx) - end - return layer -end - -local TestPerformance = class("TestPerformance",ArmatureTestLayer) -TestPerformance.__index = TestPerformance -TestPerformance._armatureCount = 0 -TestPerformance._frames = 0 -TestPerformance._times = 0 -TestPerformance._lastTimes = 0 -TestPerformance._generated = false - -function TestPerformance.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestPerformance) - return target -end - -function TestPerformance:refreshTitle() - local subTitleInfo = ArmatureTestLayer.subTitle(5) .. self._armatureCount - local label = self:getChildByTag(10001) - label:setString(subTitleInfo) -end - -function TestPerformance:addArmatureToParent(armature) - self:addChild(armature, 0, armaturePerformanceTag + self._armatureCount) -end - -function TestPerformance:removeArmatureFromParent(tag) - self:removeChildByTag(armaturePerformanceTag + self._armatureCount, true) -end - -function TestPerformance:addArmature(num) - for i = 1, num do - self._armatureCount = self._armatureCount + 1 - local armature = ccs.Armature:create("Knight_f/Knight") - armature:getAnimation():playWithIndex(0) - armature:setPosition(50 + self._armatureCount * 2, 150) - armature:setScale(0.6) - self:addArmatureToParent(armature) - end - - self:refreshTitle() -end - -function TestPerformance:onEnter() - - local function onIncrease(sender) - self:addArmature(20) - end - - local function onDecrease(sender) - if self._armatureCount == 0 then - return - end - - for i = 1, 20 do - self:removeArmatureFromParent(armaturePerformanceTag + self._armatureCount) - self._armatureCount = self._armatureCount - 1 - self:refreshTitle() - end - end - - cc.MenuItemFont:setFontSize(65) - local decrease = cc.MenuItemFont:create(" - ") - decrease:setColor(cc.c3b(0,200,20)) - decrease:registerScriptTapHandler(onDecrease) - - local increase = cc.MenuItemFont:create(" + ") - increase:setColor(cc.c3b(0,200,20)) - increase:registerScriptTapHandler(onIncrease) - - local menu = cc.Menu:create(decrease, increase ) - menu:alignItemsHorizontally() - menu:setPosition(cc.p(VisibleRect:getVisibleRect().width/2, VisibleRect:getVisibleRect().height-100)) - self:addChild(menu, 10000) - - self._armatureCount = 0 - self._frames = 0 - self._times = 0 - self._lastTimes = 0 - self._generated = false - - self:addArmature(100) -end - -function TestPerformance.create() - local layer = TestPerformance.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(armatureSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - return layer -end - -local TestPerformanceBatchNode = class("TestPerformanceBatchNode",TestPerformance) -TestPerformanceBatchNode.__index = TestPerformanceBatchNode -TestPerformanceBatchNode._batchNode = nil - -function TestPerformanceBatchNode.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestPerformanceBatchNode) - return target -end - -function TestPerformanceBatchNode:addArmatureToParent(armature) - self._batchNode:addChild(armature, 0, armaturePerformanceTag + self._armatureCount) -end - -function TestPerformanceBatchNode:removeArmatureFromParent(tag) - self._batchNode:removeChildByTag(armaturePerformanceTag + self._armatureCount, true) -end - -function TestPerformanceBatchNode:onEnter() - self._batchNode = ccs.BatchNode:create() - self:addChild(self._batchNode) - - local function onIncrease(sender) - self:addArmature(20) - end - - local function onDecrease(sender) - if self._armatureCount == 0 then - return - end - - for i = 1, 20 do - self:removeArmatureFromParent(armaturePerformanceTag + self._armatureCount) - self._armatureCount = self._armatureCount - 1 - self:refreshTitle() - end - end - - cc.MenuItemFont:setFontSize(65) - local decrease = cc.MenuItemFont:create(" - ") - decrease:setColor(cc.c3b(0,200,20)) - decrease:registerScriptTapHandler(onDecrease) - - local increase = cc.MenuItemFont:create(" + ") - increase:setColor(cc.c3b(0,200,20)) - increase:registerScriptTapHandler(onIncrease) - - local menu = cc.Menu:create(decrease, increase ) - menu:alignItemsHorizontally() - menu:setPosition(cc.p(VisibleRect:getVisibleRect().width/2, VisibleRect:getVisibleRect().height-100)) - self:addChild(menu, 10000) - - self._armatureCount = 0 - self._frames = 0 - self._times = 0 - self._lastTimes = 0 - self._generated = false - - self:addArmature(100) -end - -function TestPerformanceBatchNode.create() - local layer = TestPerformanceBatchNode.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(armatureSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - return layer -end - -local TestChangeZorder = class("TestChangeZorder",ArmatureTestLayer) -TestChangeZorder.__index = TestChangeZorder -TestChangeZorder.currentTag = -1 - -function TestChangeZorder.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestChangeZorder) - return target -end - -function TestChangeZorder:onEnter() - self.currentTag = -1 - - local armature = ccs.Armature:create("Knight_f/Knight") - armature:getAnimation():playWithIndex(0) - armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 100 )) - armature:setScale(0.6) - self.currentTag = self.currentTag + 1 - self:addChild(armature, self.currentTag, self.currentTag) - - armature = ccs.Armature:create("Cowboy") - armature:getAnimation():playWithIndex(0) - armature:setScale(0.24) - armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 100)) - self.currentTag = self.currentTag + 1 - self:addChild(armature, self.currentTag, self.currentTag) - - armature = ccs.Armature:create("Dragon") - armature:getAnimation():playWithIndex(0) - armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 100)) - armature:setScale(0.6) - self.currentTag = self.currentTag + 1 - self:addChild(armature, self.currentTag, self.currentTag) - - local function changeZorder(dt) - local node = self:getChildByTag(self.currentTag) - node:setLocalZOrder(math.random(0,1) * 3) - self.currentTag = (self.currentTag + 1) % 3 - end - - schedule(self,changeZorder, 1) -end - -function TestChangeZorder.create() - local layer = TestChangeZorder.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(armatureSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - return layer -end - ---UNDO callback -local TestAnimationEvent = class("TestAnimationEvent",ArmatureTestLayer) -TestAnimationEvent.__index = TestAnimationEvent - -function TestAnimationEvent.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestAnimationEvent) - return target -end - -function TestAnimationEvent:onEnter() - local armature = ccs.Armature:create("Cowboy") - armature:getAnimation():play("Fire") - armature:setScaleX(-0.24) - armature:setScaleY(0.24) - armature:setPosition(cc.p(VisibleRect:left().x + 50, VisibleRect:left().y)) - - local function callback1() - armature:runAction(cc.ScaleTo:create(0.3, 0.24, 0.24)) - armature:getAnimation():play("FireMax", 10) - end - - local function callback2() - armature:runAction(cc.ScaleTo:create(0.3, -0.24, 0.24)) - armature:getAnimation():play("Fire", 10) - end - - local function animationEvent(armatureBack,movementType,movementID) - local id = movementID - if movementType == ccs.MovementEventType.loopComplete then - if id == "Fire" then - local actionToRight = cc.MoveTo:create(2, cc.p(VisibleRect:right().x - 50, VisibleRect:right().y)) - armatureBack:stopAllActions() - armatureBack:runAction(cc.Sequence:create(actionToRight,cc.CallFunc:create(callback1))) - armatureBack:getAnimation():play("Walk") - elseif id == "FireMax" then - local actionToLeft = cc.MoveTo:create(2, cc.p(VisibleRect:left().x + 50, VisibleRect:left().y)) - armatureBack:stopAllActions() - armatureBack:runAction(cc.Sequence:create(actionToLeft, cc.CallFunc:create(callback2))) - armatureBack:getAnimation():play("Walk") - end - end - end - - armature:getAnimation():setMovementEventCallFunc(animationEvent) - - self:addChild(armature) -end - -function TestAnimationEvent.create() - local layer = TestAnimationEvent.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(armatureSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - return layer -end - -local TestFrameEvent = class("TestFrameEvent",ArmatureTestLayer) -TestFrameEvent.__index = TestFrameEvent - -function TestFrameEvent.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestFrameEvent) - return target -end - -function TestFrameEvent:onEnter() - - local gridNode = cc.NodeGrid:create() - - local armature = ccs.Armature:create("HeroAnimation") - armature:getAnimation():play("attack") - armature:getAnimation():setSpeedScale(0.5) - armature:setPosition(cc.p(VisibleRect:center().x - 50, VisibleRect:center().y -100)) - - local function onFrameEvent( bone,evt,originFrameIndex,currentFrameIndex) - if (not gridNode:getActionByTag(frameEventActionTag)) or (not gridNode:getActionByTag(frameEventActionTag):isDone()) then - gridNode:stopAllActions() - - local action = cc.ShatteredTiles3D:create(0.2, cc.size(16,12), 5, false) - action:setTag(frameEventActionTag) - gridNode:runAction(action) - end - end - - armature:getAnimation():setFrameEventCallFunc(onFrameEvent) - gridNode:addChild(armature) - - self:addChild(gridNode) - - local function checkAction(dt) - if gridNode:getNumberOfRunningActions() == 0 and gridNode:getGrid() ~= nil then - gridNode:setGrid(nil) - end - end - - self:scheduleUpdateWithPriorityLua(checkAction,0) - - local function onNodeEvent(tag) - if "exit" == tag then - self:unscheduleUpdate() - end - end -end - -function TestFrameEvent.create() - local layer = TestFrameEvent.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(armatureSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - return layer -end - -local TestParticleDisplay = class("TestParticleDisplay",ArmatureTestLayer) -TestParticleDisplay.__index = TestParticleDisplay -TestParticleDisplay.animationID = 0 -TestParticleDisplay.armature = nil - -function TestParticleDisplay.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestParticleDisplay) - return target -end - -function TestParticleDisplay:onEnter() - self.animationID = 0 - - self.armature = ccs.Armature:create("robot") - self.armature:getAnimation():playWithIndex(0) - self.armature:setPosition(VisibleRect:center()) - self.armature:setScale(0.48) - self:addChild(self.armature) - - local p1 = cc.ParticleSystemQuad:create("Particles/SmallSun.plist") - local p2 = cc.ParticleSystemQuad:create("Particles/SmallSun.plist") - - local bone = ccs.Bone:create("p1") - bone:addDisplay(p1, 0) - bone:changeDisplayWithIndex(0, true) - bone:setIgnoreMovementBoneData(true) - bone:setLocalZOrder(100) - bone:setScale(1.2) - self.armature:addBone(bone, "bady-a3") - - bone = ccs.Bone:create("p2") - bone:addDisplay(p2, 0) - bone:changeDisplayWithIndex(0, true) - bone:setIgnoreMovementBoneData(true) - bone:setLocalZOrder(100) - bone:setScale(1.2) - self.armature:addBone(bone, "bady-a30") - - -- handling touch events - local function onTouchEnded(touches, event) - self.animationID = (self.animationID + 1) % self.armature:getAnimation():getMovementCount() - self.armature:getAnimation():playWithIndex(self.animationID) - end - - local listener = cc.EventListenerTouchAllAtOnce:create() - listener:registerScriptHandler(onTouchEnded,cc.Handler.EVENT_TOUCHES_ENDED ) - - local eventDispatcher = self:getEventDispatcher() - eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self) -end - -function TestParticleDisplay.create() - local layer = TestParticleDisplay.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(armatureSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local TestUseMutiplePicture = class("TestUseMutiplePicture",ArmatureTestLayer) -TestUseMutiplePicture.__index = TestUseMutiplePicture -TestUseMutiplePicture.displayIndex = 0 -TestUseMutiplePicture.armature = nil - -function TestUseMutiplePicture.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestUseMutiplePicture) - return target -end - -function TestUseMutiplePicture:onEnter() - self.displayIndex = 1 - - self.armature = ccs.Armature:create("Knight_f/Knight") - self.armature:getAnimation():playWithIndex(0) - self.armature:setPosition(cc.p(VisibleRect:left().x + 70, VisibleRect:left().y)) - self.armature:setScale(1.2) - self:addChild(self.armature) - - local weapon = - { - "weapon_f-sword.png", - "weapon_f-sword2.png", - "weapon_f-sword3.png", - "weapon_f-sword4.png", - "weapon_f-sword5.png", - "weapon_f-knife.png", - "weapon_f-hammer.png", - } - - local i = 1 - for i = 1,table.getn(weapon) do - local skin = ccs.Skin:createWithSpriteFrameName(weapon[i]) - self.armature:getBone("weapon"):addDisplay(skin, i - 1) - end - - -- handling touch events - local function onTouchEnded(touches, event) - self.displayIndex = (self.displayIndex + 1) % (table.getn(weapon) - 1) - self.armature:getBone("weapon"):changeDisplayWithIndex(self.displayIndex, true) - end - - local listener = cc.EventListenerTouchAllAtOnce:create() - listener:registerScriptHandler(onTouchEnded,cc.Handler.EVENT_TOUCHES_ENDED ) - - local eventDispatcher = self:getEventDispatcher() - eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self) -end - -function TestUseMutiplePicture.create() - local layer = TestUseMutiplePicture.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(armatureSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local TestAnchorPoint = class("TestAnchorPoint",ArmatureTestLayer) -TestAnchorPoint.__index = TestAnchorPoint - -function TestAnchorPoint.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestAnchorPoint) - return target -end - -function TestAnchorPoint:onEnter() - local i = 1 - for i = 1 , 5 do - local armature = ccs.Armature:create("Cowboy") - armature:getAnimation():playWithIndex(0) - armature:setPosition(VisibleRect:center()) - armature:setScale(0.2) - self:addChild(armature, 0, i - 1) - end - - self:getChildByTag(0):setAnchorPoint(cc.p(0,0)) - self:getChildByTag(1):setAnchorPoint(cc.p(0,1)) - self:getChildByTag(2):setAnchorPoint(cc.p(1,0)) - self:getChildByTag(3):setAnchorPoint(cc.p(1,1)) - self:getChildByTag(4):setAnchorPoint(cc.p(0.5,0.5)) -end - -function TestAnchorPoint.create() - local layer = TestAnchorPoint.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(armatureSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local TestArmatureNesting = class("TestArmatureNesting",ArmatureTestLayer) -TestArmatureNesting.__index = TestArmatureNesting -TestArmatureNesting.weaponIndex = 0 -TestArmatureNesting.armature = nil - -function TestArmatureNesting.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestArmatureNesting) - return target -end - -function TestArmatureNesting:onEnter() - self.weaponIndex = 0 - - self.armature = ccs.Armature:create("cyborg") - self.armature:getAnimation():playWithIndex(1) - self.armature:setPosition(VisibleRect:center()) - self.armature:setScale(1.2) - self.armature:getAnimation():setSpeedScale(0.4) - self:addChild(self.armature) - - -- handling touch events - local function onTouchEnded(touches, event) - self.weaponIndex = (self.weaponIndex + 1) % 4 - self.armature:getBone("armInside"):getChildArmature():getAnimation():playWithIndex(self.weaponIndex) - self.armature:getBone("armOutside"):getChildArmature():getAnimation():playWithIndex(self.weaponIndex) - end - - local listener = cc.EventListenerTouchAllAtOnce:create() - listener:registerScriptHandler(onTouchEnded,cc.Handler.EVENT_TOUCHES_ENDED ) - - local eventDispatcher = self:getEventDispatcher() - eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self) -end - -function TestArmatureNesting.create() - local layer = TestArmatureNesting.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(armatureSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local Hero = class("Hero") -Hero.__index = Hero -Hero._mount = nil -Hero._layer = nil - -function Hero.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, Hero) - return target -end - -function Hero:changeMount(armature) - if nil == armature then - --note - self:retain() - - self:playWithIndex(0) - self._mount:getBone("hero"):removeDisplay(0) - self._mount:stopAllActions() - self:setPosition(self._mount:getPosition()) - self._layer:addChild(self) - self:release() - self._mount = armature - else - self._mount = armature - self:retain() - self:removeFromParent(false) - local bone = armature:getBone("hero") - bone:addDisplay(self, 0) - bone:changeDisplayWithIndex(0, true) - bone:setIgnoreMovementBoneData(true) - self:setPosition(cc.p(0,0)) - self:playWithIndex(1) - self:setScale(1) - self:release() - end -end - -function Hero:playWithIndex(index) - self:getAnimation():playWithIndex(index) - if nil ~= self._mount then - self._mount:getAnimation():playWithIndex(index) - end -end - -function Hero.create(name) - local hero = Hero.extend(ccs.Armature:create(name)) - return hero -end - - - -local TestArmatureNesting2 = class("TestArmatureNesting",ArmatureTestLayer) -TestArmatureNesting2.__index = TestArmatureNesting2 -TestArmatureNesting2._hero = nil -TestArmatureNesting2._horse = nil -TestArmatureNesting2._horse2 = nil -TestArmatureNesting2._bear = nil -TestArmatureNesting2._touchedMenu = nil - -function TestArmatureNesting2.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestArmatureNesting2) - return target -end - -function TestArmatureNesting2:onEnter() - -- handling touch events - local function onTouchEnded(touches, event) - local location = touches[1]:getLocation() - local armature = self._hero._mount and self._hero._mount or self._hero - if location.x < armature:getPositionX() then - armature:setScaleX(-1) - else - armature:setScaleX(1) - end - - local move = cc.MoveTo:create(2, location) - armature:stopAllActions() - armature:runAction(cc.Sequence:create(move)) - end - - local listener = cc.EventListenerTouchAllAtOnce:create() - listener:registerScriptHandler(onTouchEnded,cc.Handler.EVENT_TOUCHES_ENDED ) - - local eventDispatcher = self:getEventDispatcher() - eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self) - - local function changeMountCallback(sender) - self._hero:stopAllActions() - - if nil ~= self._hero._mount then - self._hero:changeMount(nil) - else - if cc.pGetDistance(cc.p(self._hero:getPosition()),cc.p(self._horse:getPosition())) < 20 then - self._hero:changeMount(self._horse) - elseif cc.pGetDistance(cc.p(self._hero:getPosition()),cc.p(self._horse2:getPosition())) < 20 then - self._hero:changeMount(self._horse2) - elseif cc.pGetDistance(cc.p(self._hero:getPosition()),cc.p(self._bear:getPosition())) < 30 then - self._hero:changeMount(self._bear) - end - end - end - - self._touchedMenu = false - local label = cc.Label:createWithTTF("Change Mount", s_arialPath, 20) - label:setAnchorPoint(cc.p(0.5, 0.5)) - local menuItem = cc.MenuItemLabel:create(label) - menuItem:registerScriptTapHandler(changeMountCallback) - local menu = cc.Menu:create(menuItem) - menu:setPosition(cc.p(0,0)) - menuItem:setPosition( cc.p( VisibleRect:right().x - 67, VisibleRect:bottom().y + 50) ) - self:addChild(menu, 2) - - self._hero = Hero.create("hero") - self._hero._layer = self - self._hero:playWithIndex(0) - self._hero:setPosition(cc.p(VisibleRect:left().x + 20, VisibleRect:left().y)) - self:addChild(self._hero) - - self._horse = self:createMount("horse", VisibleRect:center()) - - self._horse2 = self:createMount("horse", cc.p(120, 200)) - self._horse2:setOpacity(200) - - self._bear = self:createMount("bear", cc.p(300,70)) -end - -function TestArmatureNesting2:createMount(name,pt) - local armature = ccs.Armature:create(name) - armature:getAnimation():playWithIndex(0) - armature:setPosition(pt) - self:addChild(armature) - return armature -end - -function TestArmatureNesting2.create() - local layer = TestArmatureNesting2.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:creatTitleAndSubTitle(armatureSceneIdx) - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - - -local armatureSceneArr = -{ - TestAsynchronousLoading.create, - TestDirectLoading.create, - TestCSWithSkeleton.create, - TestDragonBones20.create, - TestPerformance.create, - --TestPerformanceBatchNode.create, - TestChangeZorder.create, - TestAnimationEvent.create, - TestFrameEvent.create, - TestParticleDisplay.create, - TestUseMutiplePicture.create, - TestAnchorPoint.create, - TestArmatureNesting.create, - TestArmatureNesting2.create, -} - -function nextArmatureTest() - armatureSceneIdx = armatureSceneIdx + 1 - armatureSceneIdx = armatureSceneIdx % table.getn(armatureSceneArr) - if 0 == armatureSceneIdx then - armatureSceneIdx = table.getn(armatureSceneArr) - end - return armatureSceneArr[armatureSceneIdx]() -end - -function backArmatureTest() - armatureSceneIdx = armatureSceneIdx - 1 - if armatureSceneIdx <= 0 then - armatureSceneIdx = armatureSceneIdx + table.getn(armatureSceneArr) - end - - return armatureSceneArr[armatureSceneIdx]() -end - -function restartArmatureTest() - return armatureSceneArr[armatureSceneIdx]() -end - -local function addFileInfo() - -end - -function runArmatureTestScene() - local scene = ArmatureTestScene.create() - scene:runThisTest() - cc.Director:getInstance():replaceScene(scene) -end diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua deleted file mode 100644 index 86f54144b6..0000000000 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua +++ /dev/null @@ -1,3165 +0,0 @@ -local guiSceneManager = {} -guiSceneManager.currentUISceneIdx = 1 -local font_TextName = "fonts/Marker Felt.ttf" - -local UIScene = class("UIScene") -UIScene.__index = UIScene -UIScene._uiLayer= nil -UIScene._widget = nil -UIScene._sceneTitle = nil - -function UIScene.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIScene) - return target -end - -function UIScene:init() - self._uiLayer = cc.Layer:create() - self:addChild(self._uiLayer) - - self._widget = ccs.GUIReader:getInstance():widgetFromJsonFile("cocosui/UITest/UITest.json") - self._uiLayer:addChild(self._widget) - - local root = self._uiLayer:getChildByTag(81) - - self._sceneTitle = root:getChildByName("UItest") - - local function previousCallback(sender, eventType) - if eventType == ccui.TouchEventType.ended then - cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) - end - end - - local left_button = root:getChildByName("left_Button") - left_button:addTouchEventListener(previousCallback) - - local function restartCallback(sender, eventType) - if eventType == ccui.TouchEventType.ended then - cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) - end - end - - local middle_button = root:getChildByName("middle_Button") - middle_button:addTouchEventListener(restartCallback) - - local function nextCallback(sender, eventType) - if eventType == ccui.TouchEventType.ended then - cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) - end - end - - local right_button = root:getChildByName("right_Button") - right_button:addTouchEventListener(nextCallback) - - local function menuCloseCallback( sender,eventType) - if eventType == ccui.TouchEventType.ended then - local scene = CocoStudioTestMain() - if scene ~= nil then - cc.Director:getInstance():replaceScene(scene) - end - end - end - - local backMenuLabel = ccui.Text:create() - backMenuLabel:setString("Back") - backMenuLabel:setFontSize(20) - backMenuLabel:setTouchScaleChangeEnabled(true) - backMenuLabel:setPosition(cc.p(430,30)) - backMenuLabel:setTouchEnabled(true) - backMenuLabel:addTouchEventListener(menuCloseCallback) - self._uiLayer:addChild(backMenuLabel) - -end - -function UIScene.create() - local scene = cc.Scene:create() - local layer = UIScene.extend(cc.Layer:create()) - layer:init() - scene:addChild(layer) - return scene -end - -local cocoStudioGuiArray = {} - -local dsl_env = { - create = function(classname, superclass) - local newclass = class(classname, superclass) - newclass._displayValueLabel = nil - - function newclass.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, newclass) - return target - end - - function newclass:initLabel() - self:init() - local widgetSize = self._widget:getContentSize() - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString(classname) - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getContentSize().height * 1.8)) - self._uiLayer:addChild(self._displayValueLabel) - end - - function newclass.create() - local scene = cc.Scene:create() - local layer = newclass.extend(cc.Layer:create()) - layer:initLabel() - layer:initExtend() - scene:addChild(layer) - return scene - end - - table.insert(cocoStudioGuiArray, - { - title = classname, - func = function() - return newclass.create() - end - } - ) - return newclass - end, -} - -local function add_new_testcase(fn) - setfenv(fn, setmetatable(dsl_env, - { - __index = function(self, funName) - return _G[funName] - end - })) - - return fn() -end - -add_new_testcase(function() - local UIButtonTest = create("UIButtonTest", UIScene) - - function UIButtonTest:initExtend() - - local widgetSize = self._widget:getContentSize() - self._displayValueLabel:setString("No Event") - - local alert = ccui.Text:create() - alert:setString("Button") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function touchEvent(sender,eventType) - if eventType == ccui.TouchEventType.began then - self._displayValueLabel:setString("Touch Down") - elseif eventType == ccui.TouchEventType.moved then - self._displayValueLabel:setString("Touch Move") - elseif eventType == ccui.TouchEventType.ended then - self._displayValueLabel:setString("Touch Up") - elseif eventType == ccui.TouchEventType.canceled then - self._displayValueLabel:setString("Touch Cancelled") - end - end - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - button:addTouchEventListener(touchEvent) - self._uiLayer:addChild(button) - end - -end) - -add_new_testcase(function() - local UIButtonScale9Test = create("UIButtonScale9Test", UIScene) - - function UIButtonScale9Test:initExtend() - local widgetSize = self._widget:getContentSize() - self._displayValueLabel:setString("No Event") - - local alert = ccui.Text:create() - alert:setString("Button scale9 render") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function touchEvent(sender,eventType) - if eventType == ccui.TouchEventType.began then - self._displayValueLabel:setString("Touch Down") - elseif eventType == ccui.TouchEventType.moved then - self._displayValueLabel:setString("Touch Move") - elseif eventType == ccui.TouchEventType.ended then - self._displayValueLabel:setString("Touch Up") - elseif eventType == ccui.TouchEventType.canceled then - self._displayValueLabel:setString("Touch Cancelled") - end - end - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:setScale9Enabled(true) - button:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - button:setContentSize(cc.size(150, button:getVirtualRendererSize().height * 1.5)) - button:addTouchEventListener(touchEvent) - self._uiLayer:addChild(button) - end - -end) - -add_new_testcase(function() - local UIButtonPressedActionTest = create("UIButtonPressedActionTest",UIScene) - function UIButtonPressedActionTest:initExtend() - local widgetSize = self._widget:getContentSize() - self._displayValueLabel:setString("No Event") - - local alert = ccui.Text:create() - alert:setString("Button Pressed Action") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function touchEvent(sender,eventType) - if eventType == ccui.TouchEventType.began then - self._displayValueLabel:setString("Touch Down") - elseif eventType == ccui.TouchEventType.moved then - self._displayValueLabel:setString("Touch Move") - elseif eventType == ccui.TouchEventType.ended then - self._displayValueLabel:setString("Touch Up") - elseif eventType == ccui.TouchEventType.canceled then - self._displayValueLabel:setString("Touch Cancelled") - end - end - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:setPressedActionEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - button:addTouchEventListener(touchEvent) - self._uiLayer:addChild(button) - end -end) - -add_new_testcase(function() - local UITextButtonTest = create("UITextButtonTest",UIScene) - - function UITextButtonTest:initExtend() - local widgetSize = self._widget:getContentSize() - self._displayValueLabel:setString("No Event") - - local alert = ccui.Text:create() - alert:setString("TextButton") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function touchEvent(sender,eventType) - if eventType == ccui.TouchEventType.began then - self._displayValueLabel:setString("Touch Down") - elseif eventType == ccui.TouchEventType.moved then - self._displayValueLabel:setString("Touch Move") - elseif eventType == ccui.TouchEventType.ended then - self._displayValueLabel:setString("Touch Up") - elseif eventType == ccui.TouchEventType.canceled then - self._displayValueLabel:setString("Touch Cancelled") - end - end - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - textButton:addTouchEventListener(touchEvent) - self._uiLayer:addChild(textButton) - end -end) - -add_new_testcase(function() - local UITextButtonScale9Test = create("UITextButtonScale9Test",UIScene) - - function UITextButtonScale9Test:initExtend() - local widgetSize = self._widget:getContentSize() - self._displayValueLabel:setString("No Event") - - local alert = ccui.Text:create() - alert:setString("TextButton scale9 render") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function touchEvent(sender,eventType) - if eventType == ccui.TouchEventType.began then - self._displayValueLabel:setString("Touch Down") - elseif eventType == ccui.TouchEventType.moved then - self._displayValueLabel:setString("Touch Move") - elseif eventType == ccui.TouchEventType.ended then - self._displayValueLabel:setString("Touch Up") - elseif eventType == ccui.TouchEventType.canceled then - self._displayValueLabel:setString("Touch Cancelled") - end - end - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:setScale9Enabled(true) - textButton:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - textButton:setContentSize(cc.size(180, textButton:getVirtualRendererSize().height * 1.5)) - textButton:setTitleText("Text Button scale9 render") - textButton:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - textButton:addTouchEventListener(touchEvent) - self._uiLayer:addChild(textButton) - end - -end) - -add_new_testcase(function() - local UICheckBoxTest = create("UICheckBoxTest",UIScene) - - function UICheckBoxTest:initExtend() - local widgetSize = self._widget:getContentSize() - self._displayValueLabel:setString("No Event") - - local alert = ccui.Text:create() - alert:setString("CheckBox") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function selectedEvent(sender,eventType) - if eventType == ccui.CheckBoxEventType.selected then - self._displayValueLabel:setString("Selected") - elseif eventType == ccui.CheckBoxEventType.unselected then - self._displayValueLabel:setString("Unselected") - end - end - - local checkBox = ccui.CheckBox:create() - checkBox:setTouchEnabled(true) - checkBox:setSelectedState(true) - checkBox:loadTextures("cocosui/check_box_normal.png", - "cocosui/check_box_normal_press.png", - "cocosui/check_box_active.png", - "cocosui/check_box_normal_disable.png", - "cocosui/check_box_active_disable.png") - checkBox:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - - checkBox:addEventListener(selectedEvent) - - self._uiLayer:addChild(checkBox) - end - -end) - -add_new_testcase(function() - local UIRadioBoxTest = create("UIRadioBoxTest",UIScene) - - function UIRadioBoxTest:initExtend() - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("No selection is disallowed.") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + 70)) - self._uiLayer:addChild(alert) - - local radioButtonGroup = ccui.RadioButtonGroup:create() - radioButtonGroup:addEventListener(function(radioButton, index, type) - print("RadioButton" .. index .. "Clicked") - end) - self._uiLayer:addChild(radioButtonGroup) - - local NUMBER_OF_BUTTONS = 5 - local BUTTON_WIDTH = 30 - local startPosX = widgetSize.width / 2.0 - ((NUMBER_OF_BUTTONS - 1) / 1.0) * BUTTON_WIDTH - for i = 0 , NUMBER_OF_BUTTONS-1 do - local radioButton = ccui.RadioButton:create("cocosui/radio_button_off.png", "cocosui/radio_button_on.png") - local posX = startPosX + BUTTON_WIDTH * i - radioButton:setPosition(cc.p(posX, widgetSize.height / 2.0 + 10)) - radioButton:setName("button"..i) - radioButtonGroup:addRadioButton(radioButton) - radioButton:addEventListener(function(radioButton, type) - if type == ccui.RadioButtonEventType.selected then - print("name: = " .. radioButton:getName() .. " selected") - elseif type == ccui.RadioButtonEventType.unselected then - print("name: = " .. radioButton:getName() .. " unselected") - end - end) - self._uiLayer:addChild(radioButton) - end - - local function buttonClickCallback(sender) - local name = (tolua.cast(sender, "ccui.Button")):getTitleText() - if name == "Add" then - local pos = cc.p(0,0) - if radioButtonGroup:getNumberOfRadioButtons() > 0 then - local lastRadioButton = radioButtonGroup:getRadioButtonByIndex(radioButtonGroup:getNumberOfRadioButtons() - 1) - pos.x, pos.y = lastRadioButton:getPosition() - else - pos.x = startPosX - BUTTON_WIDTH - pos.y = self._widget:getContentSize().height / 2. + 10 - end - local tempButton = ccui.RadioButton:create("cocosui/radio_button_off.png", "cocosui/radio_button_on.png") - pos.x = pos.x + BUTTON_WIDTH - tempButton:setPosition(pos) - radioButtonGroup:addRadioButton(tempButton) - self._uiLayer:addChild(tempButton) - elseif name == "Delete" then - if radioButtonGroup:getNumberOfRadioButtons() > 0 then - local radioButton = radioButtonGroup:getRadioButtonByIndex(radioButtonGroup:getNumberOfRadioButtons()-1) - radioButtonGroup:removeRadioButton(radioButton) - self._uiLayer:removeChild(radioButton) - end - elseif name == "Toggle" then - radioButtonGroup:setAllowedNoSelection(not radioButtonGroup:isAllowedNoSelection()) - alert:setString(radioButtonGroup:isAllowedNoSelection() and "No selection is allowed" or "No selection is disallowed") - end - end - - local hbox = ccui.HBox:create() - hbox:setPosition(cc.p(10, widgetSize.height/2-65)) - self._uiLayer:addChild(hbox) - - local addButton = ccui.Button:create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png") - addButton:setTitleText("Add") - addButton:setScale(0.7) - addButton:addClickEventListener(buttonClickCallback) - hbox:addChild(addButton) - - local deleteButton = addButton:clone() - deleteButton:setTitleText("Delete") - hbox:addChild(deleteButton) - - local toggleButton = addButton:clone() - toggleButton:setTitleText("Toggle") - hbox:addChild(toggleButton) - - end - -end) - -add_new_testcase(function() - local UISliderTest = create("UISliderTest",UIScene) - - function UISliderTest:initExtend() - local widgetSize = self._widget:getContentSize() - self._displayValueLabel:setString("Move the slider thumb") - - local alert = ccui.Text:create() - alert:setString("Slider") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function percentChangedEvent(sender,eventType) - print(eventType) - if eventType == ccui.SliderEventType.percentChanged then - local slider = sender - local percent = "Percent " .. (slider:getPercent() / slider:getMaxPercent() * 100) - self._displayValueLabel:setString(percent) - elseif eventType == ccui.SliderEventType.slideBallUp then - self._displayValueLabel:setString("Slide Ball Up") - elseif eventType == ccui.SliderEventType.slideBallDown then - self._displayValueLabel:setString("Slide Ball Down") - elseif eventType == ccui.SliderEventType.slideBallCancel then - self._displayValueLabel:setString("Slide Ball Cancel") - end - end - - local slider = ccui.Slider:create() - slider:setTouchEnabled(true) - slider:loadBarTexture("cocosui/sliderTrack.png") - slider:loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "") - slider:loadProgressBarTexture("cocosui/sliderProgress.png") - slider:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - slider:setMaxPercent(10000) - slider:addEventListener(percentChangedEvent) - - self._uiLayer:addChild(slider) - end - -end) - -add_new_testcase(function() - local UISliderScale9Test = create("UISliderScale9Test",UIScene) - - function UISliderScale9Test:initExtend() - local widgetSize = self._widget:getContentSize() - self._displayValueLabel:setString("Move the slider thumb") - - local alert = ccui.Text:create() - alert:setString("Slider scale9 render") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function percentChangedEvent(sender,eventType) - if eventType == ccui.SliderEventType.percentChanged then - local slider = sender - local percent = "Percent " .. slider:getPercent() - self._displayValueLabel:setString(percent) - end - end - - local slider = ccui.Slider:create() - slider:setTouchEnabled(true) - slider:loadBarTexture("cocosui/sliderTrack2.png") - slider:loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "") - slider:loadProgressBarTexture("cocosui/slider_bar_active_9patch.png") - slider:setScale9Enabled(true) - slider:setCapInsets(cc.rect(0, 0, 0, 0)) - slider:setContentSize(cc.size(250, 10)) - slider:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - slider:addEventListener(percentChangedEvent) - - self._uiLayer:addChild(slider) - end - -end) - -add_new_testcase(function() - local UIImageViewTest = create("UIImageViewTest",UIScene) - function UIImageViewTest:initExtend() - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("ImageView") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local imageView = ccui.ImageView:create() - imageView:loadTexture("cocosui/ccicon.png") - imageView:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + imageView:getContentSize().height / 4.0)) - self._uiLayer:addChild(imageView) - end -end) - -add_new_testcase(function () - local UIImageViewScale9Test = create("UIImageViewScale9Test",UIScene) - function UIImageViewScale9Test:initExtend() - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("ImageView scale9 render") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local imageView = ccui.ImageView:create() - imageView:setScale9Enabled(true) - imageView:loadTexture("cocosui/buttonHighlighted.png") - imageView:setContentSize(cc.size(200, 85)) - imageView:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + imageView:getContentSize().height / 4.0)) - self._uiLayer:addChild(imageView) - end -end) - -add_new_testcase(function () - local UILoadingBarLeftTest = create("UILoadingBarLeftTest",UIScene) - - function UILoadingBarLeftTest:initExtend() - self._count = 0 - - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("LoadingBar") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local loadingBar = ccui.LoadingBar:create() - loadingBar:setTag(0) - loadingBar:setName("LoadingBar") - loadingBar:loadTexture("cocosui/sliderProgress.png") - loadingBar:setPercent(0) - - loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getContentSize().height / 4.0)) - self._uiLayer:addChild(loadingBar) - - local function update() - self._count = self._count + 1 - if self._count > 100 then - self._count = 0 - end - - if self._uiLayer ~= nil then - loadingBar:setPercent(self._count) - end - end - - self:scheduleUpdateWithPriorityLua(update, 0) - - local function onNodeEvent(tag) - if tag == "exit" then - self:unscheduleUpdate() - end - end - - self:registerScriptHandler(onNodeEvent) - - end - -end) - -add_new_testcase(function () - local UILoadingBarRightTest = create("UILoadingBarRightTest",UIScene) - - function UILoadingBarRightTest:initExtend() - self._count = 0; - - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("LoadingBar") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local loadingBar = ccui.LoadingBar:create() - loadingBar:setTag(0) - loadingBar:setName("LoadingBar") - loadingBar:loadTexture("cocosui/sliderProgress.png") - loadingBar:setDirection(ccui.LoadingBarDirection.RIGHT) - loadingBar:setPercent(0) - - loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getContentSize().height / 4.0)) - self._uiLayer:addChild(loadingBar) - - local function update() - self._count = self._count + 1 - if self._count > 100 then - self._count = 0 - end - - if self._uiLayer ~= nil then - loadingBar:setPercent(self._count) - end - end - - self:scheduleUpdateWithPriorityLua(update, 0) - - local function onNodeEvent(tag) - if tag == "exit" then - self:unscheduleUpdate() - end - end - - self:registerScriptHandler(onNodeEvent) - - end - -end) - -add_new_testcase(function () - local UILoadingBarLeftScale9Test = create("UILoadingBarLeftScale9Test",UIScene) - function UILoadingBarLeftScale9Test:initExtend() - self._count = 0 - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("LoadingBar Scale9 Render") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local loadingBar = ccui.LoadingBar:create() - loadingBar:setTag(0) - loadingBar:setName("LoadingBar") - loadingBar:loadTexture("cocosui/slider_bar_active_9patch.png") - loadingBar:setScale9Enabled(true) - loadingBar:setCapInsets(cc.rect(0, 0, 0, 0)) - loadingBar:setContentSize(cc.size(300, 30)) - loadingBar:setPercent(0) - - loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getContentSize().height / 4.0)) - self._uiLayer:addChild(loadingBar) - - local function update() - self._count = self._count + 1 - if self._count > 100 then - self._count = 0 - end - - if self._uiLayer ~= nil then - loadingBar:setPercent(self._count) - end - end - - self:scheduleUpdateWithPriorityLua(update, 0) - - local function onNodeEvent(tag) - if tag == "exit" then - self:unscheduleUpdate() - end - end - - self:registerScriptHandler(onNodeEvent) - - end -end) - -add_new_testcase(function () - local UILoadingBarRightScale9Test = create("UILoadingBarRightScale9Test",UIScene) - - function UILoadingBarRightScale9Test:initExtend() - self._count = 0 - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("LoadingBar Scale9 Render") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local loadingBar = ccui.LoadingBar:create() - loadingBar:setTag(0) - loadingBar:setName("LoadingBar") - loadingBar:loadTexture("cocosui/slider_bar_active_9patch.png") - loadingBar:setScale9Enabled(true) - loadingBar:setCapInsets(cc.rect(0, 0, 0, 0)) - loadingBar:setContentSize(cc.size(300, 30)) - loadingBar:setDirection(ccui.LoadingBarDirection.RIGHT) - loadingBar:setPercent(0) - - loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getContentSize().height / 4.0)) - self._uiLayer:addChild(loadingBar) - - local function update() - self._count = self._count + 1 - if self._count > 100 then - self._count = 0 - end - - if self._uiLayer ~= nil then - loadingBar:setPercent(self._count) - end - end - - self:scheduleUpdateWithPriorityLua(update, 0) - - local function onNodeEvent(tag) - if tag == "exit" then - self:unscheduleUpdate() - end - end - - self:registerScriptHandler(onNodeEvent) - - end -end) - -add_new_testcase(function () - local UILabelAtlasTest = create("UILabelAtlasTest",UIScene) - - function UILabelAtlasTest:initExtend() - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("LabelAtlas") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - - local labelAtlas = ccui.TextAtlas:create() - if cc.Director:getInstance():getWinSizeInPixels().height > 320 then - labelAtlas:setProperty("1234567890", "cocosui/labelatlas.png", 34, 44, "0") - else - labelAtlas:setProperty("1234567890", "cocosui/labelatlas.png", 17, 22, "0") - end - - labelAtlas:setPosition(cc.p((widgetSize.width) / 2, widgetSize.height / 2.0)) - - self._uiLayer:addChild(labelAtlas) - end - -end) - -add_new_testcase(function () - local UILabelBMFontTest = create("UILabelBMFontTest",UIScene) - - function UILabelBMFontTest:initExtend() - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("LabelBMFont") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - - local labelBMFont = ccui.TextBMFont:create() - labelBMFont:setFntFile("cocosui/bitmapFontTest2.fnt") - labelBMFont:setString("BMFont") - labelBMFont:setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2.0 + labelBMFont:getContentSize().height / 8.0)) - - self._uiLayer:addChild(labelBMFont) - end - -end) - -add_new_testcase(function() - local UILabelTest = create("UILabelTest",UIScene) - - function UILabelTest:initExtend() - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("Label") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local label = ccui.Text:create() - label:setString("Label") - label:setFontName("AmericanTypewriter") - label:setFontSize(30) - label:setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 + label:getContentSize().height / 4)) - self._uiLayer:addChild(label) - end -end) - -add_new_testcase(function() - local UITextAreaTest = create("UITextAreaTest",UIScene) - - function UITextAreaTest:initExtend() - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("TextArea") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local textArea = ccui.Text:create() - textArea:ignoreContentAdaptWithSize(false) - textArea:setContentSize(cc.size(280, 150)) - textArea:setTextHorizontalAlignment(cc.TEXT_ALIGNMENT_CENTER) - textArea:setString("TextArea widget can line wrap") - textArea:setFontName("AmericanTypewriter") - textArea:setFontSize(32) - textArea:setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 - textArea:getContentSize().height / 8)) - self._uiLayer:addChild(textArea) - end -end) - -add_new_testcase(function() - local UITextFieldTest = create("UITextFieldTest",UIScene) - - function UITextFieldTest:initExtend() - local widgetSize = self._widget:getContentSize() - self._displayValueLabel:setString("No Event") - - local alert = ccui.Text:create() - alert:setString("TextField") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function textFieldEvent(sender, eventType) - if eventType == ccui.TextFiledEventType.attach_with_ime then - local textField = sender - textField:runAction(cc.MoveBy:create(0.225,cc.p(0, 20))) - self._displayValueLabel:setString("attach with IME") - elseif eventType == ccui.TextFiledEventType.detach_with_ime then - local textField = sender - textField:runAction(cc.MoveBy:create(0.175, cc.p(0, -20))) - self._displayValueLabel:setString("detach with IME") - elseif eventType == ccui.TextFiledEventType.insert_text then - self._displayValueLabel:setString("insert words") - elseif eventType == ccui.TextFiledEventType.delete_backward then - self._displayValueLabel:setString("delete word") - end - end - - local textField = ccui.TextField:create() - textField:setTouchEnabled(true) - textField:setFontName(font_TextName) - textField:setFontSize(30) - textField:setPlaceHolder("input words here") - textField:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - textField:addEventListener(textFieldEvent) - self._uiLayer:addChild(textField) - end -end) - -add_new_testcase(function() - local UITextFieldMaxLengthTest = create("UITextFieldMaxLengthTest",UIScene) - - function UITextFieldMaxLengthTest:initExtend() - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel:setString("No Event") - - local alert = ccui.Text:create() - alert:setString("TextField max length") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function textFieldEvent(sender, eventType) - if eventType == ccui.TextFiledEventType.attach_with_ime then - local textField = sender - textField:runAction(cc.MoveBy:create(0.225,cc.p(0, 20))) - local info = string.format("attach with IME max length %d",textField:getMaxLength()) - self._displayValueLabel:setString(info) - elseif eventType == ccui.TextFiledEventType.detach_with_ime then - local textField = sender - textField:runAction(cc.MoveBy:create(0.175, cc.p(0, -20))) - local info = string.format("detach with IME max length %d",textField:getMaxLength()) - self._displayValueLabel:setString(info) - elseif eventType == ccui.TextFiledEventType.insert_text then - local textField = sender - local info = string.format("insert words max length %d",textField:getMaxLength()) - self._displayValueLabel:setString(info) - elseif eventType == ccui.TextFiledEventType.delete_backward then - local textField = sender - local info = string.format("delete word max length %d",textField:getMaxLength()) - self._displayValueLabel:setString(info) - end - end - - local textField = ccui.TextField:create() - textField:setMaxLengthEnabled(true) - textField:setMaxLength(3) - textField:setTouchEnabled(true) - textField:setFontName(font_TextName) - textField:setFontSize(30) - textField:setPlaceHolder("input words here") - textField:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - textField:addEventListener(textFieldEvent) - self._uiLayer:addChild(textField) - end -end) - -add_new_testcase(function() - local UITextFieldPasswordTest = create("UITextFieldPasswordTest",UIScene) - - function UITextFieldPasswordTest:initExtend() - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel:setString("No Event") - - local alert = ccui.Text:create() - alert:setString("TextField password") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function textFieldEvent(sender, eventType) - if eventType == ccui.TextFiledEventType.attach_with_ime then - local textField = sender - textField:runAction(cc.MoveBy:create(0.175, cc.p(0, 20))) - self._displayValueLabel:setString("detach with IME password") - elseif eventType == ccui.TextFiledEventType.detach_with_ime then - local textField = sender - textField:runAction(cc.MoveBy:create(0.175, cc.p(0, -20))) - self._displayValueLabel:setString("detach with IME password") - elseif eventType == ccui.TextFiledEventType.insert_text then - self._displayValueLabel:setString("insert words password") - elseif eventType == ccui.TextFiledEventType.delete_backward then - self._displayValueLabel:setString("delete word password") - end - end - - local textField = ccui.TextField:create() - textField:setPasswordEnabled(true) - textField:setPasswordStyleText("*") - textField:setTouchEnabled(true) - textField:setFontName(font_TextName) - textField:setFontSize(30) - textField:setPlaceHolder("input password here") - textField:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - textField:addEventListener(textFieldEvent) - self._uiLayer:addChild(textField) - end -end) - -add_new_testcase(function() - local UIPanelTest = create("UIPanelTest",UIScene) - - function UIPanelTest:initExtend() - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("Panel") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local layout = ccui.Layout:create() - layout:setContentSize(cc.size(280, 150)) - local backgroundSize = background:getContentSize() - layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - layout:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - layout:getContentSize().height) / 2)) - self._uiLayer:addChild(layout) - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - button:setPosition(cc.p(button:getContentSize().width / 2, layout:getContentSize().height - button:getContentSize().height / 2)) - layout:addChild(button) - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) - layout:addChild(textButton) - - local button_scale9 = ccui.Button:create() - button_scale9:setTouchEnabled(true) - button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button_scale9:setScale9Enabled(true) - button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - button_scale9:setPosition(cc.p(layout:getContentSize().width - button_scale9:getContentSize().width / 2, button_scale9:getContentSize().height / 2)) - layout:addChild(button_scale9) - end -end) - -add_new_testcase(function() - local UIPanelColorTest = create("UIPanelColorTest",UIScene) - - function UIPanelColorTest:initExtend() - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("Panel color render") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local layout = ccui.Layout:create() - layout:setBackGroundColorType(ccui.LayoutBackGroundColorType.solid) - layout:setBackGroundColor(cc.c3b(128, 128, 128)) - layout:setContentSize(cc.size(280, 150)) - local backgroundSize = background:getContentSize() - layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - layout:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - layout:getContentSize().height) / 2)) - self._uiLayer:addChild(layout) - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - button:setPosition(cc.p(button:getContentSize().width / 2, layout:getContentSize().height - button:getContentSize().height / 2)) - layout:addChild(button) - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) - layout:addChild(textButton) - - local button_scale9 = ccui.Button:create() - button_scale9:setTouchEnabled(true) - button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button_scale9:setScale9Enabled(true) - button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - button_scale9:setPosition(cc.p(layout:getContentSize().width - button_scale9:getContentSize().width / 2, button_scale9:getContentSize().height / 2)) - layout:addChild(button_scale9) - end -end) - -add_new_testcase(function() - local UIPanelGradientTest = create("UIPanelGradientTest",UIScene) - - function UIPanelGradientTest:initExtend() - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("Panel color Gradient") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local layout = ccui.Layout:create() - layout:setBackGroundColorType(ccui.LayoutBackGroundColorType.gradient) - layout:setBackGroundColor(cc.c3b(64, 64, 64), cc.c3b(192, 192, 192)) - layout:setContentSize(cc.size(280, 150)) - local backgroundSize = background:getContentSize() - layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - layout:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - layout:getContentSize().height) / 2)) - self._uiLayer:addChild(layout) - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - button:setPosition(cc.p(button:getContentSize().width / 2, layout:getContentSize().height - button:getContentSize().height / 2)) - layout:addChild(button) - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) - layout:addChild(textButton) - - local button_scale9 = ccui.Button:create() - button_scale9:setTouchEnabled(true) - button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button_scale9:setScale9Enabled(true) - button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - button_scale9:setPosition(cc.p(layout:getContentSize().width - button_scale9:getContentSize().width / 2, button_scale9:getContentSize().height / 2)) - layout:addChild(button_scale9) - end -end) - -add_new_testcase(function() - local UIPanelBackGroundImageTest = create("UIPanelBackGroundImageTest",UIScene) - - function UIPanelBackGroundImageTest:initExtend() - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("Panel background image") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local layout = ccui.Layout:create() - layout:setClippingEnabled(true) - layout:setBackGroundImage("cocosui/Hello.png") - layout:setContentSize(cc.size(280, 150)) - local backgroundSize = background:getContentSize() - layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - layout:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - layout:getContentSize().height) / 2)) - self._uiLayer:addChild(layout) - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - button:setPosition(cc.p(button:getContentSize().width / 2, layout:getContentSize().height - button:getContentSize().height / 2)) - layout:addChild(button) - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) - layout:addChild(textButton) - - local button_scale9 = ccui.Button:create() - button_scale9:setTouchEnabled(true) - button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button_scale9:setScale9Enabled(true) - button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - button_scale9:setPosition(cc.p(layout:getContentSize().width - button_scale9:getContentSize().width / 2, button_scale9:getContentSize().height / 2)) - layout:addChild(button_scale9) - end -end) - -add_new_testcase(function() - local UIPanelBackGroundImageScale9Test = create("UIPanelBackGroundImageScale9Test",UIScene) - - function UIPanelBackGroundImageScale9Test:initExtend() - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("Panel background image scale9") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local layout = ccui.Layout:create() - layout:setBackGroundImageScale9Enabled(true) - layout:setBackGroundImage("cocosui/green_edit.png") - layout:setContentSize(cc.size(280, 150)) - local backgroundSize = background:getContentSize() - layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - layout:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - layout:getContentSize().height) / 2)) - self._uiLayer:addChild(layout) - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - button:setPosition(cc.p(button:getContentSize().width / 2, layout:getContentSize().height - button:getContentSize().height / 2)) - layout:addChild(button) - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) - layout:addChild(textButton) - - local button_scale9 = ccui.Button:create() - button_scale9:setTouchEnabled(true) - button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button_scale9:setScale9Enabled(true) - button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - button_scale9:setPosition(cc.p(layout:getContentSize().width - button_scale9:getContentSize().width / 2, button_scale9:getContentSize().height / 2)) - layout:addChild(button_scale9) - end -end) - -add_new_testcase(function() - local UIPanelLayoutLinearVerticalTest = create("UIPanelLayoutLinearVerticalTest",UIScene) - - function UIPanelLayoutLinearVerticalTest:initExtend() - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("Panel Layout Linear Vertical") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local layout = ccui.Layout:create() - layout:setLayoutType(ccui.LayoutType.VERTICAL) - layout:setContentSize(cc.size(280, 150)) - local backgroundSize = background:getContentSize() - layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - layout:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - layout:getContentSize().height) / 2)) - self._uiLayer:addChild(layout) - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - layout:addChild(button) - - local lp1 = ccui.LinearLayoutParameter:create() - button:setLayoutParameter(lp1) - lp1:setGravity(ccui.LinearGravity.centerHorizontal) - lp1:setMargin({ left = 0, top = 5, right = 0, bottom = 10 }) - - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - layout:addChild(textButton) - - local lp2 = ccui.LinearLayoutParameter:create() - textButton:setLayoutParameter(lp2) - lp2:setGravity(ccui.LinearGravity.centerHorizontal) - lp2:setMargin({left = 0, top = 10, right = 0, bottom = 10} ) - - - local button_scale9 = ccui.Button:create() - button_scale9:setTouchEnabled(true) - button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button_scale9:setScale9Enabled(true) - button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - layout:addChild(button_scale9) - - local lp3 = ccui.LinearLayoutParameter:create() - button_scale9:setLayoutParameter(lp3) - lp3:setGravity(ccui.LinearGravity.centerHorizontal) - lp3:setMargin({ left = 0, top = 10, right = 0, bottom = 10 } ) - end -end) - -add_new_testcase(function() - local UIPanelLayoutLinearHorizontalTest = create("UIPanelLayoutLinearHorizontalTest",UIScene) - - function UIPanelLayoutLinearHorizontalTest:initExtend() - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("Panel Layout Linear Horizontal") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local layout = ccui.Layout:create() - layout:setLayoutType(ccui.LayoutType.HORIZONTAL) - layout:setClippingEnabled(true) - layout:setContentSize(cc.size(280, 150)) - local backgroundSize = background:getContentSize() - layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - layout:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - layout:getContentSize().height) / 2)) - self._uiLayer:addChild(layout) - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - layout:addChild(button) - - local lp1 = ccui.LinearLayoutParameter:create() - button:setLayoutParameter(lp1) - lp1:setGravity(ccui.LinearGravity.centerVertical) - lp1:setMargin({left = 0, top = 10, right = 0, bottom = 10} ) - - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - layout:addChild(textButton) - - local lp2 = ccui.LinearLayoutParameter:create() - textButton:setLayoutParameter(lp2) - lp2:setGravity(ccui.LinearGravity.centerVertical) - lp2:setMargin({left = 0,top = 10,right = 0,bottom = 10}) - - - local button_scale9 = ccui.Button:create() - button_scale9:setTouchEnabled(true) - button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button_scale9:setScale9Enabled(true) - button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - layout:addChild(button_scale9) - - local lp3 = ccui.LinearLayoutParameter:create() - button_scale9:setLayoutParameter(lp3) - lp3:setGravity(ccui.LinearGravity.centerVertical) - lp3:setMargin({left = 0, top = 10, right = 0, bottom = 10}) - end -end) - -add_new_testcase(function() - local UILayoutComponentBerthTest = create("UILayoutComponentBerthTest",UIScene) - - function UILayoutComponentBerthTest:initExtend() - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel:setString("LayoutComponent Berth Test") - - local baseLayer = cc.LayerColor:create() - baseLayer:setColor(cc.c3b(50, 100, 0)) - baseLayer:setOpacity(100) - baseLayer:setContentSize(cc.size(200, 200)) - self._uiLayer:addChild(baseLayer) - - button = ccui.Button:create("cocosui/animationbuttonnormal.png") - print(string.format("content size should be greater than 0: width = %f, height = %f", button:getContentSize().width, - button:getContentSize().height)) - button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - - button:addTouchEventListener(function(sender, eventType) - if eventType == ccui.TouchEventType.ended then - local touchWidgetSize = self._widget:getContentSize() - local layerSize = baseLayer:getContentSize() - if (layerSize.width == touchWidgetSize.width and layerSize.height == touchWidgetSize.height) then - baseLayer:setContentSize(cc.size(200, 200)) - else - baseLayer:setContentSize(widgetSize) - end - ccui.Helper:doLayout(baseLayer) - end - end) - button:setZoomScale(0.4) - button:setPressedActionEnabled(true) - self._uiLayer:addChild(button) - - - local leftTopSprite = cc.Sprite:create("cocosui/CloseSelected.png") - local leftTop = ccui.LayoutComponent:bindLayoutComponent(leftTopSprite) - leftTop:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Left) - leftTop:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Top) - baseLayer:addChild(leftTopSprite) - - local leftBottomSprite = cc.Sprite:create("cocosui/CloseSelected.png") - local leftBottom = ccui.LayoutComponent:bindLayoutComponent(leftBottomSprite) - leftBottom:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Left) - leftBottom:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Bottom) - baseLayer:addChild(leftBottomSprite) - - local rightTopSprite = cc.Sprite:create("cocosui/CloseSelected.png") - local rightTop = ccui.LayoutComponent:bindLayoutComponent(rightTopSprite) - rightTop:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Right) - rightTop:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Top) - baseLayer:addChild(rightTopSprite) - - local rightBottomSprite = cc.Sprite:create("cocosui/CloseSelected.png") - local rightBottom = ccui.LayoutComponent:bindLayoutComponent(rightBottomSprite) - rightBottom:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Right) - rightBottom:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Bottom) - baseLayer:addChild(rightBottomSprite) - - ccui.Helper:doLayout(baseLayer) - end -end) - -add_new_testcase(function() - local UILayoutComponentBerthStretchTest = create("UILayoutComponentBerthStretchTest",UIScene) - - function UILayoutComponentBerthStretchTest:initExtend() - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel:setString("LayoutComponent Berth Stretch Test") - - local baseLayer = cc.LayerColor:create() - baseLayer:setColor(cc.c3b(50, 100, 0)) - baseLayer:setOpacity(100) - baseLayer:setContentSize(cc.size(200, 200)) - self._uiLayer:addChild(baseLayer) - - button = ccui.Button:create("cocosui/animationbuttonnormal.png") - print(string.format("content size should be greater than 0: width = %f, height = %f", button:getContentSize().width, - button:getContentSize().height)) - button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - - button:addTouchEventListener(function(sender, eventType) - if eventType == ccui.TouchEventType.ended then - local touchWidgetSize = self._widget:getContentSize() - local layerSize = baseLayer:getContentSize() - if (layerSize.width == touchWidgetSize.width and layerSize.height == touchWidgetSize.height) then - baseLayer:setContentSize(cc.size(200, 200)) - else - baseLayer:setContentSize(widgetSize) - end - ccui.Helper:doLayout(baseLayer) - end - end) - button:setZoomScale(0.4) - button:setPressedActionEnabled(true) - self._uiLayer:addChild(button) - - local leftTopSprite = ccui.ImageView:create("cocosui/CloseSelected.png") - leftTopSprite:ignoreContentAdaptWithSize(false) - local leftTop = ccui.LayoutComponent:bindLayoutComponent(leftTopSprite) - leftTop:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Left) - leftTop:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Top) - leftTop:setStretchWidthEnabled(true) - leftTop:setStretchHeightEnabled(true) - baseLayer:addChild(leftTopSprite) - leftTop:setSize(leftTopSprite:getContentSize()) - leftTop:setLeftMargin(0) - leftTop:setTopMargin(0) - - local leftBottomSprite = ccui.ImageView:create("cocosui/CloseSelected.png") - leftBottomSprite:ignoreContentAdaptWithSize(false) - local leftBottom = ccui.LayoutComponent:bindLayoutComponent(leftBottomSprite) - leftBottom:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Left) - leftBottom:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Bottom) - leftBottom:setStretchWidthEnabled(true) - leftBottom:setStretchHeightEnabled(true) - baseLayer:addChild(leftBottomSprite) - leftBottom:setSize(leftBottomSprite:getContentSize()) - leftBottom:setLeftMargin(0) - leftBottom:setBottomMargin(0) - - local rightTopSprite = ccui.ImageView:create("cocosui/CloseSelected.png") - rightTopSprite:ignoreContentAdaptWithSize(false) - local rightTop = ccui.LayoutComponent:bindLayoutComponent(rightTopSprite) - rightTop:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Right) - rightTop:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Top) - rightTop:setStretchWidthEnabled(true) - rightTop:setStretchHeightEnabled(true) - baseLayer:addChild(rightTopSprite) - rightTop:setSize(rightTopSprite:getContentSize()) - rightTop:setTopMargin(0) - rightTop:setRightMargin(0) - - local rightBottomSprite = ccui.ImageView:create("cocosui/CloseSelected.png") - rightBottomSprite:ignoreContentAdaptWithSize(false) - local rightBottom = ccui.LayoutComponent:bindLayoutComponent(rightBottomSprite) - rightBottom:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Right) - rightBottom:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Bottom) - rightBottom:setStretchWidthEnabled(true) - rightBottom:setStretchHeightEnabled(true) - baseLayer:addChild(rightBottomSprite) - rightBottom:setSize(rightBottomSprite:getContentSize()) - rightBottom:setBottomMargin(0) - rightBottom:setRightMargin(0) - ccui.Helper:doLayout(baseLayer) - end -end) - -add_new_testcase(function() - local UIScrollViewVerticalTest = create("UIScrollViewVerticalTest",UIScene) - - function UIScrollViewVerticalTest:initExtend() - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel:setString("Move by vertical direction") - - local alert = ccui.Text:create() - alert:setString("ScrollView") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local scrollView = ccui.ScrollView:create() - scrollView:setTouchEnabled(true) - scrollView:setContentSize(cc.size(280, 150)) - local backgroundSize = background:getContentSize() - scrollView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - scrollView:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - scrollView:getContentSize().height) / 2)) - scrollView:setScrollBarWidth(4) - scrollView:setScrollBarPositionFromCorner(cc.p(2,2)) - scrollView:setScrollBarColor(cc.RED) - self._uiLayer:addChild(scrollView) - - local imageView = ccui.ImageView:create() - imageView:loadTexture("cocosui/ccicon.png") - - local innerWidth = scrollView:getContentSize().width - local innerHeight = scrollView:getContentSize().height + imageView:getContentSize().height - - scrollView:setInnerContainerSize(cc.size(innerWidth, innerHeight)) - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - button:setPosition(cc.p(innerWidth / 2, scrollView:getInnerContainerSize().height - button:getContentSize().height / 2)) - scrollView:addChild(button) - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(innerWidth / 2, button:getBottomBoundary() - button:getContentSize().height)) - scrollView:addChild(textButton) - - local button_scale9 = ccui.Button:create() - button_scale9:setTouchEnabled(true) - button_scale9:setScale9Enabled(true) - button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - button_scale9:setPosition(cc.p(innerWidth / 2, textButton:getBottomBoundary() - textButton:getContentSize().height)) - scrollView:addChild(button_scale9) - - imageView:setPosition(cc.p(innerWidth / 2, imageView:getContentSize().height / 2)) - scrollView:addChild(imageView) - end -end) - -add_new_testcase(function() - local UIScrollViewHorizontalTest = create("UIScrollViewHorizontalTest",UIScene) - - function UIScrollViewHorizontalTest:initExtend() - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel:setString("Move by horizontal direction") - - local alert = ccui.Text:create() - alert:setString("ScrollView") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local scrollView = ccui.ScrollView:create() - scrollView:setBounceEnabled(true) - scrollView:setDirection(ccui.ScrollViewDir.horizontal) - scrollView:setTouchEnabled(true) - scrollView:setContentSize(cc.size(280, 150)) - scrollView:setInnerContainerSize(scrollView:getContentSize()) - local backgroundSize = background:getContentSize() - scrollView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - scrollView:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - scrollView:getContentSize().height) / 2)) - self._uiLayer:addChild(scrollView) - - local imageView = ccui.ImageView:create() - imageView:loadTexture("cocosui/ccicon.png") - - local innerWidth = scrollView:getContentSize().width + imageView:getContentSize().width - local innerHeight = scrollView:getContentSize().height - - scrollView:setInnerContainerSize(cc.size(innerWidth, innerHeight)) - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - button:setPosition(cc.p(button:getContentSize().width / 2, - scrollView:getInnerContainerSize().height - button:getContentSize().height / 2)) - scrollView:addChild(button) - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(button:getRightBoundary() + button:getContentSize().width / 2, - button:getBottomBoundary() - button:getContentSize().height / 2)) - scrollView:addChild(textButton) - - local button_scale9 = ccui.Button:create() - button_scale9:setTouchEnabled(true) - button_scale9:setScale9Enabled(true) - button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - button_scale9:setPosition(cc.p(textButton:getRightBoundary() + textButton:getContentSize().width / 2, - textButton:getBottomBoundary() - textButton:getContentSize().height / 2)) - scrollView:addChild(button_scale9) - - imageView:setPosition(cc.p(innerWidth - imageView:getContentSize().width / 2, - button_scale9:getBottomBoundary() - button_scale9:getContentSize().height / 2)) - scrollView:addChild(imageView) - end -end) - -add_new_testcase(function() - local UIPageViewTest = create("UIPageViewTest",UIScene) - function UIPageViewTest:initExtend() - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel:setString("Move by horizontal direction") - - local alert = ccui.Text:create() - alert:setString("PageView") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local pageView = ccui.PageView:create() - pageView:setTouchEnabled(true) - pageView:setContentSize(cc.size(240, 130)) - local backgroundSize = background:getContentSize() - pageView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - pageView:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - pageView:getContentSize().height) / 2)) - for i = 1 , 3 do - local layout = ccui.Layout:create() - layout:setContentSize(cc.size(240, 130)) - - local imageView = ccui.ImageView:create() - imageView:setTouchEnabled(true) - imageView:setScale9Enabled(true) - imageView:loadTexture("cocosui/scrollviewbg.png") - imageView:setContentSize(cc.size(240, 130)) - imageView:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) - layout:addChild(imageView) - - local label = ccui.Text:create() - local pageInfo = string.format("page %d", i) - label:setString(pageInfo) - label:setFontName(font_TextName) - label:setFontSize(30) - label:setColor(cc.c3b(192, 192, 192)) - label:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) - layout:addChild(label) - - pageView:addWidgetToPage(layout, i-1) - - end - pageView:setCurPageIndex(1) - - local function pageViewEvent(sender, eventType) - if eventType == ccui.PageViewEventType.turning then - local pageInfo = string.format("page %d " , pageView:getCurPageIndex() + 1) - local pages = pageView:getPages() - print("total items " .. table.getn(pages)) - self._displayValueLabel:setString(pageInfo) - end - end - - pageView:addEventListener(pageViewEvent) - - self._uiLayer:addChild(pageView) - - end -end) - -add_new_testcase(function() - local UIPageViewVerticalTest = create("UIPageViewVerticalTest",UIScene) - function UIPageViewVerticalTest:initExtend() - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel:setString("Move by vertical direction") - - local alert = ccui.Text:create() - alert:setString("PageView") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local pageView = ccui.PageView:create() - pageView:setTouchEnabled(true) - pageView:setDirection(ccui.ScrollViewDir.vertical) - pageView:setContentSize(cc.size(240, 130)) - local backgroundSize = background:getContentSize() - pageView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - pageView:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - pageView:getContentSize().height) / 2)) - - for i = 1 , 3 do - local layout = ccui.Layout:create() - layout:setContentSize(cc.size(240, 130)) - - local imageView = ccui.ImageView:create() - imageView:setTouchEnabled(true) - imageView:setScale9Enabled(true) - imageView:loadTexture("cocosui/scrollviewbg.png") - imageView:setContentSize(cc.size(240, 130)) - imageView:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) - layout:addChild(imageView) - - local label = ccui.Text:create() - local pageInfo = string.format("page %d", i) - label:setString(pageInfo) - label:setFontName(font_TextName) - label:setFontSize(30) - label:setColor(cc.c3b(192, 192, 192)) - label:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) - layout:addChild(label) - - pageView:addPage(layout) - - end - - local function pageViewEvent(sender, eventType) - if eventType == ccui.PageViewEventType.turning then - local pageInfo = string.format("page %d " , pageView:getCurPageIndex() + 1) - self._displayValueLabel:setString(pageInfo) - end - end - - pageView:addEventListener(pageViewEvent) - - self._uiLayer:addChild(pageView) - - end -end) - -add_new_testcase(function() - local UIListViewVerticalTest = create("UIListViewVerticalTest",UIScene) - - function UIListViewVerticalTest:initExtend() - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel:setString("Move by vertical direction") - - local alert = ccui.Text:create() - alert:setString("ListView") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - - local background = root:getChildByName("background_Panel") - local backgroundSize = background:getContentSize() - - local array = {} - for i = 1,20 do - array[i] = string.format("ListView_item_%d",i - 1) - end - - local function listViewEvent(sender, eventType) - if eventType == ccui.ListViewEventType.ONSELECTEDITEM_START then - print("select child index = ",sender:getCurSelectedIndex()) - end - end - - local function scrollViewEvent(sender, evenType) - if evenType == ccui.ScrollviewEventType.scrollToBottom then - print("SCROLL_TO_BOTTOM") - elseif evenType == ccui.ScrollviewEventType.scrollToTop then - print("SCROLL_TO_TOP") - end - end - - local listView = ccui.ListView:create() - -- set list view ex direction - listView:setDirection(ccui.ScrollViewDir.vertical) - listView:setBounceEnabled(true) - listView:setBackGroundImage("cocosui/green_edit.png") - listView:setBackGroundImageScale9Enabled(true) - listView:setContentSize(cc.size(240, 130)) - listView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2.0 + - (backgroundSize.width - listView:getContentSize().width) / 2.0, - (widgetSize.height - backgroundSize.height) / 2.0 + - (backgroundSize.height - listView:getContentSize().height) / 2.0)) - listView:addEventListener(listViewEvent) - listView:addScrollViewEventListener(scrollViewEvent) - self._uiLayer:addChild(listView) - - - -- create model - local default_button = ccui.Button:create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png") - default_button:setName("Title Button") - - local default_item = ccui.Layout:create() - default_item:setTouchEnabled(true) - default_item:setContentSize(default_button:getContentSize()) - default_button:setPosition(cc.p(default_item:getContentSize().width / 2.0, default_item:getContentSize().height / 2.0)) - default_item:addChild(default_button) - - --set model - listView:setItemModel(default_item) - - --add default item - local count = table.getn(array) - for i = 1,math.floor(count / 4) do - listView:pushBackDefaultItem() - end - --insert default item - for i = 1,math.floor(count / 4) do - listView:insertDefaultItem(0) - end - - listView:removeAllChildren() - - local testSprite = cc.Sprite:create("cocosui/backtotoppressed.png") - testSprite:setPosition(cc.p(200,200)) - listView:addChild(testSprite) - - --add custom item - for i = 1,math.floor(count / 4) do - local custom_button = ccui.Button:create("cocosui/button.png", "cocosui/buttonHighlighted.png") - custom_button:setName("Title Button") - custom_button:setScale9Enabled(true) - custom_button:setContentSize(default_button:getContentSize()) - - local custom_item = ccui.Layout:create() - custom_item:setContentSize(custom_button:getContentSize()) - custom_button:setPosition(cc.p(custom_item:getContentSize().width / 2.0, custom_item:getContentSize().height / 2.0)) - custom_item:addChild(custom_button) - - listView:addChild(custom_item) - end - - --insert custom item - local items = listView:getItems() - local items_count = table.getn(items) - for i = 1, math.floor(count / 4) do - local custom_button = ccui.Button:create("cocosui/button.png", "cocosui/buttonHighlighted.png") - custom_button:setName("Title Button") - custom_button:setScale9Enabled(true) - custom_button:setContentSize(default_button:getContentSize()) - - local custom_item = ccui.Layout:create() - custom_item:setContentSize(custom_button:getContentSize()) - custom_button:setPosition(cc.p(custom_item:getContentSize().width / 2.0, custom_item:getContentSize().height / 2.0)) - custom_item:addChild(custom_button) - custom_item:setTag(1) - - listView:insertCustomItem(custom_item, items_count) - end - - -- set item data - items_count = table.getn(listView:getItems()) - for i = 1,items_count do - local item = listView:getItem(i - 1) - local button = item:getChildByName("Title Button") - local index = listView:getIndex(item) - button:setTitleText(array[index + 1]) - end - - -- remove last item - listView:removeChildByTag(1) - - -- remove item by index - items_count = table.getn(listView:getItems()) - listView:removeItem(items_count - 1) - - -- set all items layout gravity - listView:setGravity(ccui.ListViewGravity.centerVertical) - - --set items margin - listView:setItemsMargin(2.0) - end -end) - -add_new_testcase(function() - local UIListViewHorizontalTest = create("UIListViewHorizontalTest",UIScene) - - function UIListViewHorizontalTest:initExtend() - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel:setString("Move by vertical direction") - - local alert = ccui.Text:create() - alert:setString("ListView") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - - local root = self._uiLayer:getChildByTag(81) - - local background = root:getChildByName("background_Panel") - local backgroundSize = background:getContentSize() - - local array = {} - for i = 1,20 do - array[i] = string.format("ListView_item_%d",i - 1) - end - - local function listViewEvent(sender, eventType) - if eventType == ccui.ListViewEventType.ons_selected_item then - print("select child index = ",sender:getCurSelectedIndex()) - end - end - - local listView = ccui.ListView:create() - -- set list view ex direction - listView:setDirection(ccui.ScrollViewDir.horizontal) - listView:setTouchEnabled(true) - listView:setBounceEnabled(true) - listView:setBackGroundImage("cocosui/green_edit.png") - listView:setBackGroundImageScale9Enabled(true) - listView:setContentSize(cc.size(240, 130)) - listView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2.0 + - (backgroundSize.width - listView:getContentSize().width) / 2.0, - (widgetSize.height - backgroundSize.height) / 2.0 + - (backgroundSize.height - listView:getContentSize().height) / 2.0)) - listView:addEventListener(listViewEvent) - self._uiLayer:addChild(listView) - - - -- create model - local default_button = ccui.Button:create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png") - default_button:setName("Title Button") - - local default_item = ccui.Layout:create() - default_item:setTouchEnabled(true) - default_item:setContentSize(default_button:getContentSize()) - default_button:setPosition(cc.p(default_item:getContentSize().width / 2.0, default_item:getContentSize().height / 2.0)) - default_item:addChild(default_button) - - --set model - listView:setItemModel(default_item) - - --add default item - local count = table.getn(array) - for i = 1,math.floor(count / 4) do - listView:pushBackDefaultItem() - end - --insert default item - for i = 1,math.floor(count / 4) do - listView:insertDefaultItem(0) - end - - --add custom item - for i = 1,math.floor(count / 4) do - local custom_button = ccui.Button:create("cocosui/button.png", "cocosui/buttonHighlighted.png") - custom_button:setName("Title Button") - custom_button:setScale9Enabled(true) - custom_button:setContentSize(default_button:getContentSize()) - - local custom_item = ccui.Layout:create() - custom_item:setContentSize(custom_button:getContentSize()) - custom_button:setPosition(cc.p(custom_item:getContentSize().width / 2.0, custom_item:getContentSize().height / 2.0)) - custom_item:addChild(custom_button) - - listView:pushBackCustomItem(custom_item) - end - - --insert custom item - local items = listView:getItems() - local items_count = table.getn(items) - for i = 1, math.floor(count / 4) do - local custom_button = ccui.Button:create("cocosui/button.png", "cocosui/buttonHighlighted.png") - custom_button:setName("Title Button") - custom_button:setScale9Enabled(true) - custom_button:setContentSize(default_button:getContentSize()) - - local custom_item = ccui.Layout:create() - custom_item:setContentSize(custom_button:getContentSize()) - custom_button:setPosition(cc.p(custom_item:getContentSize().width / 2.0, custom_item:getContentSize().height / 2.0)) - custom_item:addChild(custom_button) - - listView:insertCustomItem(custom_item, items_count) - end - - -- set item data - items_count = table.getn(listView:getItems()) - print("items_count", items_count) - for i = 1,items_count do - local item = listView:getItem(i - 1) - local button = item:getChildByName("Title Button") - local index = listView:getIndex(item) - print("index is ", index) - button:setTitleText(array[index + 1]) - end - - -- remove last item - listView:removeLastItem() - - -- remove item by index - items_count = table.getn(listView:getItems()) - listView:removeItem(items_count - 1) - - -- set all items layout gravity - listView:setGravity(ccui.ListViewGravity.centerVertical) - - --set items margin - listView:setItemsMargin(2.0) - end -end) - -add_new_testcase(function() - local UIDragPanelTest = create("UIDragPanelTest",UIScene) - - function UIDragPanelTest:initExtend() - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel:setString("No Event") - - local alert = ccui.Text:create() - alert:setString("DragPanel") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local sc = ccui.ScrollView:create() - sc:setBackGroundColor(cc.c3b(0,255,0)) - sc:setBackGroundColorType(ccui.LayoutBackGroundColorType.solid) - sc:setDirection(ccui.ScrollViewDir.both) - sc:setInnerContainerSize(cc.size(480, 320)) - sc:setContentSize(cc.size(100,100)) - sc:setPosition(cc.p(100,100)) - sc:scrollToPercentBothDirection(cc.p(50, 50), 1, true) - local iv = ccui.ImageView:create() - iv:loadTexture("cocosui/Hello.png") - iv:setPosition(cc.p(240, 160)) - sc:addChild(iv) - self._uiLayer:addChild(sc) - - end -end) - -add_new_testcase(function() - local UIDragPanelBounceTest = create("UIDragPanelBounceTest",UIScene) - - function UIDragPanelBounceTest:initExtend() - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel:setString("No Event") - - local alert = ccui.Text:create() - alert:setString("DragPanel Bounce") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local sc = ccui.ScrollView:create() - sc:setBackGroundColor(cc.c3b(0, 255 , 0)) - sc:setBackGroundColorType(ccui.LayoutBackGroundColorType.solid) - sc:setBounceEnabled(true) - sc:setDirection(ccui.ScrollViewDir.both) - sc:setInnerContainerSize(cc.size(480, 320)) - sc:setContentSize(cc.size(100,100)) - sc:setPosition(cc.p(100,100)) - sc:scrollToPercentBothDirection(cc.p(50, 50), 1, true) - local iv = ccui.ImageView:create() - iv:loadTexture("cocosui/Hello.png") - iv:setPosition(cc.p(240, 160)) - sc:addChild(iv) - self._uiLayer:addChild(sc) - end -end) - -add_new_testcase(function() - local UINodeContainerTest = create("UINodeContainerTest",UIScene) - - function UINodeContainerTest:initExtend() - local widgetSize = self._widget:getContentSize() - self._displayValueLabel:setString("NodeContainer Add CCNode") - - local alert = ccui.Text:create() - alert:setString("NodeContainer") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local nodeContainer = ccui.Widget:create() - nodeContainer:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addChild(nodeContainer) - - local sprite = cc.Sprite:create("cocosui/ccicon.png") - sprite:setPosition(cc.p(0, sprite:getBoundingBox().height / 4)) - nodeContainer:addChild(sprite) - end -end) - -add_new_testcase(function() - local UIRichTextTest = create("UIRichTextTest",UIScene) - - function UIRichTextTest:initExtend() - local widgetSize = self._widget:getContentSize() - self._displayValueLabel:setString("") - - local alert = ccui.Text:create("RichText", "fonts/Marker Felt.ttf", 30) - alert:setFontName(font_TextName) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 3.125)) - self._widget:addChild(alert) - - - local function touchEvent(sender, eventType) - if eventType == ccui.TouchEventType.ended then - if self._richText:isIgnoreContentAdaptWithSize() then - self._richText:ignoreContentAdaptWithSize(false) - self._richText:setContentSize(cc.size(100, 100)) - else - self._richText:ignoreContentAdaptWithSize(true) - end - end - end - - local button = ccui.Button:create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png") - button:setTouchEnabled(true) - button:setTitleText("switch") - button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + button:getContentSize().height * 2.5)) - button:addTouchEventListener(touchEvent) - button:setLocalZOrder(10) - self._widget:addChild(button) - - self._richText = ccui.RichText:create() - self._richText:ignoreContentAdaptWithSize(false) - self._richText:setContentSize(cc.size(100, 100)) - - local re1 = ccui.RichElementText:create(1, cc.c3b(255, 255, 255), 255, "This color is white. ", "Helvetica", 10) - local re2 = ccui.RichElementText:create(2, cc.c3b(255, 255, 0), 255, "And this is yellow. ", "Helvetica", 10) - local re3 = ccui.RichElementText:create(3, cc.c3b(0, 0, 255), 255, "This one is blue. ", "Helvetica", 10) - local re4 = ccui.RichElementText:create(4, cc.c3b(0, 255, 0), 255, "And green. ", "Helvetica", 10) - local re5 = ccui.RichElementText:create(5, cc.c3b(255, 0, 0), 255, "Last one is red ", "Helvetica", 10) - - local reimg = ccui.RichElementImage:create(6, cc.c3b(255, 255, 255), 255, "cocosui/sliderballnormal.png") - - ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("cocosui/100/100.ExportJson") - local arr = ccs.Armature:create("100") - arr:getAnimation():play("Animation1") - - local recustom = ccui.RichElementCustomNode:create(1, cc.c3b(255, 255, 255), 255, arr) - local re6 = ccui.RichElementText:create(7, cc.c3b(255, 127, 0), 255, "Have fun!! ", "Helvetica", 10) - self._richText:pushBackElement(re1) - self._richText:insertElement(re2, 1) - self._richText:pushBackElement(re3) - self._richText:pushBackElement(re4) - self._richText:pushBackElement(re5) - self._richText:insertElement(reimg, 2) - self._richText:pushBackElement(recustom) - self._richText:pushBackElement(re6) - - self._richText:setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2)) - self._richText:setLocalZOrder(10) - - - self._widget:addChild(self._richText) - - end -end) - -add_new_testcase(function() - local UIFocusTestHorizontal = create("UIFocusTestHorizontal",UIScene) - - function UIFocusTestHorizontal:initExtend() - - self._displayValueLabel:setString("") - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - background:removeFromParent(true) - - local function onLeftKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_LEFT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onRightKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_RIGHT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onUpKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_UP, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onDownKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_DOWN, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - self._dpadMenu = cc.Menu:create() - local winSize = cc.Director:getInstance():getVisibleSize() - - local leftItem = cc.MenuItemFont:create("Left") - leftItem:setPosition(cc.p(winSize.width - 100, winSize.height/2)) - leftItem:registerScriptTapHandler(onLeftKeyPressed) - self._dpadMenu:addChild(leftItem) - - local rightItem = cc.MenuItemFont:create("Right") - rightItem:setPosition(cc.p(winSize.width - 30, winSize.height/2)) - rightItem:registerScriptTapHandler(onRightKeyPressed) - self._dpadMenu:addChild(rightItem) - - local upItem = cc.MenuItemFont:create("Up") - upItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 + 50)) - upItem:registerScriptTapHandler(onUpKeyPressed) - self._dpadMenu:addChild(upItem) - - local downItem = cc.MenuItemFont:create("Down") - downItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 - 50)) - downItem:registerScriptTapHandler(onDownKeyPressed) - self._dpadMenu:addChild(downItem) - self._dpadMenu:setPosition(cc.p(0, 0)) - self._uiLayer:addChild(self._dpadMenu) - - ccui.Widget:enableDpadNavigation(true) - - local function onFocusChanged(widgetLostFocus,widgetGetFocus) - if nil ~= widgetGetFocus and widgetGetFocus:isFocusEnabled() then - widgetGetFocus:setColor(cc.c3b(255, 0, 0)) - end - - if nil ~= widgetLostFocus and widgetLostFocus:isFocusEnabled() then - widgetLostFocus:setColor(cc.c3b(255, 255, 255)) - end - - if nil ~= widgetLostFocus and nil ~= widgetGetFocus then - print(string.format("on focus change, %d widget get focus, %d widget lose focus", widgetGetFocus:getTag(), widgetLostFocus:getTag())) - end - end - - local eventListener = cc.EventListenerFocus:create() - eventListener:registerScriptHandler(onFocusChanged) - local eventDispatcher = self:getEventDispatcher() - eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) - - local function onExit(tag) - if tag == "exit" then - if eventListener ~= nil then - eventDispatcher:removeEventListener(eventListener) - end - end - end - self:registerScriptHandler(onExit) - - local winSize = cc.Director:getInstance():getVisibleSize() - self._horizontalLayout = ccui.HBox:create() - self._horizontalLayout:setPosition(cc.p(20, winSize.height / 2 + 40)) - self._uiLayer:addChild(self._horizontalLayout) - - self._horizontalLayout:setFocused(true) - self._horizontalLayout:setLoopFocus(true) - self._horizontalLayout:setTag(100) - self._firstFocusedWidget = self._horizontalLayout - - local function onImageViewClicked(sender, eventType) - if eventType == ccui.TouchEventType.ended then - local w = sender - if w:isFocusEnabled() then - w:setFocusEnabled(false) - w:setColor(cc.c3b(255, 255, 0)) - else - w:setFocusEnabled(true) - w:setColor(cc.c3b(255, 255, 255)) - end - end - end - - local count = 3 - for i = 1, count do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setTouchEnabled(true) - imageView:setTag(i) - imageView:addTouchEventListener(onImageViewClicked) - self._horizontalLayout:addChild(imageView) - end - - self._loopText = ccui.Text:create("loop enabled", "Arial", 20) - self._loopText:setPosition(cc.p(winSize.width/2, winSize.height - 50)) - self._loopText:setColor(cc.c3b(255, 0 ,0)) - self:addChild(self._loopText) - - local function toggleFocusLoop(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self._horizontalLayout:setLoopFocus(not self._horizontalLayout:isLoopFocus()) - if self._horizontalLayout:isLoopFocus() then - self._loopText:setString("loop enabled") - else - self._loopText:setString("loop disabled") - end - end - end - - local btn = ccui.Button:create("cocosui/switch-mask.png") - btn:setTitleText("Toggle Loop") - btn:setPosition(cc.p(60, winSize.height - 50)) - btn:setTitleColor(cc.c3b(0, 255, 0)) - btn:addTouchEventListener(toggleFocusLoop) - self:addChild(btn) - end -end) - -add_new_testcase(function() - local UIFocusTestVertical = create("UIFocusTestVertical",UIScene) - - function UIFocusTestVertical:initExtend() - - self._displayValueLabel:setString("") - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - background:removeFromParent(true) - - local function onLeftKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_LEFT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onRightKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_RIGHT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onUpKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_UP, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onDownKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_DOWN, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - self._dpadMenu = cc.Menu:create() - local winSize = cc.Director:getInstance():getVisibleSize() - - local leftItem = cc.MenuItemFont:create("Left") - leftItem:setPosition(cc.p(winSize.width - 100, winSize.height/2)) - leftItem:registerScriptTapHandler(onLeftKeyPressed) - self._dpadMenu:addChild(leftItem) - - local rightItem = cc.MenuItemFont:create("Right") - rightItem:setPosition(cc.p(winSize.width - 30, winSize.height/2)) - rightItem:registerScriptTapHandler(onRightKeyPressed) - self._dpadMenu:addChild(rightItem) - - local upItem = cc.MenuItemFont:create("Up") - upItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 + 50)) - upItem:registerScriptTapHandler(onUpKeyPressed) - self._dpadMenu:addChild(upItem) - - local downItem = cc.MenuItemFont:create("Down") - downItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 - 50)) - downItem:registerScriptTapHandler(onDownKeyPressed) - self._dpadMenu:addChild(downItem) - self._dpadMenu:setPosition(cc.p(0, 0)) - self._uiLayer:addChild(self._dpadMenu) - - ccui.Widget:enableDpadNavigation(true) - - local function onFocusChanged(widgetLostFocus,widgetGetFocus) - if nil ~= widgetGetFocus and widgetGetFocus:isFocusEnabled() then - widgetGetFocus:setColor(cc.c3b(255, 0, 0)) - end - - if nil ~= widgetLostFocus and widgetLostFocus:isFocusEnabled() then - widgetLostFocus:setColor(cc.c3b(255, 255, 255)) - end - - if nil ~= widgetLostFocus and nil ~= widgetGetFocus then - print(string.format("on focus change, %d widget get focus, %d widget lose focus", widgetGetFocus:getTag(), widgetLostFocus:getTag())) - end - end - - local eventListener = cc.EventListenerFocus:create() - eventListener:registerScriptHandler(onFocusChanged) - local eventDispatcher = self:getEventDispatcher() - eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) - - local function onExit(tag) - if tag == "exit" then - if eventListener ~= nil then - eventDispatcher:removeEventListener(eventListener) - end - end - end - self:registerScriptHandler(onExit) - - local winSize = cc.Director:getInstance():getVisibleSize() - self._verticalLayout = ccui.VBox:create() - self._verticalLayout:setPosition(cc.p(winSize.width/2 - 100, winSize.height - 70)) - self._uiLayer:addChild(self._verticalLayout) - - self._verticalLayout:setFocused(true) - self._verticalLayout:setLoopFocus(true) - self._verticalLayout:setTag(100) - self._verticalLayout:setScale(0.5) - self._firstFocusedWidget = self._verticalLayout - - local function onImageViewClicked(sender, eventType) - if eventType == ccui.TouchEventType.ended then - local w = sender - if w:isFocusEnabled() then - w:setFocusEnabled(false) - w:setColor(cc.c3b(255, 255, 0)) - else - w:setFocusEnabled(true) - w:setColor(cc.c3b(255, 255, 255)) - end - end - end - - local count = 3 - for i = 1, count do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setTouchEnabled(true) - imageView:setTag(i) - imageView:addTouchEventListener(onImageViewClicked) - self._verticalLayout:addChild(imageView) - end - - self._loopText = ccui.Text:create("loop enabled", "Arial", 20) - self._loopText:setPosition(cc.p(winSize.width/2, winSize.height - 50)) - self._loopText:setColor(cc.c3b(255, 0 ,0)) - self:addChild(self._loopText) - - local function toggleFocusLoop(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self._verticalLayout:setLoopFocus(not self._verticalLayout:isLoopFocus()) - if self._verticalLayout:isLoopFocus() then - self._loopText:setString("loop enabled") - else - self._loopText:setString("loop disabled") - end - end - end - - local btn = ccui.Button:create("cocosui/switch-mask.png") - btn:setTitleText("Toggle Loop") - btn:setPosition(cc.p(60, winSize.height - 50)) - btn:setTitleColor(cc.c3b(0, 255, 0)) - btn:addTouchEventListener(toggleFocusLoop) - self:addChild(btn) - end -end) - -add_new_testcase(function() - local UIFocusTestNestedLayout1 = create("UIFocusTestNestedLayout1",UIScene) - - function UIFocusTestNestedLayout1:initExtend() - self._displayValueLabel:setString("") - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - background:removeFromParent(true) - - local function onLeftKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_LEFT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onRightKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_RIGHT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onUpKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_UP, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onDownKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_DOWN, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - self._dpadMenu = cc.Menu:create() - local winSize = cc.Director:getInstance():getVisibleSize() - - local leftItem = cc.MenuItemFont:create("Left") - leftItem:setPosition(cc.p(winSize.width - 100, winSize.height/2)) - leftItem:registerScriptTapHandler(onLeftKeyPressed) - self._dpadMenu:addChild(leftItem) - - local rightItem = cc.MenuItemFont:create("Right") - rightItem:setPosition(cc.p(winSize.width - 30, winSize.height/2)) - rightItem:registerScriptTapHandler(onRightKeyPressed) - self._dpadMenu:addChild(rightItem) - - local upItem = cc.MenuItemFont:create("Up") - upItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 + 50)) - upItem:registerScriptTapHandler(onUpKeyPressed) - self._dpadMenu:addChild(upItem) - - local downItem = cc.MenuItemFont:create("Down") - downItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 - 50)) - downItem:registerScriptTapHandler(onDownKeyPressed) - self._dpadMenu:addChild(downItem) - self._dpadMenu:setPosition(cc.p(0, 0)) - self._uiLayer:addChild(self._dpadMenu) - - ccui.Widget:enableDpadNavigation(true) - - local function onFocusChanged(widgetLostFocus,widgetGetFocus) - if nil ~= widgetGetFocus and widgetGetFocus:isFocusEnabled() then - widgetGetFocus:setColor(cc.c3b(255, 0, 0)) - end - - if nil ~= widgetLostFocus and widgetLostFocus:isFocusEnabled() then - widgetLostFocus:setColor(cc.c3b(255, 255, 255)) - end - - if nil ~= widgetLostFocus and nil ~= widgetGetFocus then - print(string.format("on focus change, %d widget get focus, %d widget lose focus", widgetGetFocus:getTag(), widgetLostFocus:getTag())) - end - end - - local eventListener = cc.EventListenerFocus:create() - eventListener:registerScriptHandler(onFocusChanged) - local eventDispatcher = self:getEventDispatcher() - eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) - - local function onExit(tag) - if tag == "exit" then - if eventListener ~= nil then - eventDispatcher:removeEventListener(eventListener) - end - end - end - self:registerScriptHandler(onExit) - - local winSize = cc.Director:getInstance():getVisibleSize() - - self._verticalLayout = ccui.VBox:create() - self._verticalLayout:setPosition(cc.p(winSize.width/2 - 80, winSize.height - 70)) - self._uiLayer:addChild(self._verticalLayout) - self._verticalLayout:setScale(0.5) - - self._verticalLayout:setFocused(true) - self._verticalLayout:setLoopFocus(true) - self._verticalLayout:setTag(100) - self._firstFocusedWidget = self._verticalLayout - - local function onImageViewClicked(sender, eventType) - if eventType == ccui.TouchEventType.ended then - local w = sender - if w:isFocusEnabled() then - w:setFocusEnabled(false) - w:setColor(cc.c3b(255, 255, 0)) - else - w:setFocusEnabled(true) - w:setColor(cc.c3b(255, 255, 255)) - end - end - end - - local count1 = 1 - for i = 1, count1 do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setAnchorPoint(cc.p(0, 0)) - imageView:setTouchEnabled(true) - imageView:setScaleX(2.5) - imageView:setTag(i - 1 + count1) - imageView:addTouchEventListener(onImageViewClicked) - self._verticalLayout:addChild(imageView) - end - - local hbox = ccui.HBox:create() - hbox:setScale(0.8) - hbox:setTag(101) - self._verticalLayout:addChild(hbox) - - local count2 = 2 - for i = 1, count2 do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setAnchorPoint(cc.p(0, 1)) - imageView:setScaleY(2.0) - imageView:setTouchEnabled(true) - imageView:setTag(i - 1 + count1 + count2) - imageView:addTouchEventListener(onImageViewClicked) - hbox:addChild(imageView) - end - - local innerVBox = ccui.VBox:create() - hbox:addChild(innerVBox) - innerVBox:setTag(102) - - local count3 = 2 - for i = 1, count3 do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setTouchEnabled(true) - imageView:setTag(i - 1 + count1 + count2 + count3) - imageView:addTouchEventListener(onImageViewClicked) - innerVBox:addChild(imageView) - end - - self._loopText = ccui.Text:create("loop enabled", "Arial", 20) - self._loopText:setPosition(cc.p(winSize.width/2, winSize.height - 50)) - self._loopText:setColor(cc.c3b(255, 0 ,0)) - self:addChild(self._loopText) - - local function toggleFocusLoop(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self._verticalLayout:setLoopFocus(not self._verticalLayout:isLoopFocus()) - if self._verticalLayout:isLoopFocus() then - self._loopText:setString("loop enabled") - else - self._loopText:setString("loop disabled") - end - end - end - - local btn = ccui.Button:create("cocosui/switch-mask.png") - btn:setTitleText("Toggle Loop") - btn:setPosition(cc.p(60, winSize.height - 50)) - btn:setTitleColor(cc.c3b(0, 255, 0)) - btn:addTouchEventListener(toggleFocusLoop) - self:addChild(btn) - end -end) - -add_new_testcase(function() - local UIFocusTestNestedLayout2 = create("UIFocusTestNestedLayout2",UIScene) - - function UIFocusTestNestedLayout2:initExtend() - self._displayValueLabel:setString("") - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - background:removeFromParent(true) - - local function onLeftKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_LEFT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onRightKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_RIGHT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onUpKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_UP, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onDownKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_DOWN, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - self._dpadMenu = cc.Menu:create() - local winSize = cc.Director:getInstance():getVisibleSize() - - local leftItem = cc.MenuItemFont:create("Left") - leftItem:setPosition(cc.p(winSize.width - 100, winSize.height/2)) - leftItem:registerScriptTapHandler(onLeftKeyPressed) - self._dpadMenu:addChild(leftItem) - - local rightItem = cc.MenuItemFont:create("Right") - rightItem:setPosition(cc.p(winSize.width - 30, winSize.height/2)) - rightItem:registerScriptTapHandler(onRightKeyPressed) - self._dpadMenu:addChild(rightItem) - - local upItem = cc.MenuItemFont:create("Up") - upItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 + 50)) - upItem:registerScriptTapHandler(onUpKeyPressed) - self._dpadMenu:addChild(upItem) - - local downItem = cc.MenuItemFont:create("Down") - downItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 - 50)) - downItem:registerScriptTapHandler(onDownKeyPressed) - self._dpadMenu:addChild(downItem) - self._dpadMenu:setPosition(cc.p(0, 0)) - self._uiLayer:addChild(self._dpadMenu) - - ccui.Widget:enableDpadNavigation(true) - - local function onFocusChanged(widgetLostFocus,widgetGetFocus) - if nil ~= widgetGetFocus and widgetGetFocus:isFocusEnabled() then - widgetGetFocus:setColor(cc.c3b(255, 0, 0)) - end - - if nil ~= widgetLostFocus and widgetLostFocus:isFocusEnabled() then - widgetLostFocus:setColor(cc.c3b(255, 255, 255)) - end - - if nil ~= widgetLostFocus and nil ~= widgetGetFocus then - print(string.format("on focus change, %d widget get focus, %d widget lose focus", widgetGetFocus:getTag(), widgetLostFocus:getTag())) - end - end - - local eventListener = cc.EventListenerFocus:create() - eventListener:registerScriptHandler(onFocusChanged) - local eventDispatcher = self:getEventDispatcher() - eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) - - local function onExit(tag) - if tag == "exit" then - if eventListener ~= nil then - eventDispatcher:removeEventListener(eventListener) - end - end - end - self:registerScriptHandler(onExit) - - local winSize = cc.Director:getInstance():getVisibleSize() - - self._horizontalLayout = ccui.HBox:create() - self._horizontalLayout:setPosition(cc.p(winSize.width/2 - 200, winSize.height - 70)) - self._uiLayer:addChild(self._horizontalLayout) - self._horizontalLayout:setScale(0.6) - - self._horizontalLayout:setFocused(true) - self._horizontalLayout:setLoopFocus(true) - self._horizontalLayout:setTag(100) - self._firstFocusedWidget = self._horizontalLayout - - local function onImageViewClicked(sender, eventType) - if eventType == ccui.TouchEventType.ended then - local w = sender - if w:isFocusEnabled() then - w:setFocusEnabled(false) - w:setColor(cc.c3b(255, 255, 0)) - else - w:setFocusEnabled(true) - w:setColor(cc.c3b(255, 255, 255)) - end - end - end - - local count1 = 2 - for i = 1, count1 do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setAnchorPoint(cc.p(0, 1)) - imageView:setTouchEnabled(true) - imageView:setScaleY(2.4) - imageView:setTag(i - 1 + count1) - imageView:addTouchEventListener(onImageViewClicked) - self._horizontalLayout:addChild(imageView) - end - - local vbox = ccui.VBox:create() - vbox:setScale(0.8) - vbox:setTag(101) - self._horizontalLayout:addChild(vbox) - - local count2 = 2 - for i = 1, count2 do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setAnchorPoint(cc.p(0, 1)) - imageView:setScaleX(2.0) - imageView:setTouchEnabled(true) - imageView:setTag(i - 1 + count1 + count2) - imageView:addTouchEventListener(onImageViewClicked) - vbox:addChild(imageView) - end - - local innerVBox = ccui.HBox:create() - vbox:addChild(innerVBox) - innerVBox:setTag(102) - - local count3 = 2 - for i = 1, count3 do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setTouchEnabled(true) - imageView:setTag(i - 1 + count1 + count2 + count3) - imageView:addTouchEventListener(onImageViewClicked) - innerVBox:addChild(imageView) - end - - self._loopText = ccui.Text:create("loop enabled", "Arial", 20) - self._loopText:setPosition(cc.p(winSize.width/2, winSize.height - 50)) - self._loopText:setColor(cc.c3b(255, 0 ,0)) - self:addChild(self._loopText) - - local function toggleFocusLoop(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self._horizontalLayout:setLoopFocus(not self._horizontalLayout:isLoopFocus()) - if self._horizontalLayout:isLoopFocus() then - self._loopText:setString("loop enabled") - else - self._loopText:setString("loop disabled") - end - end - end - - local btn = ccui.Button:create("cocosui/switch-mask.png") - btn:setTitleText("Toggle Loop") - btn:setPosition(cc.p(60, winSize.height - 50)) - btn:setTitleColor(cc.c3b(0, 255, 0)) - btn:addTouchEventListener(toggleFocusLoop) - self:addChild(btn) - end -end) - -add_new_testcase(function() - local UIFocusTestNestedLayout3 = create("UIFocusTestNestedLayout3",UIScene) - - function UIFocusTestNestedLayout3:initExtend() - self._displayValueLabel:setString("") - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - background:removeFromParent(true) - - local function onLeftKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_LEFT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onRightKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_RIGHT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onUpKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_UP, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onDownKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_DOWN, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - self._dpadMenu = cc.Menu:create() - local winSize = cc.Director:getInstance():getVisibleSize() - - local leftItem = cc.MenuItemFont:create("Left") - leftItem:setPosition(cc.p(winSize.width - 100, winSize.height/2)) - leftItem:registerScriptTapHandler(onLeftKeyPressed) - self._dpadMenu:addChild(leftItem) - - local rightItem = cc.MenuItemFont:create("Right") - rightItem:setPosition(cc.p(winSize.width - 30, winSize.height/2)) - rightItem:registerScriptTapHandler(onRightKeyPressed) - self._dpadMenu:addChild(rightItem) - - local upItem = cc.MenuItemFont:create("Up") - upItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 + 50)) - upItem:registerScriptTapHandler(onUpKeyPressed) - self._dpadMenu:addChild(upItem) - - local downItem = cc.MenuItemFont:create("Down") - downItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 - 50)) - downItem:registerScriptTapHandler(onDownKeyPressed) - self._dpadMenu:addChild(downItem) - self._dpadMenu:setPosition(cc.p(0, 0)) - self._uiLayer:addChild(self._dpadMenu) - - ccui.Widget:enableDpadNavigation(true) - - local function onFocusChanged(widgetLostFocus,widgetGetFocus) - if nil ~= widgetGetFocus and widgetGetFocus:isFocusEnabled() then - widgetGetFocus:setColor(cc.c3b(255, 0, 0)) - end - - if nil ~= widgetLostFocus and widgetLostFocus:isFocusEnabled() then - widgetLostFocus:setColor(cc.c3b(255, 255, 255)) - end - - if nil ~= widgetLostFocus and nil ~= widgetGetFocus then - print(string.format("on focus change, %d widget get focus, %d widget lose focus", widgetGetFocus:getTag(), widgetLostFocus:getTag())) - end - end - - local eventListener = cc.EventListenerFocus:create() - eventListener:registerScriptHandler(onFocusChanged) - local eventDispatcher = self:getEventDispatcher() - eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) - - local function onExit(tag) - if tag == "exit" then - if eventListener ~= nil then - eventDispatcher:removeEventListener(eventListener) - end - end - end - self:registerScriptHandler(onExit) - - local winSize = cc.Director:getInstance():getVisibleSize() - - self._verticalLayout = ccui.VBox:create() - self._verticalLayout:setPosition(cc.p(40, winSize.height - 70)) - self._uiLayer:addChild(self._verticalLayout) - self._verticalLayout:setScale(0.8) - - self._verticalLayout:setFocused(true) - self._verticalLayout:setLoopFocus(true) - self._verticalLayout:setTag(-1000) - self._firstFocusedWidget = self._verticalLayout - - local upperHBox = ccui.HBox:create() - upperHBox:setTag(-200) - self._verticalLayout:addChild(upperHBox) - - local params = ccui.LinearLayoutParameter:create() - params:setMargin({left = 0, top = 0, right = 50, bottom = 0}) - - local vparams = ccui.LinearLayoutParameter:create() - vparams:setMargin({left = 10, top = 0, right = 0, bottom = 140}) - upperHBox:setLayoutParameter(vparams) - - local function onImageViewClicked(sender, eventType) - if eventType == ccui.TouchEventType.ended then - local w = sender - if w:isFocusEnabled() then - w:setFocusEnabled(false) - w:setColor(cc.c3b(255, 255, 0)) - else - w:setFocusEnabled(true) - w:setColor(cc.c3b(255, 255, 255)) - end - end - end - - local count = 3 - for i = 1, count do - local firstVbox = ccui.VBox:create() - firstVbox:setScale(0.5) - firstVbox:setLayoutParameter(params) - firstVbox:setTag(i * 100) - - local count1 = 3 - for j = 1, count1 do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setTouchEnabled(true) - imageView:setTag(j + firstVbox:getTag()) - imageView:addTouchEventListener(onImageViewClicked) - firstVbox:addChild(imageView) - end - - upperHBox:addChild(firstVbox) - end - - local bottomHBox = ccui.HBox:create() - bottomHBox:setScale(0.5) - bottomHBox:setTag(600) - bottomHBox:setLayoutParameter(vparams) - - count = 3 - local bottomParams = ccui.LinearLayoutParameter:create() - bottomParams:setMargin({left = 0, top = 0, right = 8, bottom = 0}) - for i = 1, count do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setLayoutParameter(bottomParams) - imageView:setTouchEnabled(true) - imageView:setTag(i + 600) - imageView:addTouchEventListener(onImageViewClicked) - bottomHBox:addChild(imageView) - end - - self._verticalLayout:addChild(bottomHBox) - - self._loopText = ccui.Text:create("loop enabled", "Arial", 20) - self._loopText:setPosition(cc.p(winSize.width/2, winSize.height - 50)) - self._loopText:setColor(cc.c3b(255, 0 ,0)) - self:addChild(self._loopText) - - local function toggleFocusLoop(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self._verticalLayout:setLoopFocus(not self._verticalLayout:isLoopFocus()) - if self._verticalLayout:isLoopFocus() then - self._loopText:setString("loop enabled") - else - self._loopText:setString("loop disabled") - end - end - end - - local btn = ccui.Button:create("cocosui/switch-mask.png") - btn:setTitleText("Toggle Loop") - btn:setPosition(cc.p(60, winSize.height - 50)) - btn:setTitleColor(cc.c3b(0, 255, 0)) - btn:addTouchEventListener(toggleFocusLoop) - self:addChild(btn) - end -end) - -add_new_testcase(function() - local UIS9NinePatchTest = create( "UIS9NinePatchTest", UIScene) - - function UIS9NinePatchTest:initExtend() - - cc.SpriteFrameCache:getInstance():addSpriteFrames("cocosui/android9patch.plist") - - local winSize = cc.Director:getInstance():getWinSize() - local x = winSize.width / 2 - local y = 0 + (winSize.height / 2 + 50) - - local preferedSize = cc.size(99,99) - - --9-patch sprite with filename - local playerSprite = ccui.Scale9Sprite:create("cocosui/player.9.png") - playerSprite:setPosition(x, y) - playerSprite:setContentSize(preferedSize) - local capInsets = playerSprite:getCapInsets() - print(string.format("player sprite capInset = %f, %f %f, %f", capInsets.x, - capInsets.y, capInsets.width, capInsets.height)) - self:addChild(playerSprite) - - local animationBtnSprite = ccui.Scale9Sprite:createWithSpriteFrameName("animationbuttonpressed.png") - animationBtnSprite:setPosition(x-100, y-100) - capInsets = animationBtnSprite:getCapInsets() - print(string.format("animationBtnSprite capInset = %f, %f %f, %f", capInsets.x, - capInsets.y, capInsets.width, capInsets.height)) - self:addChild(animationBtnSprite) - - - local monsterSprite = ccui.Scale9Sprite:createWithSpriteFrameName("monster.9.png") - monsterSprite:setPosition(x+100, y-100) - capInsets = monsterSprite:getCapInsets() - monsterSprite:setContentSize(preferedSize) - print(string.format("monsterSprite capInset = %f, %f %f, %f", capInsets.x, - capInsets.y, capInsets.width, capInsets.height)) - self:addChild(monsterSprite) - - local spriteFrame = cc.SpriteFrameCache:getInstance():getSpriteFrame("buttonnormal.9.png") - local buttonScale9Sprite = ccui.Scale9Sprite:createWithSpriteFrame(spriteFrame) - buttonScale9Sprite:setContentSize(cc.size(150,80)) - buttonScale9Sprite:setPosition(cc.p(100,200)) - self:addChild(buttonScale9Sprite) - - end -end) - - - - -function guiSceneManager.nextUIScene() - guiSceneManager.currentUISceneIdx = (guiSceneManager.currentUISceneIdx + 1) % table.getn(cocoStudioGuiArray) - if 0 == guiSceneManager.currentUISceneIdx then - guiSceneManager.currentUISceneIdx = table.getn(cocoStudioGuiArray) - end - - return cocoStudioGuiArray[guiSceneManager.currentUISceneIdx].func() -end - -function guiSceneManager.previousUIScene() - - guiSceneManager.currentUISceneIdx = guiSceneManager.currentUISceneIdx - 1 - if guiSceneManager.currentUISceneIdx <= 0 then - guiSceneManager.currentUISceneIdx = guiSceneManager.currentUISceneIdx + table.getn(cocoStudioGuiArray) - end - - return cocoStudioGuiArray[guiSceneManager.currentUISceneIdx].func() -end - -function guiSceneManager.currentUIScene() - return cocoStudioGuiArray[guiSceneManager.currentUISceneIdx].func() -end - - - -function runCocosGUITestScene() - local scene = guiSceneManager.currentUIScene() - cc.Director:getInstance():replaceScene(scene) -end diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua deleted file mode 100644 index 856affe621..0000000000 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua +++ /dev/null @@ -1,929 +0,0 @@ -require "CocoStudioTest/CocoStudioSceneTest/TriggerCode/acts" -require "CocoStudioTest/CocoStudioSceneTest/TriggerCode/cons" -require "CocoStudioTest/CocoStudioSceneTest/TriggerCode/eventDef" - -local itemTagBasic = 1000 - -local sceneEditorTestIdx = 1 - -local SceneEditorTestLayer = class("SceneEditorTestLayer") -SceneEditorTestLayer.__index = SceneEditorTestLayer -SceneEditorTestLayer._backItem = nil -SceneEditorTestLayer._restarItem = nil -SceneEditorTestLayer._nextItem = nil -SceneEditorTestLayer.title = -{ - "loadSceneEdtiorFile Test", - "Sprite Component Test", - "Armature Component Test", - "UI Component Test", - "TmxMap Component Test", - "Particle Component Test", - "Effect Component Test", - "Background Component Test", - "Attribute Component Test", - "Trigger Test", -} - -SceneEditorTestLayer.loadtypeStr= -{ - "change to load \nwith binary file", - "change to load \nwith json file" -} - -SceneEditorTestLayer.fileName = "" -SceneEditorTestLayer.rootNode = nil - -function SceneEditorTestLayer.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, SceneEditorTestLayer) - return target -end - - -function SceneEditorTestLayer:onEnter() - -end - -function SceneEditorTestLayer:onExit() - ccs.TriggerMng.destroyInstance() - ccs.ArmatureDataManager:destroyInstance() - ccs.SceneReader:destroyInstance() - ccs.ActionManagerEx:destroyInstance() - ccs.GUIReader:destroyInstance() -end - -function SceneEditorTestLayer.create() - local layer = SceneEditorTestLayer.extend(cc.Layer:create()) - if nil ~= layer then - layer:createTitle() - layer:createMenu() - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - end - end - layer:registerScriptHandler(onNodeEvent) - end -end - -function SceneEditorTestLayer:createTitle() - local title = cc.Label:createWithTTF(self.title[sceneEditorTestIdx], s_arialPath, 18) - title:setAnchorPoint(cc.p(0.5, 0.5)) - title:setColor(cc.c3b(255, 255, 255)) - self:addChild(title, 1, 10000) - title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30)) -end - -function SceneEditorTestLayer:loadFileChangeHelper(filePathName) - local indexTable = {} - local index = 0 - - while true do - index = string.find(filePathName, "%.", index + 1) - if nil == index then - break - end - - indexTable[#indexTable + 1] = index - end - - if #indexTable == 0 then - return filePathName - end - - local lastIndex = indexTable[#indexTable] - if lastIndex == 1 then - return filePathName - end - local renamePathName= string.sub(filePathName, 1, lastIndex - 1) - - if self.isCsbLoad then - renamePathName = renamePathName .. ".csb" - else - renamePathName = renamePathName .. ".json" - end - print("renamePath is", renamePathName) - return renamePathName -end - -function SceneEditorTestLayer:defaultPlay() - -end - -function SceneEditorTestLayer:createMenu() - local menu = cc.Menu:create() - local function pre() - local scene = cc.Scene:create() - scene:addChild(backSceneEditorTest()) - cc.Director:getInstance():replaceScene(scene) - end - - local function restart() - local scene = cc.Scene:create() - scene:addChild(restartSceneEditorTest()) - cc.Director:getInstance():replaceScene(scene) - end - - local function next() - local scene = cc.Scene:create() - scene:addChild(nextSceneEditorTest()) - cc.Director:getInstance():replaceScene(scene) - end - - self._backItem = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) - self._backItem:registerScriptTapHandler(pre) - self._restarItem = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) - self._restarItem:registerScriptTapHandler(restart) - self._nextItem = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) - self._nextItem:registerScriptTapHandler(next) - - - - local size = cc.Director:getInstance():getWinSize() - self._backItem:setPosition(cc.p(size.width / 2 - self._restarItem:getContentSize().width * 2, self._restarItem:getContentSize().height / 2)) - self._restarItem:setPosition(cc.p(size.width / 2, self._restarItem:getContentSize().height / 2)) - self._nextItem:setPosition(cc.p(size.width / 2 + self._restarItem:getContentSize().width * 2, self._restarItem:getContentSize().height / 2)) - - menu:addChild(self._backItem,itemTagBasic) - menu:addChild(self._restarItem,itemTagBasic) - menu:addChild(self._nextItem,itemTagBasic) - menu:setPosition(cc.p(0,0)) - self:addChild(menu, 100) - - local function back() - local scene = CocoStudioTestMain() - if nil ~= scene then - cc.Director:getInstance():replaceScene(scene) - end - end - - self.isCsbLoad = false - self.loadtypeLabel = cc.Label:createWithSystemFont(self.loadtypeStr[1], "Arial", 12) - local function changeLoadTypeCallback(tag,sender) - self.isCsbLoad = not self.isCsbLoad - if self.isCsbLoad then - self.loadtypeLabel:setString(self.loadtypeStr[2]) - else - self.loadtypeLabel:setString(self.loadtypeStr[1]) - end - - if sceneEditorTestIdx == #SceneEditorTestLayer.title then - ccs.TriggerMng.getInstance():removeAll() - end - - SceneEditorTestLayer.fileName = self:loadFileChangeHelper(SceneEditorTestLayer.fileName) - - if SceneEditorTestLayer.rootNode ~= nil then - self:removeChild(SceneEditorTestLayer.rootNode, true) - SceneEditorTestLayer.rootNode = ccs.SceneReader:getInstance():createNodeWithSceneFile(SceneEditorTestLayer.fileName) - if SceneEditorTestLayer.rootNode == nil then - return - end - self:defaultPlay() - self:addChild(SceneEditorTestLayer.rootNode, 0, 1) - end - end - - local loadTypeItem = cc.MenuItemLabel:create(self.loadtypeLabel) - loadTypeItem:registerScriptTapHandler(changeLoadTypeCallback) - local loadtypeMenu = cc.Menu:create() - loadtypeMenu:addChild(loadTypeItem) - loadtypeMenu:setPosition(cc.p(0,0)) - loadTypeItem:setPosition(cc.p(VisibleRect:rightTop().x -80,VisibleRect:rightTop().y -30)) - self:addChild(loadtypeMenu, 100) - - local backMenu = cc.Menu:create() - cc.MenuItemFont:setFontName("Arial") - cc.MenuItemFont:setFontSize(24) - local menuItemFont = cc.MenuItemFont:create("Back") - menuItemFont:setPosition(cc.p(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) - menuItemFont:registerScriptTapHandler(back) - - backMenu:addChild(menuItemFont) - backMenu:setPosition(cc.p(0, 0)) - self:addChild(backMenu,10) -end - -local LoadSceneEdtiorFileTest = class("LoadSceneEdtiorFileTest",SceneEditorTestLayer) -LoadSceneEdtiorFileTest.__index = LoadSceneEdtiorFileTest - -function LoadSceneEdtiorFileTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, LoadSceneEdtiorFileTest) - return target -end - -function LoadSceneEdtiorFileTest:createGameScene() - local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/LoadSceneEdtiorFileTest/FishJoy2.json") - SceneEditorTestLayer.fileName = "scenetest/LoadSceneEdtiorFileTest/FishJoy2.json" - SceneEditorTestLayer.rootNode = node - self:defaultPlay() - return node -end - -function LoadSceneEdtiorFileTest:defaultPlay() - -end - -function LoadSceneEdtiorFileTest:onEnter() - self:createMenu() - self:createTitle() - local root = self:createGameScene() - if nil ~= root then - self:addChild(root, 0, 1) - end - -end - -function LoadSceneEdtiorFileTest.create() - local layer = LoadSceneEdtiorFileTest.extend(cc.Layer:create()) - - if nil ~= layer then - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - elseif "exit" == event then - layer:onExit() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local SpriteComponentTest = class("SpriteComponentTest",SceneEditorTestLayer) -SpriteComponentTest.__index = SpriteComponentTest - -function SpriteComponentTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, SpriteComponentTest) - return target -end - -function SpriteComponentTest:createGameScene() - local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/SpriteComponentTest/SpriteComponentTest.json") - if nil ~= node then - SceneEditorTestLayer.fileName = "scenetest/SpriteComponentTest/SpriteComponentTest.json" - SceneEditorTestLayer.rootNode = node - self:defaultPlay() - end - - return node -end - -function SpriteComponentTest:onEnter() - self:createMenu() - self:createTitle() - local root = self:createGameScene() - if nil ~= root then - self:addChild(root, 0, 1) - end -end - -function SpriteComponentTest:defaultPlay() - if SceneEditorTestLayer.rootNode ~= nil then - local action1 = cc.Blink:create(2, 10) - local action2 = cc.Blink:create(2, 5) - - local sister1 = SceneEditorTestLayer.rootNode:getChildByTag(10003):getComponent("CCSprite") - sister1:getNode():runAction(action1) - local sister2 = SceneEditorTestLayer.rootNode:getChildByTag(10004):getComponent("CCSprite") - sister2:getNode():runAction(action2) - end -end - -function SpriteComponentTest.create() - local layer = SpriteComponentTest.extend(cc.Layer:create()) - - if nil ~= layer then - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - elseif "exit" == event then - layer:onExit() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local ArmatureComponentTest = class("ArmatureComponentTest",SceneEditorTestLayer) -ArmatureComponentTest.__index = ArmatureComponentTest - -function ArmatureComponentTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, ArmatureComponentTest) - return target -end - -function ArmatureComponentTest:createGameScene() - local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/ArmatureComponentTest/ArmatureComponentTest.json") - if nil ~= node then - SceneEditorTestLayer.fileName = "scenetest/ArmatureComponentTest/ArmatureComponentTest.json" - SceneEditorTestLayer.rootNode = node - - self:defaultPlay() - end - - return node -end - -function ArmatureComponentTest:defaultPlay() - if SceneEditorTestLayer.rootName ~= nil then - local blowFish = node:getChildByTag(10007):getComponent("CCArmature") - blowFish:getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0))) - - local butterflyfish = node:getChildByTag(10008):getComponent("CCArmature") - butterflyfish:getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0))) - end -end - -function ArmatureComponentTest:onEnter() - self:createMenu() - self:createTitle() - local root = self:createGameScene() - if nil ~= root then - self:addChild(root, 0, 1) - end - -end - -function ArmatureComponentTest.create() - local layer = ArmatureComponentTest.extend(cc.Layer:create()) - - if nil ~= layer then - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - elseif "exit" == event then - layer:onExit() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local UIComponentTest = class("UIComponentTest",SceneEditorTestLayer) -UIComponentTest.__index = UIComponentTest - -function UIComponentTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIComponentTest) - return target -end - -function UIComponentTest:createGameScene() - local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/UIComponentTest/UIComponentTest.json") - if nil ~= node then - SceneEditorTestLayer.fileName = "scenetest/UIComponentTest/UIComponentTest.json" - SceneEditorTestLayer.rootNode = node - self:defaultPlay() - end - - return node -end - -function UIComponentTest:defaultPlay() - if SceneEditorTestLayer.rootNode ~= nil then - local render = SceneEditorTestLayer.rootNode:getChildByTag(10025):getComponent("GUIComponent") - local widget = render:getNode() - local button = widget:getChildByName("Button_156") - local function onTouch(sender, eventType) - if eventType == ccui.TouchEventType.began then - local blowFish = SceneEditorTestLayer.rootNode:getChildByTag(10010):getComponent("CCArmature") - blowFish:getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0))) - - local butterflyfish = SceneEditorTestLayer.rootNode:getChildByTag(10011):getComponent("CCArmature") - butterflyfish:getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0))) - end - end - - button:addTouchEventListener(onTouch) - end -end - -function UIComponentTest:onEnter() - self:createMenu() - self:createTitle() - local root = self:createGameScene() - if nil ~= root then - self:addChild(root, 0, 1) - end - -end - -function UIComponentTest.create() - local layer = UIComponentTest.extend(cc.Layer:create()) - - if nil ~= layer then - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - elseif "exit" == event then - layer:onExit() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local TmxMapComponentTest = class("TmxMapComponentTest",SceneEditorTestLayer) -TmxMapComponentTest.__index = TmxMapComponentTest - -function TmxMapComponentTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TmxMapComponentTest) - return target -end - -function TmxMapComponentTest:createGameScene() - local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/TmxMapComponentTest/TmxMapComponentTest.json") - if nil ~= node then - SceneEditorTestLayer.fileName = "scenetest/TmxMapComponentTest/TmxMapComponentTest.json" - SceneEditorTestLayer.rootNode = node - - self:defaultPlay() - end - - return node -end - -function TmxMapComponentTest:defaultPlay() - if SceneEditorTestLayer.rootNode ~= nil then - local tmxMap = SceneEditorTestLayer.rootNode:getChildByTag(10015):getComponent("CCTMXTiledMap") - local actionTo = cc.SkewTo:create(2, 0.0, 2.0) - local rotateTo = cc.RotateTo:create(2, 61.0) - local actionScaleTo = cc.ScaleTo:create(2, -0.44, 0.47) - - local actionScaleToBack = cc.ScaleTo:create(2, 1.0, 1.0) - local rotateToBack = cc.RotateTo:create(2, 0) - local actionToBack = cc.SkewTo:create(2, 0, 0) - - tmxMap:getNode():runAction(cc.Sequence:create(actionTo, actionToBack)) - tmxMap:getNode():runAction(cc.Sequence:create(rotateTo, rotateToBack)) - tmxMap:getNode():runAction(cc.Sequence:create(actionScaleTo, actionScaleToBack)) - end -end - -function TmxMapComponentTest:onEnter() - self:createMenu() - self:createTitle() - local root = self:createGameScene() - if nil ~= root then - self:addChild(root, 0, 1) - end - -end - -function TmxMapComponentTest.create() - local layer = TmxMapComponentTest.extend(cc.Layer:create()) - - if nil ~= layer then - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - elseif "exit" == event then - layer:onExit() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local ParticleComponentTest = class("ParticleComponentTest",SceneEditorTestLayer) -ParticleComponentTest.__index = ParticleComponentTest - -function ParticleComponentTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, ParticleComponentTest) - return target -end - -function ParticleComponentTest:createGameScene() - local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/ParticleComponentTest/ParticleComponentTest.json") - if nil ~= node then - SceneEditorTestLayer.fileName = "scenetest/ParticleComponentTest/ParticleComponentTest.json" - SceneEditorTestLayer.rootNode = node - - self:defaultPlay() - end - - return node -end - -function ParticleComponentTest:defaultPlay() - if SceneEditorTestLayer.rootNode ~= nil then - local particle = SceneEditorTestLayer.rootNode:getChildByTag(10020):getComponent("CCParticleSystemQuad") - local jump = cc.JumpBy:create(5, cc.p(-500,0), 50, 4) - local action = cc.Sequence:create( jump, jump:reverse()) - particle:getNode():runAction(action) - end -end - -function ParticleComponentTest:onEnter() - self:createMenu() - self:createTitle() - local root = self:createGameScene() - if nil ~= root then - self:addChild(root, 0, 1) - end - -end - -function ParticleComponentTest.create() - local layer = ParticleComponentTest.extend(cc.Layer:create()) - - if nil ~= layer then - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - elseif "exit" == event then - layer:onExit() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local EffectComponentTest = class("EffectComponentTest",SceneEditorTestLayer) -EffectComponentTest.__index = EffectComponentTest - -function EffectComponentTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, EffectComponentTest) - return target -end - -function EffectComponentTest:createGameScene() - local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/EffectComponentTest/EffectComponentTest.json") - if nil ~= node then - SceneEditorTestLayer.fileName = "scenetest/EffectComponentTest/EffectComponentTest.json" - SceneEditorTestLayer.rootNode = node - - self:defaultPlay() - end - - return node -end - -function EffectComponentTest:defaultPlay() - if SceneEditorTestLayer.rootNode ~= nil then - local render = SceneEditorTestLayer.rootNode:getChildByTag(10015):getComponent("CCArmature") - local armature = render:getNode() - local function animationEvent(armatureBack,movementType,movementID) - local id = movementID - if movementType == ccs.MovementEventType.loopComplete then - if id == "Fire" then - local audio = SceneEditorTestLayer.rootNode:getChildByTag(10015):getComponent("CCComAudio") - audio:playEffect() - end - end - end - - armature:getAnimation():setMovementEventCallFunc(animationEvent) - end -end - -function EffectComponentTest:onEnter() - self:createMenu() - self:createTitle() - local root = self:createGameScene() - if nil ~= root then - self:addChild(root, 0, 1) - end - -end - -function EffectComponentTest.create() - local layer = EffectComponentTest.extend(cc.Layer:create()) - - if nil ~= layer then - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - elseif "exit" == event then - layer:onExit() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local BackgroundComponentTest = class("BackgroundComponentTest",SceneEditorTestLayer) -BackgroundComponentTest.__index = BackgroundComponentTest - -function BackgroundComponentTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, BackgroundComponentTest) - return target -end - -function BackgroundComponentTest:createGameScene() - local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/BackgroundComponentTest/BackgroundComponentTest.json") - if nil ~= node then - SceneEditorTestLayer.fileName = "scenetest/BackgroundComponentTest/BackgroundComponentTest.json" - SceneEditorTestLayer.rootNode = node - - self:defaultPlay() - end - - return node -end - -function BackgroundComponentTest:defaultPlay() - if SceneEditorTestLayer.rootNode ~= nil then - local audio = SceneEditorTestLayer.rootNode:getComponent("CCBackgroundAudio") - audio:playBackgroundMusic() - end -end - -function BackgroundComponentTest:onEnter() - self:createMenu() - self:createTitle() - local root = self:createGameScene() - if nil ~= root then - self:addChild(root, 0, 1) - end - -end - -function BackgroundComponentTest.create() - local layer = BackgroundComponentTest.extend(cc.Layer:create()) - - if nil ~= layer then - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - elseif "exit" == event then - layer:onExit() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local AttributeComponentTest = class("AttributeComponentTest",SceneEditorTestLayer) -AttributeComponentTest.__index = AttributeComponentTest - -function AttributeComponentTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, AttributeComponentTest) - return target -end - -function AttributeComponentTest:createGameScene() - local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/AttributeComponentTest/AttributeComponentTest.json") - if nil ~= node then - SceneEditorTestLayer.fileName = "scenetest/AttributeComponentTest/AttributeComponentTest.json" - SceneEditorTestLayer.rootNode = node - self:defaultPlay() - end - return node -end - -function AttributeComponentTest:defaultPlay() - if SceneEditorTestLayer.rootNode ~= nil then - local attribute = SceneEditorTestLayer.rootNode:getChildByTag(10015):getComponent("CCComAttribute") - print(string.format("Name: %s, HP: %f, MP: %f", attribute:getString("name"), attribute:getFloat("maxHP"), attribute:getFloat("maxMP"))) - end -end - -function AttributeComponentTest:onEnter() - self:createMenu() - self:createTitle() - local root = self:createGameScene() - if nil ~= root then - self:addChild(root, 0, 1) - end - -end - -function AttributeComponentTest.create() - local layer = AttributeComponentTest.extend(cc.Layer:create()) - - if nil ~= layer then - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - elseif "exit" == event then - layer:onExit() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local TriggerTest = class("TriggerTest",SceneEditorTestLayer) -TriggerTest.__index = TriggerTest -TriggerTest._touchListener = nil - -function TriggerTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TriggerTest) - return target -end - -function TriggerTest:createGameScene() - local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/TriggerTest/TriggerTest.json") - if nil ~= node then - SceneEditorTestLayer.fileName = "scenetest/TriggerTest/TriggerTest.json" - SceneEditorTestLayer.rootNode = node - - self:defaultPlay() - end - return node -end - -function TriggerTest:onTouchBegan(touch,event) - ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHBEGAN) - return true -end - -function TriggerTest:onTouchMoved(touch,event) - ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHMOVED) -end - -function TriggerTest:onTouchEnded(touch,event) - ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHENDED) -end - -function TriggerTest:onTouchCancelled(touch,event) - ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHCANCELLED) -end - -function TriggerTest:onEnter() - self:createMenu() - self:createTitle() - local root = self:createGameScene() - if nil ~= root then - self:addChild(root, 0, 1) - local function onTouchEvent(touch, event) - if eventType == "began" then - return self:onTouchBegan(touch, event) - elseif eventType == "moved" then - self:onTouchMoved(touch, event) - elseif eventType == "ended" then - self:onTouchEnded(touch, event) - elseif eventType == "cancelled" then - self:onTouchCancelled(touch, event) - end - end - self._touchListener = nil - local listener = cc.EventListenerTouchOneByOne:create() - listener:setSwallowTouches(true) - listener:registerScriptHandler(self.onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN ) - listener:registerScriptHandler(self.onTouchMoved,cc.Handler.EVENT_TOUCH_MOVED ) - listener:registerScriptHandler(self.onTouchEnded,cc.Handler.EVENT_TOUCH_ENDED ) - listener:registerScriptHandler(self.onTouchCancelled,cc.Handler.EVENT_TOUCH_CANCELLED ) - local eventDispatcher = self:getEventDispatcher() - eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self) - self._touchListener = listener - - self:unscheduleUpdate() - local function update(dt) - ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_UPDATESCENE) - end - self:scheduleUpdateWithPriorityLua(update,0) - end -end - -function TriggerTest:defaultPlay() - ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_ENTERSCENE) -end - -function TriggerTest:onExit() - self:unscheduleUpdate() - ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_LEAVESCENE) - local dispatcher = self:getEventDispatcher() - dispatcher:removeEventListener(self._touchListener) - self._touchListener = nil - ccs.TriggerMng.destroyInstance() - ccs.ArmatureDataManager:destroyInstance() - ccs.SceneReader:destroyInstance() - ccs.ActionManagerEx:destroyInstance() - ccs.GUIReader:destroyInstance() -end - -function TriggerTest.create() - local layer = TriggerTest.extend(cc.Layer:create()) - - if nil ~= layer then - local function onNodeEvent(event) - if "enter" == event then - layer:onEnter() - elseif "exit" == event then - layer:onExit() - end - end - layer:registerScriptHandler(onNodeEvent) - end - - return layer -end - -local createSceneEditorTest = -{ - LoadSceneEdtiorFileTest.create, - SpriteComponentTest.create, - ArmatureComponentTest.create, - UIComponentTest.create, - TmxMapComponentTest.create, - ParticleComponentTest.create, - EffectComponentTest.create, - BackgroundComponentTest.create, - AttributeComponentTest.create, - TriggerTest.create, -} - -function nextSceneEditorTest( ) - sceneEditorTestIdx = sceneEditorTestIdx + 1 - sceneEditorTestIdx = sceneEditorTestIdx % table.getn(createSceneEditorTest) - - if 0 == sceneEditorTestIdx then - sceneEditorTestIdx = table.getn(createSceneEditorTest) - end - - return createSceneEditorTest[sceneEditorTestIdx]() -end - -function backSceneEditorTest() - sceneEditorTestIdx = sceneEditorTestIdx - 1 - if sceneEditorTestIdx <= 0 then - sceneEditorTestIdx = sceneEditorTestIdx + table.getn(createSceneEditorTest) - end - - return createSceneEditorTest[sceneEditorTestIdx]() -end - -function restartSceneEditorTest() - return createSceneEditorTest[sceneEditorTestIdx]() -end - -function runCocosSceneTestScene() - local scene = cc.Scene:create() - sceneEditorTestIdx = 1 - scene:addChild(restartSceneEditorTest()) - cc.Director:getInstance():replaceScene(scene) -end diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/TriggerCode/acts.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/TriggerCode/acts.lua deleted file mode 100644 index 6d1ca8c553..0000000000 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/TriggerCode/acts.lua +++ /dev/null @@ -1,170 +0,0 @@ -local TMoveBy = class("TMoveBy") -TMoveBy._tag = -1 -TMoveBy._duration = 0 -TMoveBy._x = 0 -TMoveBy._y = 0 -TMoveBy._reverse = false -function TMoveBy:ctor() - self._tag = -1 - self._duration = 0.0 - self._x = 0 - self._y = 0 - self._reverse = false -end - -function TMoveBy:init() - return true -end - -function TMoveBy:done() - local node = ccs.SceneReader:getInstance():getNodeByTag(self._tag) - if nil == node then - return - end - local actionBy = cc.MoveBy:create(self._duration, cc.p(self._x, self._y)) - if nil == actionBy then - return - end - - if true == self._reverse then - local actionByBack = actionBy:reverse() - node:runAction(cc.Sequence:create(actionBy, actionByBack)) - else - node:runAction(actionBy) - end -end - -function TMoveBy:serialize(value) - local dataItems = value["dataitems"] - if nil ~= dataItems then - local count = table.getn(dataItems) - for i = 1, count do - local subDict = dataItems[i] - local key = subDict["key"] - if key == "Tag" then - self._tag = subDict["value"] - elseif key == "Duration" then - self._duration = subDict["value"] - elseif key == "x" then - self._x = subDict["value"] - elseif key == "y" then - self._y = subDict["value"] - elseif key == "IsReverse" then - self._reverse = subDict["value"] - end - end - end -end - -function TMoveBy:removeAll() - local node = ccs.SceneReader:getInstance():getNodeByTag(self._tag) - node:getActionManager():removeAllActions() - print("TMoveBy::removeAll") -end - -local TScaleTo = class("TScaleTo") -TScaleTo._tag = -1 -TScaleTo._duration = 0 -TScaleTo._scaleX = 0 -TScaleTo._scaleY = 0 - -function TScaleTo:ctor() - self._tag = -1 - self._duration = 0 - self._scaleX = 0 - self._scaleY = 0 -end - -function TScaleTo:init() - return true -end - -function TScaleTo:done() - local node = ccs.SceneReader:getInstance():getNodeByTag(self._tag) - if nil == node then - return - end - - local actionTo = cc.ScaleTo:create(self._duration, self._scaleX, self._scaleY) - if nil == actionTo then - return - end - - node:runAction(actionTo) -end - -function TScaleTo:serialize(value) - local dataItems = value["dataitems"] - if nil ~= dataItems then - local count = table.getn(dataItems) - for i = 1, count do - local subDict = dataItems[i] - local key = subDict["key"] - if key == "Tag" then - self._tag = subDict["value"] - elseif key == "Duration" then - self._duration = subDict["value"] - elseif key == "ScaleX" then - self._scaleX = subDict["value"] - elseif key == "ScaleY" then - self._scaleY = subDict["value"] - end - end - end -end - -function TScaleTo:removeAll() - print("TScaleTo::removeAll") -end - - -local TriggerState = class("TriggerState") -TriggerState._id = -1 -TriggerState._state = 0 - -function TriggerState:ctor() - self._id = -1 - self._state = 0 -end - -function TriggerState:init() - return true -end - -function TriggerState:done() - local obj = ccs.TriggerMng.getInstance():getTriggerObj(self._id) - if nil ~= obj then - if self._state == 0 then - obj:setEnable(false) - elseif self._state == 1 then - obj:setEnable(true) - elseif self._state == 2 then - ccs.TriggerMng.getInstance():removeTriggerObj(self._id) - end - end -end - -function TriggerState:serialize(value) - local dataItems = value["dataitems"] - if nil ~= dataItems then - local count = table.getn(dataItems) - for i = 1, count do - local subDict = dataItems[i] - local key = subDict["key"] - if key == "ID" then - self._id = subDict["value"] - elseif key == "State" then - self._state = subDict["value"] - end - end - end -end - -function TriggerState:removeAll() - print("TriggerState::removeAll") -end - - -ccs.registerTriggerClass("TScaleTo",TScaleTo.new) -ccs.registerTriggerClass("TMoveBy",TMoveBy.new) -ccs.registerTriggerClass("TriggerState",TriggerState.new) diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/TriggerCode/cons.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/TriggerCode/cons.lua deleted file mode 100644 index e05c918fd7..0000000000 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/TriggerCode/cons.lua +++ /dev/null @@ -1,53 +0,0 @@ -local NodeInRect = class("NodeInRect") -NodeInRect._tag = -1 -NodeInRect._origin = nil -NodeInRect._size = nil - -function NodeInRect:ctor() - self._tag = -1 - self._origin = nil - self._size = nil - self._origin = cc.p(0, 0) - self._size = cc.size(0, 0) -end - -function NodeInRect:init() - return true -end - -function NodeInRect:detect() - local node = ccs.SceneReader:getInstance():getNodeByTag(self._tag) - if nil ~= node and math.abs(node:getPositionX() - self._origin.x) <= self._size.width and math.abs(node:getPositionY() - self._origin.y) <= self._size.height then - return true - end - - return false -end - -function NodeInRect:serialize(value) - local dataItems = value["dataitems"] - if nil ~= dataItems then - local count = table.getn(dataItems) - for i = 1, count do - local subDict = dataItems[i] - local key = subDict["key"] - if key == "Tag" then - self._tag = subDict["value"] - elseif key == "originX" then - self._origin.x = subDict["value"] - elseif key == "originY" then - self._origin.y = subDict["value"] - elseif key == "sizeWidth" then - self._size.width = subDict["value"] - elseif key == "sizeHeight" then - self._size.height = subDict["value"] - end - end - end -end - -function NodeInRect:removeAll() - print("NodeInRect::removeAll") -end - -ccs.registerTriggerClass("NodeInRect",NodeInRect.new) diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/TriggerCode/eventDef.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/TriggerCode/eventDef.lua deleted file mode 100644 index a973745b38..0000000000 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/TriggerCode/eventDef.lua +++ /dev/null @@ -1,12 +0,0 @@ - -triggerEventDef = -{ - TRIGGEREVENT_ENTERSCENE = 0, - TRIGGEREVENT_LEAVESCENE = 1, - TRIGGEREVENT_INITSCENE = 2, - TRIGGEREVENT_UPDATESCENE = 3, - TRIGGEREVENT_TOUCHBEGAN = 4, - TRIGGEREVENT_TOUCHMOVED = 5, - TRIGGEREVENT_TOUCHENDED = 6, - TRIGGEREVENT_TOUCHCANCELLED = 7, -} diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioTest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioTest.lua deleted file mode 100644 index c0b90397b8..0000000000 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioTest.lua +++ /dev/null @@ -1,135 +0,0 @@ -require "CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest" -require "CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest" -require "CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest" -require "CocoStudioTest/CocoStudioUIEditorTest/CocoStudioUIEditorTest" -require "CocoStudioTest/CocoStudioActionTimelineTest/CocoStudioActionTimelineTest" -require "CocoStudioTest/CocoStudioActionTimelineTest2/CocoStudioActionTimelineTest2" - -local LINE_SPACE = 40 -local ITEM_TAG_BASIC = 1000 - -local cocoStudioTestItemNames = -{ - { - itemTitle = "CocoStudioArmatureTest", - testScene = function () - runArmatureTestScene() - end - }, - - { - itemTitle = "CocoStudioGUITest", - testScene = function () - runCocosGUITestScene() - end - }, - - { - itemTitle = "CocoStudioSceneTest", - testScene = function () - runCocosSceneTestScene() - end - }, - - { - itemTitle = "CocoStudioUIEditorTest", - testScene = function() - runCocoStudioUIEditorTestScene() - end - }, - - { - itemTitle = "CocoStudioActionTimelineTest", - testScene = function() - runCocoStudioActionTimelineTestScene() - end - }, - - { - itemTitle = "CocoStudioActionTimelineTest2", - testScene = function() - runCocoStudioActionTimelineTest2Scene() - end - }, -} - -local CocoStudioTestScene = class("CocoStudioTestScene") -CocoStudioTestScene.__index = CocoStudioTestScene - -function CocoStudioTestScene.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, CocoStudioTestScene) - return target -end - -function CocoStudioTestScene:runThisTest() - - --armatureSceneIdx = ArmatureTestIndex.TEST_COCOSTUDIO_WITH_SKELETON - --self:addChild(restartArmatureTest()) -end - -function CocoStudioTestScene.create() - local scene = CocoStudioTestScene.extend(cc.Scene:create()) - return scene -end - -local CocoStudioTestLayer = class("CocoStudioTestLayer") -CocoStudioTestLayer.__index = CocoStudioTestLayer - -function CocoStudioTestLayer.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, CocoStudioTestLayer) - return target -end - -function CocoStudioTestLayer.onMenuCallback(tag,sender) - local index = sender:getLocalZOrder() - ITEM_TAG_BASIC - cocoStudioTestItemNames[index].testScene() -end - -function CocoStudioTestLayer:createMenu() - - local winSize = cc.Director:getInstance():getWinSize() - - local menu = cc.Menu:create() - menu:setPosition(cc.p(0,0)) - cc.MenuItemFont:setFontName("Arial") - cc.MenuItemFont:setFontSize(24) - - for i = 1, table.getn(cocoStudioTestItemNames) do - local menuItem = cc.MenuItemFont:create(cocoStudioTestItemNames[i].itemTitle) - menuItem:setPosition(cc.p(winSize.width / 2, winSize.height - (i + 1) * LINE_SPACE)) - menuItem:registerScriptTapHandler(CocoStudioTestLayer.onMenuCallback) - menu:addChild(menuItem, ITEM_TAG_BASIC + i) - end - - self:addChild(menu) -end - -function CocoStudioTestLayer.create() - local layer = CocoStudioTestLayer.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - end - return layer -end - -------------------------------------- ---CocoStudio Test -------------------------------------- -function CocoStudioTestMain() - local newScene = CocoStudioTestScene.create() - newScene:addChild(CreateBackMenuItem()) - newScene:addChild(CocoStudioTestLayer.create()) - newScene:runThisTest() - return newScene -end diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioUIEditorTest/CocoStudioUIEditorTest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioUIEditorTest/CocoStudioUIEditorTest.lua deleted file mode 100644 index 679f362ad8..0000000000 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioUIEditorTest/CocoStudioUIEditorTest.lua +++ /dev/null @@ -1,1442 +0,0 @@ -local LINE_SPACE = 40 -local ITEM_TAG_BASIC = 1000 -local CurPos = {x = 0, y = 0} -local BeginPos = {x = 0, y = 0} - -local targetPlatform = cc.Application:getInstance():getTargetPlatform() - -local function getFont() - if kTargetIphone == targetPlatform or kTargetIpad == targetPlatform then - return "Marker Felt" - else - return "cocosui/Marker Felt.ttf" - end -end - - -local UIScene = class("UIScene") -UIScene.__index = UIScene -UIScene._uiLayer= nil -UIScene._sceneTitle = nil - -function UIScene.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIScene) - return target -end - -function UIScene:init() - self._uiLayer = cc.Layer:create() - self:addChild(self._uiLayer) -end - -function UIScene.create() - local scene = cc.Scene:create() - local layer = UIScene.extend(cc.Layer:create()) - layer:init() - scene:addChild(layer) - return scene -end - -local UIButtonTest = class("UIButtonTest",UIScene) -UIButtonTest._displayValueLabel = nil - -function UIButtonTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIButtonTest) - return target -end - -function UIButtonTest:configureGUIScene() - local screenSize = cc.Director:getInstance():getWinSize() - local rootSize = self._layout:getContentSize() - self._uiLayer:setPosition(cc.p((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)) - - local root = self._layout:getChildByName("root_Panel") - local sceneTitle = ccui.Helper:seekWidgetByName(root, "UItest") - - local function toGUIEditorTestScene(sender,eventType) - runCocoStudioUIEditorTestScene() - end - local back_label = ccui.Helper:seekWidgetByName(root, "back") - back_label:addTouchEventListener(toGUIEditorTestScene) - - local function touchEvent(sender,eventType) - if eventType == ccui.TouchEventType.began then - self._displayValueLabel:setString("Touch Down") - elseif eventType == ccui.TouchEventType.moved then - self._displayValueLabel:setString("Touch Move") - elseif eventType == ccui.TouchEventType.ended then - self._displayValueLabel:setString("Touch Up") - elseif eventType == ccui.TouchEventType.canceled then - self._displayValueLabel:setString("Touch Cancelled") - end - end - - local button = ccui.Helper:seekWidgetByName(root, "Button_123") - button:addTouchEventListener(touchEvent) - - local title_button = ccui.Helper:seekWidgetByName(root, "Button_126") - title_button:addTouchEventListener(touchEvent) - - local scale9_button = ccui.Helper:seekWidgetByName(root, "Button_129") - scale9_button:addTouchEventListener(touchEvent) -end - -function UIButtonTest:initExtend() - self:init() - - local node = cc.CSLoader:createNode("cocosui/UIEditorTest/UIButton/res.csb") - local child = node:getChildByTag(4) - child:removeFromParent() - self._layout = child - self._uiLayer:addChild(self._layout) - self:configureGUIScene() - - -- local widgetSize = self._widget:getSize() - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("No Event") - self._displayValueLabel:setFontName("fonts/Marker Felt.ttf") - self._displayValueLabel:setFontSize(30) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(self._layout:getContentSize().width / 2, - self._layout:getContentSize().height - self._displayValueLabel:getContentSize().height * 2)) - self._uiLayer:addChild(self._displayValueLabel) -end - -function UIButtonTest.create() - local scene = cc.Scene:create() - local layer = UIButtonTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - cc.Director:getInstance():replaceScene(scene) -end - -local function runEditButtonTestScene() - UIButtonTest.create() -end - -local UICheckBoxEditorTest = class("UICheckBoxEditorTest",UIScene) -UICheckBoxEditorTest._displayValueLabel = nil - -function UICheckBoxEditorTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UICheckBoxEditorTest) - return target -end - -function UICheckBoxEditorTest:configureGUIScene() - local screenSize = cc.Director:getInstance():getWinSize() - local rootSize = self._layout:getContentSize() - self._uiLayer:setPosition(cc.p((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)) - - local root = self._layout:getChildByName("root_Panel") - local sceneTitle = ccui.Helper:seekWidgetByName(root, "UItest") - - local function toGUIEditorTestScene(sender,eventType) - runCocoStudioUIEditorTestScene() - end - local back_label = ccui.Helper:seekWidgetByName(root, "back") - back_label:addTouchEventListener(toGUIEditorTestScene) - - local function selectedStateEvent(sender,eventType) - if eventType == ccui.CheckBoxEventType.selected then - self._displayValueLabel:setString("Selected") - elseif eventType == ccui.CheckBoxEventType.unselected then - self._displayValueLabel:setString("Unselected") - end - end - - local checkbox = ccui.Helper:seekWidgetByName(root, "CheckBox_540") - checkbox:addEventListener(selectedStateEvent) -end - -function UICheckBoxEditorTest:initExtend() - self:init() - - local node = cc.CSLoader:createNode("cocosui/UIEditorTest/UICheckBox/res.csb") - local child = node:getChildByTag(5) - child:removeFromParent() - self._layout = child - self._uiLayer:addChild(self._layout) - self:configureGUIScene() - - -- local widgetSize = self._widget:getSize() - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("No Event") - self._displayValueLabel:setFontName("fonts/Marker Felt.ttf") - self._displayValueLabel:setFontSize(30) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(self._layout:getContentSize().width / 2, - self._layout:getContentSize().height - self._displayValueLabel:getContentSize().height * 2)) - self._uiLayer:addChild(self._displayValueLabel) -end - -function UICheckBoxEditorTest.create() - local scene = cc.Scene:create() - local layer = UICheckBoxEditorTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - cc.Director:getInstance():replaceScene(scene) -end - -local function runEditButtonEditorTestScene() - UICheckBoxEditorTest.create() -end - - -local UISliderEditorTest = class("UISliderEditorTest",UIScene) -UISliderEditorTest._displayValueLabel = nil - -function UISliderEditorTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UISliderEditorTest) - return target -end - -function UISliderEditorTest:configureGUIScene() - local screenSize = cc.Director:getInstance():getWinSize() - local rootSize = self._layout:getContentSize() - self._uiLayer:setPosition(cc.p((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)) - - local root = self._layout:getChildByName("root_Panel") - local sceneTitle = ccui.Helper:seekWidgetByName(root, "UItest") - - local function toGUIEditorTestScene(sender,eventType) - runCocoStudioUIEditorTestScene() - end - local back_label = ccui.Helper:seekWidgetByName(root, "back") - back_label:addTouchEventListener(toGUIEditorTestScene) - - local function sliderEvent(sender,eventType) - if eventType == ccui.SliderEventType.percentChanged then - local slider = sender - local percent = "Percent " .. slider:getPercent() - self._displayValueLabel:setString(percent) - end - end - - local slider = ccui.Helper:seekWidgetByName(root, "Slider_738") - slider:addEventListener(sliderEvent) -end - -function UISliderEditorTest:initExtend() - self:init() - - local node = cc.CSLoader:createNode("cocosui/UIEditorTest/UISlider/res.csb") - local child = node:getChildByTag(5) - child:removeFromParent() - self._layout = child - self._uiLayer:addChild(self._layout) - self:configureGUIScene() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("No Event") - self._displayValueLabel:setFontName("fonts/Marker Felt.ttf") - self._displayValueLabel:setFontSize(30) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(self._layout:getContentSize().width / 2, - self._layout:getContentSize().height - self._displayValueLabel:getContentSize().height * 2)) - self._uiLayer:addChild(self._displayValueLabel) -end - -function UISliderEditorTest.create() - local scene = cc.Scene:create() - local layer = UISliderEditorTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - cc.Director:getInstance():replaceScene(scene) -end - -local function runSliderEditorTestScene() - UISliderEditorTest.create() -end - -local UIImageViewEditorTest = class("UIImageViewEditorTest",UIScene) -UIImageViewEditorTest._displayValueLabel = nil - -function UIImageViewEditorTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIImageViewEditorTest) - return target -end - -function UIImageViewEditorTest:configureGUIScene() - local screenSize = cc.Director:getInstance():getWinSize() - local rootSize = self._layout:getContentSize() - self._uiLayer:setPosition(cc.p((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)) - - local root = self._layout:getChildByName("root_Panel") - local sceneTitle = ccui.Helper:seekWidgetByName(root, "UItest") - - local function toGUIEditorTestScene(sender,eventType) - runCocoStudioUIEditorTestScene() - end - local back_label = ccui.Helper:seekWidgetByName(root, "back") - back_label:addTouchEventListener(toGUIEditorTestScene) -end - -function UIImageViewEditorTest:initExtend() - self:init() - - local node = cc.CSLoader:createNode("cocosui/UIEditorTest/UIImageView/res.csb") - local child = node:getChildByTag(5) - child:removeFromParent() - self._layout = child - self._uiLayer:addChild(self._layout) - self:configureGUIScene() -end - -function UIImageViewEditorTest.create() - local scene = cc.Scene:create() - local layer = UIImageViewEditorTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - cc.Director:getInstance():replaceScene(scene) -end - -local function runImageViewEditorTestScene() - UIImageViewEditorTest.create() -end - -local LoadingBarEditorTest = class("LoadingBarEditorTest",UIScene) -LoadingBarEditorTest._displayValueLabel = nil - -function LoadingBarEditorTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, LoadingBarEditorTest) - return target -end - -function LoadingBarEditorTest:configureGUIScene() - local screenSize = cc.Director:getInstance():getWinSize() - local rootSize = self._layout:getContentSize() - self._uiLayer:setPosition(cc.p((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)) - - local root = self._layout:getChildByName("root_Panel") - local sceneTitle = ccui.Helper:seekWidgetByName(root, "UItest") - - local function toGUIEditorTestScene(sender,eventType) - self:unscheduleUpdate() - runCocoStudioUIEditorTestScene() - end - local back_label = ccui.Helper:seekWidgetByName(root, "back") - back_label:addTouchEventListener(toGUIEditorTestScene) - - local loadingBar_left_to_right = ccui.Helper:seekWidgetByName(root, "LoadingBar_856") - loadingBar_left_to_right:setPercent(0) - - local loadingBar_right_to_left = ccui.Helper:seekWidgetByName(root, "LoadingBar_857") - loadingBar_right_to_left:setPercent(0) -end - -function LoadingBarEditorTest:initExtend() - self:init() - - local node = cc.CSLoader:createNode("cocosui/UIEditorTest/UILoadingBar/res.csb") - local child = node:getChildByTag(5) - child:removeFromParent() - self._layout = child - self._uiLayer:addChild(self._layout) - self:configureGUIScene() - - self._count = 0 - - local function update(delta) - self._count = self._count + 1 - if self._count > 100 then - self._count = 0 - end - - local root = self._layout:getChildByName("root_Panel") - - local loadingBar_left_to_right = ccui.Helper:seekWidgetByName(root, "LoadingBar_856") - loadingBar_left_to_right:setPercent(self._count) - - local loadingBar_right_to_left = ccui.Helper:seekWidgetByName(root, "LoadingBar_857") - loadingBar_right_to_left:setPercent(self._count) - end - - self:scheduleUpdateWithPriorityLua(update, 0) -end - -function LoadingBarEditorTest.create() - local scene = cc.Scene:create() - local layer = LoadingBarEditorTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - cc.Director:getInstance():replaceScene(scene) -end - -local function runLoadingBarEditorTestScene() - LoadingBarEditorTest.create() -end - -local LabelAtalsEditorTest = class("LabelAtalsEditorTest",UIScene) -LabelAtalsEditorTest._displayValueLabel = nil - -function LabelAtalsEditorTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, LabelAtalsEditorTest) - return target -end - -function LabelAtalsEditorTest:configureGUIScene() - local screenSize = cc.Director:getInstance():getWinSize() - local rootSize = self._layout:getContentSize() - self._uiLayer:setPosition(cc.p((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)) - - local root = self._layout:getChildByName("root_Panel") - local sceneTitle = ccui.Helper:seekWidgetByName(root, "UItest") - - local function toGUIEditorTestScene(sender,eventType) - self:unscheduleUpdate() - runCocoStudioUIEditorTestScene() - end - local back_label = ccui.Helper:seekWidgetByName(root, "back") - back_label:addTouchEventListener(toGUIEditorTestScene) -end - -function LabelAtalsEditorTest:initExtend() - self:init() - - local node = cc.CSLoader:createNode("cocosui/UIEditorTest/UILabelAtlas/res.csb") - local child = node:getChildByTag(5) - child:removeFromParent() - self._layout = child - self._uiLayer:addChild(self._layout) - self:configureGUIScene() -end - -function LabelAtalsEditorTest.create() - local scene = cc.Scene:create() - local layer = LabelAtalsEditorTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - cc.Director:getInstance():replaceScene(scene) -end - -local function runLabelAtalsEditorTestScene() - LabelAtalsEditorTest.create() -end - -local LabelEditorTest = class("LabelEditorTest",UIScene) -LabelEditorTest._displayValueLabel = nil - -function LabelEditorTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, LabelEditorTest) - return target -end - -function LabelEditorTest:configureGUIScene() - local screenSize = cc.Director:getInstance():getWinSize() - local rootSize = self._layout:getContentSize() - self._uiLayer:setPosition(cc.p((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)) - - local root = self._layout:getChildByName("root_Panel") - local sceneTitle = ccui.Helper:seekWidgetByName(root, "UItest") - - local function toGUIEditorTestScene(sender,eventType) - self:unscheduleUpdate() - runCocoStudioUIEditorTestScene() - end - local back_label = ccui.Helper:seekWidgetByName(root, "back") - back_label:addTouchEventListener(toGUIEditorTestScene) -end - -function LabelEditorTest:initExtend() - self:init() - - local node = cc.CSLoader:createNode("cocosui/UIEditorTest/UILabel/res.csb") - local child = node:getChildByTag(5) - child:removeFromParent() - self._layout = child - self._uiLayer:addChild(self._layout) - self:configureGUIScene() -end - -function LabelEditorTest.create() - local scene = cc.Scene:create() - local layer = LabelEditorTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - cc.Director:getInstance():replaceScene(scene) -end - -local function runLabelEditorTestScene() - LabelEditorTest.create() -end - -local LabelBMFontEditorTest = class("LabelBMFontEditorTest",UIScene) -LabelBMFontEditorTest._displayValueLabel = nil - -function LabelBMFontEditorTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, LabelBMFontEditorTest) - return target -end - -function LabelBMFontEditorTest:configureGUIScene() - local screenSize = cc.Director:getInstance():getWinSize() - local rootSize = self._layout:getContentSize() - self._uiLayer:setPosition(cc.p((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)) - - local root = self._layout:getChildByName("root_Panel") - local sceneTitle = ccui.Helper:seekWidgetByName(root, "UItest") - - local function toGUIEditorTestScene(sender,eventType) - self:unscheduleUpdate() - runCocoStudioUIEditorTestScene() - end - local back_label = ccui.Helper:seekWidgetByName(root, "back") - back_label:addTouchEventListener(toGUIEditorTestScene) -end - -function LabelBMFontEditorTest:initExtend() - self:init() - - local node = cc.CSLoader:createNode("cocosui/UIEditorTest/UILabelBMFont/res.csb") - local child = node:getChildByTag(5) - child:removeFromParent() - self._layout = child - self._uiLayer:addChild(self._layout) - self:configureGUIScene() -end - -function LabelBMFontEditorTest.create() - local scene = cc.Scene:create() - local layer = LabelBMFontEditorTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - cc.Director:getInstance():replaceScene(scene) -end - -local function runLabelBMFontEditorTestScene() - LabelBMFontEditorTest.create() -end - -local TextFieldEditorTest = class("TextFieldEditorTest",UIScene) -TextFieldEditorTest._displayValueLabel = nil - -function TextFieldEditorTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TextFieldEditorTest) - return target -end - -function TextFieldEditorTest:configureGUIScene() - local screenSize = cc.Director:getInstance():getWinSize() - local rootSize = self._layout:getContentSize() - self._uiLayer:setPosition(cc.p((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)) - - local root = self._layout:getChildByName("root_Panel") - local sceneTitle = ccui.Helper:seekWidgetByName(root, "UItest") - - local function toGUIEditorTestScene(sender,eventType) - self:unscheduleUpdate() - runCocoStudioUIEditorTestScene() - end - local back_label = ccui.Helper:seekWidgetByName(root, "back") - back_label:addTouchEventListener(toGUIEditorTestScene) - - local function textFieldEvent(sender, eventType) - if eventType == ccui.TextFiledEventType.attach_with_ime then - self._displayValueLabel:setString("attach with IME") - elseif eventType == ccui.TextFiledEventType.detach_with_ime then - self._displayValueLabel:setString("detach with IME") - elseif eventType == ccui.TextFiledEventType.insert_text then - self._displayValueLabel:setString("insert words") - elseif eventType == ccui.TextFiledEventType.delete_backward then - self._displayValueLabel:setString("delete word") - end - end - - local textField_normal = ccui.Helper:seekWidgetByName(root, "TextField_1109") - textField_normal:addEventListener(textFieldEvent) - - local textField_max_character = ccui.Helper:seekWidgetByName(root, "TextField_1110") - textField_max_character:addEventListener(textFieldEvent) - - local textField_password = ccui.Helper:seekWidgetByName(root, "TextField_1107") - textField_password:addEventListener(textFieldEvent) -end - -function TextFieldEditorTest:initExtend() - self:init() - - local node = cc.CSLoader:createNode("cocosui/UIEditorTest/UITextField/res.csb") - local child = node:getChildByTag(5) - child:removeFromParent() - self._layout = child - self._uiLayer:addChild(self._layout) - self:configureGUIScene() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("No Event") - self._displayValueLabel:setFontName("fonts/Marker Felt.ttf") - self._displayValueLabel:setFontSize(30) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(self._layout:getContentSize().width / 2, - self._layout:getContentSize().height - self._displayValueLabel:getContentSize().height * 2)) - self._uiLayer:addChild(self._displayValueLabel) -end - -function TextFieldEditorTest.create() - local scene = cc.Scene:create() - local layer = TextFieldEditorTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - cc.Director:getInstance():replaceScene(scene) -end - -local function runTextFieldEditorTestScene() - TextFieldEditorTest.create() -end - -local LayoutEditorTest = class("LayoutEditorTest",UIScene) -LayoutEditorTest._displayValueLabel = nil - -function LayoutEditorTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, LayoutEditorTest) - return target -end - -function LayoutEditorTest:configureGUIScene() - local screenSize = cc.Director:getInstance():getWinSize() - local rootSize = self._layout:getContentSize() - self._uiLayer:setPosition(cc.p((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)) - - local root = self._layout:getChildByName("root_Panel") - local sceneTitle = ccui.Helper:seekWidgetByName(root, "UItest") - - local function toGUIEditorTestScene(sender,eventType) - self:unscheduleUpdate() - runCocoStudioUIEditorTestScene() - end - local back_label = ccui.Helper:seekWidgetByName(root, "back") - back_label:addTouchEventListener(toGUIEditorTestScene) -end - -function LayoutEditorTest:initExtend() - self:init() - - local node = cc.CSLoader:createNode("cocosui/UIEditorTest/UILayout/Layout/res.csb") - local child = node:getChildByTag(5) - child:removeFromParent() - self._layout = child - self._uiLayer:addChild(self._layout) - self:configureGUIScene() -end - -function LayoutEditorTest.create() - local scene = cc.Scene:create() - local layer = LayoutEditorTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - cc.Director:getInstance():replaceScene(scene) -end - -local function runLayoutEditorTestScene() - LayoutEditorTest.create() -end - -local LayoutComponentTest = class("LayoutComponentTest",UIScene) -LayoutComponentTest._displayValueLabel = nil - -function LayoutComponentTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, LayoutComponentTest) - return target -end - -function LayoutComponentTest:configureGUIScene() - - local screenSize = cc.Director:getInstance():getWinSize() - local rootSize = self._layout:getContentSize() - self._uiLayer:setPosition(cc.p((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)) - - - local scheduler = cc.Director:getInstance():getScheduler() - local schedulerEntry = 0 - - local root = self._layout:getChildByName("root_Panel") - - local back_label = ccui.Helper:seekWidgetByName(root, "back") - back_label:addTouchEventListener(function(sender, eventType) - scheduler:unscheduleScriptEntry(schedulerEntry) - schedulerEntry = 0 - runCocoStudioUIEditorTestScene() - end) - - local sceneTitle = ccui.Helper:seekWidgetByName(root, "UItest") - - - local hUnchecked = ccui.Helper:seekWidgetByName(root, "Button_h_unchecked") - local vUnchecked = ccui.Helper:seekWidgetByName(root, "Button_v_unchecked") - local hChecked = ccui.Helper:seekWidgetByName(root, "Button_h_checked") - local vChecked = ccui.Helper:seekWidgetByName(root, "Button_v_checked") - local lPinUnchecked = ccui.Helper:seekWidgetByName(root, "Button_Pin_Left") - local rPinUnchecked = ccui.Helper:seekWidgetByName(root, "Button_Pin_Right") - local tPinUnchecked = ccui.Helper:seekWidgetByName(root, "Button_Pin_Top") - local bPinUnchecked = ccui.Helper:seekWidgetByName(root, "Button_Pin_Bottom") - local lPinChecked = ccui.Helper:seekWidgetByName(root, "Button_Pin_Left_Checked") - local rPinChecked = ccui.Helper:seekWidgetByName(root, "Button_Pin_Right_Checked") - local tPinChecked = ccui.Helper:seekWidgetByName(root, "Button_Pin_Top_Checked") - local bPinChecked = ccui.Helper:seekWidgetByName(root, "Button_Pin_Bottom_Checked") - - local textPin = ccui.Helper:seekWidgetByName(root, "Text_Pin") - local textStretch = ccui.Helper:seekWidgetByName(root, "Text_Stretch") - local widget = ccui.Helper:seekWidgetByName(root, "Image_Widget") - local container = ccui.Helper:seekWidgetByName(root, "background_Panel") - - local strenchStartIndex = 0 - local function onChangeLayoutComponent(sender) - local statusStretch = textStretch:getString() - --if statusStretch == nil - local statusPin = textPin:getString() - local hPinStatus = " Left" - local vPinStatus = " Bottom" - - if sender == hUnchecked then - hUnchecked:setVisible(false) - hChecked:setVisible(true) - statusStretch = statusStretch .. " Horizontal" - textStretch:setString(statusStretch) - elseif sender == hChecked then - hChecked:setVisible(false) - hUnchecked:setVisible(true) - strenchStartIndex = string.find(statusStretch, " Horizontal") - if strenchStartIndex ~= nil then - statusStretch = string.gsub(statusStretch, " Horizontal", "") - end - textStretch:setString(statusStretch) - elseif sender == vUnchecked then - vUnchecked:setVisible(false) - vChecked:setVisible(true) - statusStretch = statusStretch .. " Vertical" - textStretch:setString(statusStretch) - elseif sender == vChecked then - vChecked:setVisible(false) - vUnchecked:setVisible(true) - strenchStartIndex = string.find(statusStretch, " Vertical") - if strenchStartIndex ~= nil then - statusStretch = string.gsub(statusStretch, " Vertical", "") - end - textStretch:setString(statusStretch) - elseif sender == lPinUnchecked then - lPinUnchecked:setVisible(false) - lPinChecked:setVisible(true) - elseif sender == lPinChecked then - lPinChecked:setVisible(false) - lPinUnchecked:setVisible(true) - elseif sender == rPinUnchecked then - rPinUnchecked:setVisible(false) - rPinChecked:setVisible(true) - elseif sender == rPinChecked then - rPinChecked:setVisible(false) - rPinUnchecked:setVisible(true) - elseif sender == tPinUnchecked then - tPinUnchecked:setVisible(false) - tPinChecked:setVisible(true) - elseif sender == tPinChecked then - tPinChecked:setVisible(false) - tPinUnchecked:setVisible(true) - elseif sender == bPinUnchecked then - bPinUnchecked:setVisible(false) - bPinChecked:setVisible(true) - elseif (sender == bPinChecked) then - bPinChecked:setVisible(false) - bPinUnchecked:setVisible(true) - end - - if rPinChecked:isVisible() then - if lPinChecked:isVisible() then - hPinStatus = " Left Right" - else - hPinStatus = " Right" - end - end - - if tPinChecked:isVisible() then - if bPinChecked:isVisible() then - vPinStatus = " Top Bottom" - else - vPinStatus = " Top" - end - end - - statusPin = string.format("Pin:%s%s", hPinStatus, vPinStatus) - textPin:setString(statusPin) - - local layoutComponent = ccui.LayoutComponent:bindLayoutComponent(widget) - local widthEnableFlag = false - if string.find(statusStretch, "Horizontal") ~= nil then - widthEnableFlag = true - end - layoutComponent:setStretchWidthEnabled(widthEnableFlag) - - local heightEnableFlag = false - if string.find(statusStretch, "Vertical") ~= nil then - heightEnableFlag = true - end - layoutComponent:setStretchHeightEnabled(heightEnableFlag) - - local horizontalEdgeType = ccui.LayoutComponent.HorizontalEdge.None - if string.find(statusPin, "Left") ~= nil and string.find(statusPin, "Right") == nil then - horizontalEdgeType = ccui.LayoutComponent.HorizontalEdge.Left - elseif string.find(statusPin, "Left") == nil and string.find(statusPin, "Right") ~= nil then - horizontalEdgeType = ccui.LayoutComponent.HorizontalEdge.Right - elseif string.find(statusPin, "Left") ~= nil and string.find(statusPin, "Right") ~= nil then - horizontalEdgeType = ccui.LayoutComponent.HorizontalEdge.Center - end - layoutComponent:setHorizontalEdge(horizontalEdgeType) - - local verticalEdgeType = ccui.LayoutComponent.VerticalEdge.None - if string.find(statusPin, "Top") ~= nil and string.find(statusPin, "Bottom") == nil then - verticalEdgeType = ccui.LayoutComponent.VerticalEdge.Top - elseif string.find(statusPin, "Top") == nil and string.find(statusPin, "Bottom") ~= nil then - verticalEdgeType = ccui.LayoutComponent.VerticalEdge.Bottom - elseif string.find(statusPin, "Top") ~= nil and string.find(statusPin, "Bottom") ~= nil then - verticalEdgeType = ccui.LayoutComponent.VerticalEdge.Center - end - layoutComponent:setVerticalEdge(verticalEdgeType) - end - - hUnchecked:addClickEventListener(onChangeLayoutComponent) - vUnchecked:addClickEventListener(onChangeLayoutComponent) - hChecked:addClickEventListener(onChangeLayoutComponent) - vChecked:addClickEventListener(onChangeLayoutComponent) - lPinUnchecked:addClickEventListener(onChangeLayoutComponent) - rPinUnchecked:addClickEventListener(onChangeLayoutComponent) - tPinUnchecked:addClickEventListener(onChangeLayoutComponent) - bPinUnchecked:addClickEventListener(onChangeLayoutComponent) - lPinChecked:addClickEventListener(onChangeLayoutComponent) - rPinChecked:addClickEventListener(onChangeLayoutComponent) - tPinChecked:addClickEventListener(onChangeLayoutComponent) - bPinChecked:addClickEventListener(onChangeLayoutComponent) - - local btnSwitch = ccui.Helper:seekWidgetByName(root, "Button_Switch") - local scheduleTimes = 0 - btnSwitch:addClickEventListener(function(sender) - local layoutController = ccui.Helper:seekWidgetByName(root, "Panel_Controller") - local size = container:getContentSize() - local switchButton = ccui.Helper:seekWidgetByName(root, "Button_Switch") - switchButton:setEnabled(false) - switchButton:setBright(false) - - if size.width < 200 then - layoutController:setVisible(false) - - scheduler:unscheduleScriptEntry(schedulerEntry) - - schedulerEntry = scheduler:scheduleScriptFunc(function(dt) - - local increaseSize = container:getContentSize() - increaseSize.width = increaseSize.width + 303.0 / 40.0 - increaseSize.height = increaseSize.height + 70.0 / 40.0 - container:setContentSize(increaseSize) - ccui.Helper:doLayout(container) - - if increaseSize.width > 390 then - switchButton:setEnabled(true) - switchButton:setBright(true) - scheduler:unscheduleScriptEntry(schedulerEntry) - schedulerEntry = 0 - end - end, 0.025, false) - else - layoutController:setVisible(true) - - scheduler:unscheduleScriptEntry(schedulerEntry) - schedulerEntry = scheduler:scheduleScriptFunc(function(dt) - - local decreaseSize = container:getContentSize() - decreaseSize.width = decreaseSize.width - 303.0 / 40.0 - decreaseSize.height = decreaseSize.height - 70.0 / 40.0 - container:setContentSize(decreaseSize) - ccui.Helper:doLayout(container) - - if decreaseSize.width < 110 then - switchButton:setEnabled(true) - switchButton:setBright(true) - scheduler:unscheduleScriptEntry(schedulerEntry) - schedulerEntry = 0 - end - end, 0.025, false) - end - end) -end - -function LayoutComponentTest:initExtend() - self:init() - - local node = cc.CSLoader:createNode("cocosui/UIEditorTest/UILayout/LayoutComponent/res.csb") - local child = node:getChildByTag(5) - child:removeFromParent() - self._layout = child - self._uiLayer:addChild(self._layout) - self:configureGUIScene() -end - -function LayoutComponentTest.create() - local scene = cc.Scene:create() - local layer = LayoutComponentTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - cc.Director:getInstance():replaceScene(scene) -end - -local function runLayoutComponentTestScene() - LayoutComponentTest.create() -end - -local ScrollViewEditorTest = class("ScrollViewEditorTest",UIScene) -ScrollViewEditorTest._displayValueLabel = nil - -function ScrollViewEditorTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, ScrollViewEditorTest) - return target -end - -function ScrollViewEditorTest:configureGUIScene() - local screenSize = cc.Director:getInstance():getWinSize() - local rootSize = self._layout:getContentSize() - self._uiLayer:setPosition(cc.p((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)) - - local root = self._layout:getChildByName("root_Panel") - local sceneTitle = ccui.Helper:seekWidgetByName(root, "UItest") - - local function toGUIEditorTestScene(sender,eventType) - self:unscheduleUpdate() - runCocoStudioUIEditorTestScene() - end - local back_label = ccui.Helper:seekWidgetByName(root, "back") - back_label:addTouchEventListener(toGUIEditorTestScene) -end - -function ScrollViewEditorTest:initExtend() - self:init() - - local node = cc.CSLoader:createNode("cocosui/UIEditorTest/UIScrollView/Vertical/res.csb") - local child = node:getChildByTag(5) - child:removeFromParent() - self._layout = child - self._uiLayer:addChild(self._layout) - self:configureGUIScene() -end - -function ScrollViewEditorTest.create() - local scene = cc.Scene:create() - local layer = ScrollViewEditorTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - cc.Director:getInstance():replaceScene(scene) -end - -local function runScrollViewEditorTestScene() - ScrollViewEditorTest.create() -end - -local PageViewEditorTest = class("PageViewEditorTest",UIScene) -PageViewEditorTest._displayValueLabel = nil - -function PageViewEditorTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, PageViewEditorTest) - return target -end - -function PageViewEditorTest:configureGUIScene() - local screenSize = cc.Director:getInstance():getWinSize() - local rootSize = self._layout:getContentSize() - self._uiLayer:setPosition(cc.p((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)) - - local root = self._layout:getChildByName("root_Panel") - local sceneTitle = ccui.Helper:seekWidgetByName(root, "UItest") - - local function toGUIEditorTestScene(sender,eventType) - self:unscheduleUpdate() - runCocoStudioUIEditorTestScene() - end - local back_label = ccui.Helper:seekWidgetByName(root, "back") - back_label:addTouchEventListener(toGUIEditorTestScene) -end - -function PageViewEditorTest:initExtend() - self:init() - - local node = cc.CSLoader:createNode("cocosui/UIEditorTest/UIPageView/res.csb") - local child = node:getChildByTag(5) - child:removeFromParent() - self._layout = child - self._uiLayer:addChild(self._layout) - self:configureGUIScene() -end - -function PageViewEditorTest.create() - local scene = cc.Scene:create() - local layer = PageViewEditorTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - cc.Director:getInstance():replaceScene(scene) -end - -local function runPageViewEditorTestScene() - PageViewEditorTest.create() -end - -local ListViewEditorTest = class("ListViewEditorTest",UIScene) -ListViewEditorTest._displayValueLabel = nil - -function ListViewEditorTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, ListViewEditorTest) - return target -end - -function ListViewEditorTest:configureGUIScene() - local screenSize = cc.Director:getInstance():getWinSize() - local rootSize = self._layout:getContentSize() - self._uiLayer:setPosition(cc.p((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)) - - local root = self._layout:getChildByName("root_Panel") - local sceneTitle = ccui.Helper:seekWidgetByName(root, "UItest") - - local function toGUIEditorTestScene(sender,eventType) - self:unscheduleUpdate() - runCocoStudioUIEditorTestScene() - end - local back_label = ccui.Helper:seekWidgetByName(root, "back") - back_label:addTouchEventListener(toGUIEditorTestScene) - - -- local listView = ccui.Helper:seekWidgetByName(root, "ListView_1214") - -- if nil ~= listView then - -- print("listView isBounceEnabled ", listView:isBounceEnabled()) - -- end -end - -function ListViewEditorTest:setupListView(listView) - local scale = 0.5 - local itemMargin = listView:getItemsMargin() - - local item0 = ccui.Text:create() - item0:setString(string.format("Item margin: %d", math.floor(itemMargin))) - listView:addChild(item0) - - local item1 = ccui.Layout:create() - local checkbox = ccui.CheckBox:create("selected01.png", "selected01.png", "selected02.png", "selected01.png", "selected01.png") - checkbox:setPosition(cc.p(checkbox:getCustomSize().width / 2, checkbox:getCustomSize().height / 2)) - item1:addChild(checkbox) - local checkboxText = ccui.Text:create() - checkboxText:setString("CheckBox") - checkboxText:setFontSize(checkbox:getCustomSize().width * 0.8) - checkboxText:setPosition(cc.p(checkbox:getCustomSize().width + checkboxText:getCustomSize().width / 2, checkbox:getCustomSize().height / 2)) - item1:addChild(checkboxText) - local item1Width = scale * (checkbox:getCustomSize().width + checkboxText:getCustomSize().width) - local item1Height = scale * checkbox:getCustomSize().height - item1:setContentSize(cc.size(item1Width, item1Height)) - item1:setScale(scale) - listView:addChild(item1) - - local item2 = ccui.Text:create() - item2:setString("Text2") - item2:setFontSize(checkbox:getCustomSize().width * 0.4) - item2:setTextColor(cc.c4b(0, 255, 0, 255)) - listView:addChild(item2) - - local item3 = ccui.Layout:create() - local imageview0 = ccui.ImageView:create("image.png") - local imageview1 = ccui.ImageView:create("image.png") - imageview1:setPositionX(imageview1:getCustomSize().width * 2) - imageview0:setAnchorPoint(cc.p(0, 0)) - imageview1:setAnchorPoint(cc.p(0, 0)) - item3:setContentSize(cc.size(imageview0:getCustomSize().width * 3 * scale, imageview0:getCustomSize().height * scale)) - item3:addChild(imageview0) - item3:addChild(imageview1) - item3:setScale(scale) - listView:addChild(item3) - - local item4 = ccui.Button:create("button.png", "button_p.png") - item4:setTitleText("Button") - listView:pushBackCustomItem(item4) - - local itemModel = ccui.Text:create() - itemModel:setTextColor(cc.c4b(255, 0, 0, 125)) - itemModel:setString("List item model") - listView:setItemModel(itemModel) - listView:pushBackDefaultItem() - listView:pushBackDefaultItem() -end - -function ListViewEditorTest:initExtend() - self:init() - - local node = cc.CSLoader:createNode("cocosui/UIEditorTest/UIListView/New/resV.csb") - local child = node:getChildByTag(5) - child:removeFromParent() - self._layout = child - self._uiLayer:addChild(self._layout) - self:configureGUIScene() - - local listView1 = ccui.Helper:seekWidgetByName(self._layout, "ListView1") - local listView2 = ccui.Helper:seekWidgetByName(self._layout, "ListView2") - local listView3 = ccui.Helper:seekWidgetByName(self._layout, "ListView3") - self:setupListView(listView1) - self:setupListView(listView2) - self:setupListView(listView3) -end - -function ListViewEditorTest.create() - local scene = cc.Scene:create() - local layer = ListViewEditorTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - cc.Director:getInstance():replaceScene(scene) -end - -local function runListViewEditorTestScene() - ListViewEditorTest.create() -end - -local WidgetAddNodeEditorTest = class("WidgetAddNodeEditorTest",UIScene) -WidgetAddNodeEditorTest._displayValueLabel = nil - -function WidgetAddNodeEditorTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, WidgetAddNodeEditorTest) - return target -end - -function WidgetAddNodeEditorTest:configureGUIScene() - local screenSize = cc.Director:getInstance():getWinSize() - local rootSize = self._layout:getContentSize() - self._uiLayer:setPosition(cc.p((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)) - - local root = self._layout:getChildByName("root_Panel") - local sceneTitle = ccui.Helper:seekWidgetByName(root, "UItest") - - local function toGUIEditorTestScene(sender,eventType) - self:unscheduleUpdate() - runCocoStudioUIEditorTestScene() - end - local back_label = ccui.Helper:seekWidgetByName(root, "back") - back_label:addTouchEventListener(toGUIEditorTestScene) - - - local widget = ccui.Widget:create() - widget:setPosition(cc.p(rootSize.width / 2.0, rootSize.height / 2.0)) - widget:setLocalZOrder(self._layout:getLocalZOrder() + 1) - self._layout:addChild(widget) - - local sprite = cc.Sprite:create("cocosui/ccicon.png") - widget:addChild(sprite) -end - -function WidgetAddNodeEditorTest:initExtend() - self:init() - - local node = cc.CSLoader:createNode("cocosui/UIEditorTest/UIWidgetAddNode/res.csb") - local child = node:getChildByTag(5) - child:removeFromParent() - self._layout = child - self._uiLayer:addChild(self._layout) - self:configureGUIScene() -end - -function WidgetAddNodeEditorTest.create() - local scene = cc.Scene:create() - local layer = WidgetAddNodeEditorTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - cc.Director:getInstance():replaceScene(scene) -end - -local function runWidgetAddNodeEditorTestScene() - WidgetAddNodeEditorTest.create() -end - -local UIEditorTestItemNames = -{ - { - itemTitle = "gui Editor ButtonTest", - testScene = function () - runEditButtonTestScene() - end - }, - - { - itemTitle = "gui Editor CheckBoxTest", - testScene = function () - runEditButtonEditorTestScene() - end - }, - - { - itemTitle = "gui Editor SliderTest", - testScene = function () - runSliderEditorTestScene() - end - }, - - { - itemTitle = "gui Editor ImageViewTest", - testScene = function () - runImageViewEditorTestScene() - end - }, - - { - itemTitle = "gui Editor LoadingBarTest", - testScene = function () - runLoadingBarEditorTestScene() - end - }, - - -- { - -- itemTitle = "gui Editor LabelAtalsTest", - -- testScene = function () - -- runLabelAtalsEditorTestScene() - -- end - -- }, - - { - itemTitle = "gui Editor LabelTest", - testScene = function () - runLabelEditorTestScene() - end - }, - - { - itemTitle = "gui Editor LabelBMFontTest", - testScene = function () - runLabelBMFontEditorTestScene() - end - }, - - { - itemTitle = "gui Editor TextFieldTest", - testScene = function () - runTextFieldEditorTestScene() - end - }, - - { - itemTitle = "gui Editor LayoutTest", - testScene = function () - runLayoutEditorTestScene() - end - }, - - { - itemTitle = "gui Editor UILayoutComponentTest", - testScene = function () - runLayoutComponentTestScene() - end - }, - - { - itemTitle = "gui Editor ScrollViewTest", - testScene = function () - runScrollViewEditorTestScene() - end - }, - - { - itemTitle = "gui Editor PageViewTest", - testScene = function () - runPageViewEditorTestScene() - end - }, - - { - itemTitle = "gui Editor ListViewTest", - testScene = function () - runListViewEditorTestScene() - end - }, - - { - itemTitle = "gui Editor WidgetAddNodeTest", - testScene = function () - runWidgetAddNodeEditorTestScene() - end - }, -} - -local CocoStudioUIEditorTestScene = class("CocoStudioUIEditorTestScene") -CocoStudioUIEditorTestScene.__index = CocoStudioUIEditorTestScene - -function CocoStudioUIEditorTestScene.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, CocoStudioUIEditorTestScene) - return target -end - -function CocoStudioUIEditorTestScene:runThisTest() - -end - -function CocoStudioUIEditorTestScene.create() - local scene = CocoStudioUIEditorTestScene.extend(cc.Scene:create()) - return scene -end - -local CocoStudioUIEditorTestLayer = class("CocoStudioUIEditorTestLayer") -CocoStudioUIEditorTestLayer.__index = CocoStudioUIEditorTestLayer - -function CocoStudioUIEditorTestLayer.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, CocoStudioUIEditorTestLayer) - return target -end - -function CocoStudioUIEditorTestLayer.onMenuCallback(tag,sender) - local index = sender:getLocalZOrder() - ITEM_TAG_BASIC - UIEditorTestItemNames[index].testScene() -end - -function CocoStudioUIEditorTestLayer:createMenu() - - local winSize = cc.Director:getInstance():getWinSize() - - local menu = cc.Menu:create() - menu:setContentSize(cc.size(winSize.width, (#UIEditorTestItemNames + 1) * (LINE_SPACE))) - menu:setPosition(CurPos.x, CurPos.y) - cc.MenuItemFont:setFontName("Arial") - cc.MenuItemFont:setFontSize(24) - - for i = 1, #UIEditorTestItemNames do - local menuItem = cc.MenuItemFont:create(UIEditorTestItemNames[i].itemTitle) - menuItem:setPosition(cc.p(winSize.width / 2, winSize.height - i* LINE_SPACE)) - menuItem:registerScriptTapHandler(CocoStudioUIEditorTestLayer.onMenuCallback) - menu:addChild(menuItem, ITEM_TAG_BASIC + i) - end - - self:addChild(menu) - - -- handling touch events - local function onTouchBegan(touch, event) - BeginPos = touch:getLocation() - return true - end - - local function onTouchMoved(touch, event) - local location = touch:getLocation() - local nMoveY = location.y - BeginPos.y - local curPosx, curPosy = menu:getPosition() - local nextPosy = curPosy + nMoveY - if nextPosy < 0 then - menu:setPosition(0, 0) - return - end - - if nextPosy > ((#UIEditorTestItemNames + 1) * LINE_SPACE - winSize.height) then - menu:setPosition(0, ((#UIEditorTestItemNames + 1) * LINE_SPACE - winSize.height)) - return - end - - menu:setPosition(curPosx, nextPosy) - BeginPos = {x = location.x, y = location.y} - CurPos = {x = curPosx, y = nextPosy} - end - - local listener = cc.EventListenerTouchOneByOne:create() - listener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN ) - listener:registerScriptHandler(onTouchMoved,cc.Handler.EVENT_TOUCH_MOVED ) - local eventDispatcher = self:getEventDispatcher() - eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self) -end - -function CocoStudioUIEditorTestLayer.create() - local layer = CocoStudioUIEditorTestLayer.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - end - return layer -end - -------------------------------------- ---CocoStudioUIEditorTest -------------------------------------- -function runCocoStudioUIEditorTestScene() - local newScene = CocoStudioUIEditorTestScene.create() - newScene:addChild(CreateBackMenuItem()) - newScene:addChild(CocoStudioUIEditorTestLayer.create()) - cc.Director:getInstance():replaceScene(newScene) -end diff --git a/tests/lua-tests/src/CocosStudio3DTest/CocosStudio3DTest.lua b/tests/lua-tests/src/CocosStudio3DTest/CocosStudio3DTest.lua deleted file mode 100644 index ab6556bec9..0000000000 --- a/tests/lua-tests/src/CocosStudio3DTest/CocosStudio3DTest.lua +++ /dev/null @@ -1,111 +0,0 @@ ----------------------------------------- -----CSNode3DTest ----------------------------------------- - -local CSNode3DTest = {} -CSNode3DTest.__index = CSNode3DTest - -function CSNode3DTest.create() - local layer = cc.Layer:create() - Helper.initWithLayer(layer) - Helper.titleLabel:setString("Node3DReader Test") - - local node = cc.CSLoader:createNode("ccs-res/scene3DTest/Node3D.csb"); - - local size = cc.Director:getInstance():getWinSize() - local label = cc.LabelTTF:create("Function demo, no content to show", "Arial", 24) - label:setPosition( cc.p(size.width / 2, size.height / 2) ) - label:setColor(cc.c3b(255, 127, 0)) - node:addChild(label); - - layer:addChild(node); - - return layer; -end - ----------------------------------------- -----CSSprite3DTest ----------------------------------------- - -local CSSprite3DTest = {} -CSSprite3DTest.__index = CSSprite3DTest - -function CSSprite3DTest.create() - local layer = cc.Layer:create() - Helper.initWithLayer(layer) - Helper.titleLabel:setString("Sprite3DReader Test") - - local node = cc.CSLoader:createNode("ccs-res/scene3DTest/Sprite3D.csb") - - local sprite3D = node:getChildByTag(8) - local size = cc.Director:getInstance():getWinSize() - - sprite3D:setPosition(size.width / 2, size.height / 2 - 50) - sprite3D:setColor(cc.c3b(255, 255, 255)) - sprite3D:setOpacity(255) - - layer:addChild(node) - - return layer -end - ----------------------------------------- -----CSUserCameraTest ----------------------------------------- - -local CSUserCameraTest = {} -CSUserCameraTest.__index = CSUserCameraTest - -function CSUserCameraTest.create() - local layer = cc.Layer:create() - Helper.initWithLayer(layer) - Helper.titleLabel:setString("UserCameraReader Test") - - local node = cc.CSLoader:createNode("ccs-res/scene3DTest/UserCamera.csb") - - local sprite3D = cc.Sprite3D:create("ccs-res/scene3DTest/dragon/dragon.c3b") - sprite3D:setPosition3D(cc.vec3(100, 95, 80)) - sprite3D:setCameraMask(cc.CameraFlag.USER1) - - layer:addChild(node) - layer:addChild(sprite3D) - - return layer -end - ----------------------------------------- -----CSParticle3DTest ----------------------------------------- - -local CSParticle3DTest = {} -CSParticle3DTest.__index = CSParticle3DTest - -function CSParticle3DTest.create() - local layer = cc.Layer:create() - Helper.initWithLayer(layer) - Helper.titleLabel:setString("Particle3DReader Test") - - local node = cc.CSLoader:createNode("ccs-res/scene3DTest/Particle3D.csb") - - layer:addChild(node) - - return layer -end - -function CocosStudio3DTest() - cc.FileUtils:getInstance():addSearchPath("ccs-res/scene3DTest") - local scene = cc.Scene:create() - - Helper.createFunctionTable = - { - CSNode3DTest.create, - CSSprite3DTest.create, - CSUserCameraTest.create, - CSParticle3DTest.create - } - - scene:addChild(CSNode3DTest.create()) - scene:addChild(CreateBackMenuItem()) - - return scene -end diff --git a/tests/lua-tests/src/controller.lua b/tests/lua-tests/src/controller.lua index 7fb1cf221c..5b51b7739f 100644 --- a/tests/lua-tests/src/controller.lua +++ b/tests/lua-tests/src/controller.lua @@ -43,75 +43,6 @@ local function addSearchPath(resPrefix, height) table.insert(searchPaths, 1, resPrefix .. "hd") table.insert(searchPaths, 1, resPrefix .. "ccs-res") table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/Images") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/ArmatureComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/AttributeComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/BackgroundComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/EffectComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/LoadSceneEdtiorFileTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/ParticleComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/SpriteComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/TmxMapComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/UIComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/TriggerTest") - - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UIButton") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UICheckBox") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UIImageView") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UILabel") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UILabelBMFont") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UILayout/BackgroundImage") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UILayout/Color") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UILayout/Layout") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UILayout/Gradient_Color") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UILayout/Scale9_BackgroundImage") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UILayout/LayoutComponent") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UILoadingBar") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UIPageView") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UIScrollView/Both") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UIScrollView/Horizontal") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UIScrollView/Vertical") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UISlider") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UITextField") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UIWidgetAddNode") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/cocosui/UIEditorTest/UIListView/New") - - table.insert(searchPaths, 1, resPrefix .. "hd/ActionTimeline") - else - table.insert(searchPaths, 1, resPrefix .. "ccs-res/Images") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/ArmatureComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/AttributeComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/BackgroundComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/EffectComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/LoadSceneEdtiorFileTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/ParticleComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/SpriteComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/TmxMapComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/UIComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/TriggerTest") - - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UIButton") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UICheckBox") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UIImageView") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UILabel") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UILabelBMFont") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UILayout/BackgroundImage") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UILayout/Color") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UILayout/Layout") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UILayout/Gradient_Color") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UILayout/Scale9_BackgroundImage") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UILayout/LayoutComponent") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UILoadingBar") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UIPageView") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UIScrollView/Both") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UIScrollView/Horizontal") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UIScrollView/Vertical") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UISlider") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UITextField") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UIWidgetAddNode") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/cocosui/UIEditorTest/UIListView/New") - - table.insert(searchPaths, 1, resPrefix .. "ActionTimeline") end fileUtils:setSearchPaths(searchPaths) @@ -119,7 +50,6 @@ local function addSearchPath(resPrefix, height) end addSearchPath("res/", screenSize.height) -addSearchPath("res/ccs-res/scene3DTest", screenSize.height) addSearchPath("", screenSize.height) require "mainMenu" diff --git a/tests/lua-tests/src/mainMenu.lua b/tests/lua-tests/src/mainMenu.lua index 01bb893eaf..9968cb7dc5 100644 --- a/tests/lua-tests/src/mainMenu.lua +++ b/tests/lua-tests/src/mainMenu.lua @@ -15,7 +15,6 @@ require "ByteCodeEncryptTest/ByteCodeEncryptTest" require "Camera3DTest/Camera3DTest" require "ClickAndMoveTest/ClickAndMoveTest" require "CocosDenshionTest/CocosDenshionTest" -require "CocoStudioTest/CocoStudioTest" require "ComponentTest/main" require "CurrentLanguageTest/CurrentLanguageTest" require "DrawPrimitivesTest/DrawPrimitivesTest" @@ -59,7 +58,6 @@ require "CaptureScreenTest/CaptureScreenTest" require "VideoPlayerTest/VideoPlayerTest" require "FastTiledMapTest/FastTiledMapTest" require "NewAudioEngineTest/NewAudioEngineTest" -require "CocosStudio3DTest/CocosStudio3DTest" require "WebViewTest/WebViewTest" require "SpritePolygonTest/SpritePolygonTest" require "Physics3DTest/Physics3DTest" @@ -107,8 +105,6 @@ local _allTests = { { isSupported = false, name = "ChipmunkAccelTouchTest" , create_func= ChipmunkAccelTouchTestMain }, { isSupported = true, name = "ClickAndMoveTest" , create_func = ClickAndMoveTest }, { isSupported = true, name = "CocosDenshionTest" , create_func = CocosDenshionTestMain }, - { isSupported = true, name = "CocosStudio3DTest" , create_func = CocosStudio3DTest}, - { isSupported = true, name = "CocoStudioTest" , create_func = CocoStudioTestMain }, { isSupported = true, name = "ComponentTest" , create_func = ComponentTestMain }, { isSupported = false, name = "CurlTest" , create_func= CurlTestMain }, { isSupported = true, name = "CurrentLanguageTest" , create_func= CurrentLanguageTestMain },